Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1990372pxu; Fri, 18 Dec 2020 02:54:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw32iUD3xGthP+omS/k7gXH7hmUkKJ96tCGdoy/GczmQeIHu3JMm3D/FNCzyZEw4jK77rW9 X-Received: by 2002:a17:906:7f10:: with SMTP id d16mr3417419ejr.104.1608288871198; Fri, 18 Dec 2020 02:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608288871; cv=none; d=google.com; s=arc-20160816; b=R85HnHECUozjw1kl0Mpge92h8aEeFath3O7ZtWSEAIy5gwTAq0a8Bj6coq7iFGNmUl FLS2DBnXfx7G62te2tMlnjCUgK2M9sTlGP62edY6D356BCMhnLtMYymLn+LMclCgn+TT hnvVe90Cb5zsRY5nPHvt0W393UWlYp7rCkSWxuu0TLc93G21R0uQLIpibff16sH+lbtf XPkvx2Yvu3WTKSfCrGnq3rC/H7r0BM8rNUI/LEfAU0PcXMyVJD4o+aCvGYpe67RhC15+ yEi0krLgYd9cyHFUeaC+Wltf2RNCoIGeLGsWmG2nhut3/fErwUYQ2MLoBXDRmNOQqDKE YP6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8MQYiPPFwOXe1yceAmnwSQFW51gmPEmADZJTW8S8zQI=; b=TGGCVNDqlCug8CH2MEHahjgxuLh4i6CVcz+Vi2vp83+vVVh+V3zEH/GjZWiqSHYkgI r1jXir30O5eE93ReDQ3+x2Ja4MIeUzPhWrvwJGcey4GhsNu8gb4ggFF7n0Ajv0j0Cb/W j0et5yDp3QejMzfR9Ix/ULK5vHVYi8i81C23qKsOSfike1Yxryp9xtE1lvCWjRBBxZrc SqLaY5vLmWqv7uKv7mJ8rwQWnA8desf2kUGIak8egiAzQDnK5q+csdfdKR3GLDj2wOH5 3qGbBNeeZrnD5/g5Diy1PTLoAS/RPEHTo9nM8gTzn0oip2wZlsrzEclB2WgFfCl0Ir5e wxrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=p4Oy1M04; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a29si6560107edm.401.2020.12.18.02.54.08; Fri, 18 Dec 2020 02:54:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=p4Oy1M04; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389097AbgLRKwk (ORCPT + 99 others); Fri, 18 Dec 2020 05:52:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:38928 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389078AbgLRKwk (ORCPT ); Fri, 18 Dec 2020 05:52:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1608288713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8MQYiPPFwOXe1yceAmnwSQFW51gmPEmADZJTW8S8zQI=; b=p4Oy1M04f2z+5mTIDxeHlLDELqaylg9Gmjc2rKY/4RyCJDvjqifw7iPZAP3KOtOk3LWusj XB3+Z9mwv9BWy78dBl7B2PWo//ZMnBQjrPCLemF0ObWjjZg0oXwVXiF+/7agKiHYhzni+P wOtyf+ZVCSfPvvWFnhnAyi3ncPW8slA= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D0827ABC6; Fri, 18 Dec 2020 10:51:53 +0000 (UTC) Date: Fri, 18 Dec 2020 11:51:53 +0100 From: Michal Hocko To: Jacob Wen Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH] mm/vmscan: DRY cleanup for do_try_to_free_pages() Message-ID: <20201218105153.GX32193@dhcp22.suse.cz> References: <20201218102217.186836-1-jian.w.wen@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201218102217.186836-1-jian.w.wen@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 18-12-20 18:22:17, Jacob Wen wrote: > This patch reduces repetition of set_task_reclaim_state() around > do_try_to_free_pages(). The changelog really should be talking about why this is needed/useful. From the above it is not really clear whether you aimed at doing a clean up or this is a fix for some misbehavior. I do assume the former but this should be clearly articulated. > Signed-off-by: Jacob Wen > --- > mm/vmscan.c | 27 ++++++++++++++++----------- > 1 file changed, 16 insertions(+), 11 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 257cba79a96d..4bc244b23686 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -3023,6 +3023,10 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, > pg_data_t *last_pgdat; > struct zoneref *z; > struct zone *zone; > + unsigned long ret; > + > + set_task_reclaim_state(current, &sc->reclaim_state); > + > retry: > delayacct_freepages_start(); > > @@ -3069,12 +3073,16 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, > > delayacct_freepages_end(); > > - if (sc->nr_reclaimed) > - return sc->nr_reclaimed; > + if (sc->nr_reclaimed) { > + ret = sc->nr_reclaimed; > + goto out; > + } > > /* Aborted reclaim to try compaction? don't OOM, then */ > - if (sc->compaction_ready) > - return 1; > + if (sc->compaction_ready) { > + ret = 1; > + goto out; > + } > > /* > * We make inactive:active ratio decisions based on the node's > @@ -3101,7 +3109,10 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, > goto retry; > } > > - return 0; > + ret = 0; > +out: > + set_task_reclaim_state(current, NULL); > + return ret; > } > > static bool allow_direct_reclaim(pg_data_t *pgdat) > @@ -3269,13 +3280,11 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, > if (throttle_direct_reclaim(sc.gfp_mask, zonelist, nodemask)) > return 1; > > - set_task_reclaim_state(current, &sc.reclaim_state); > trace_mm_vmscan_direct_reclaim_begin(order, sc.gfp_mask); > > nr_reclaimed = do_try_to_free_pages(zonelist, &sc); > > trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); > - set_task_reclaim_state(current, NULL); > > return nr_reclaimed; > } > @@ -3347,7 +3356,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, > */ > struct zonelist *zonelist = node_zonelist(numa_node_id(), sc.gfp_mask); > > - set_task_reclaim_state(current, &sc.reclaim_state); > trace_mm_vmscan_memcg_reclaim_begin(0, sc.gfp_mask); > noreclaim_flag = memalloc_noreclaim_save(); > > @@ -3355,7 +3363,6 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, > > memalloc_noreclaim_restore(noreclaim_flag); > trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); > - set_task_reclaim_state(current, NULL); > > return nr_reclaimed; > } > @@ -4023,11 +4030,9 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) > > fs_reclaim_acquire(sc.gfp_mask); > noreclaim_flag = memalloc_noreclaim_save(); > - set_task_reclaim_state(current, &sc.reclaim_state); > > nr_reclaimed = do_try_to_free_pages(zonelist, &sc); > > - set_task_reclaim_state(current, NULL); > memalloc_noreclaim_restore(noreclaim_flag); > fs_reclaim_release(sc.gfp_mask); > > -- > 2.25.1 > -- Michal Hocko SUSE Labs