From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934756AbdBVUyz (ORCPT ); Wed, 22 Feb 2017 15:54:55 -0500 Received: from gum.cmpxchg.org ([85.214.110.215]:36662 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933512AbdBVUys (ORCPT ); Wed, 22 Feb 2017 15:54:48 -0500 Date: Wed, 22 Feb 2017 15:24:06 -0500 From: Johannes Weiner To: Michal Hocko Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jia He , Andrew Morton , Mel Gorman , Vlastimil Babka , Minchan Kim , Rik van Riel Subject: Re: [RFC PATCH] mm/vmscan: fix high cpu usage of kswapd if there Message-ID: <20170222202406.GB6534@cmpxchg.org> References: <1487754288-5149-1-git-send-email-hejianet@gmail.com> <20170222201657.GA6534@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170222201657.GA6534@cmpxchg.org> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 22, 2017 at 03:16:57PM -0500, Johannes Weiner wrote: > [...] And then it sounds pretty much like what the allocator/direct > reclaim already does. On a side note: Michal, I'm not sure I fully understand why we need the backoff code in should_reclaim_retry(). If no_progress_loops is growing steadily, then we quickly reach 16 and bail anyway. Layering on top a backoff function that *might* cut out an iteration or two earlier in the cold path of an OOM situation seems unnecessary. Conversely, if there *are* intermittent reclaims, no_progress_loops gets reset straight to 0, which then also makes the backoff function jump back to square one. So in the only situation where backing off would make sense - making some progress, but not enough - it's not actually backing off. It seems to me it should be enough to bail after either 16 iterations or when free + reclaimable < watermark. Hm? diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c470b8fe28cf..b0e9495c0530 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3396,11 +3396,10 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) /* * Checks whether it makes sense to retry the reclaim to make a forward progress * for the given allocation request. - * The reclaim feedback represented by did_some_progress (any progress during - * the last reclaim round) and no_progress_loops (number of reclaim rounds without - * any progress in a row) is considered as well as the reclaimable pages on the - * applicable zone list (with a backoff mechanism which is a function of - * no_progress_loops). + * + * We give up when we either have tried MAX_RECLAIM_RETRIES in a row + * without success, or when we couldn't even meet the watermark if we + * reclaimed all remaining pages on the LRU lists. * * Returns true if a retry is viable or false to enter the oom path. */ @@ -3441,13 +3440,11 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, unsigned long reclaimable; available = reclaimable = zone_reclaimable_pages(zone); - available -= DIV_ROUND_UP((*no_progress_loops) * available, - MAX_RECLAIM_RETRIES); available += zone_page_state_snapshot(zone, NR_FREE_PAGES); /* - * Would the allocation succeed if we reclaimed the whole - * available? + * Would the allocation succeed if we reclaimed all + * the reclaimable pages? */ if (__zone_watermark_ok(zone, order, min_wmark_pages(zone), ac_classzone_idx(ac), alloc_flags, available)) {