Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1463814ybg; Wed, 23 Oct 2019 16:27:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYJ7EZqwZTGCjFxq9V1fdVjwcumb9c0at+0OVljKSVbcgBKQFMkX3Wpq7N9XntkLsDTb0L X-Received: by 2002:a17:907:213c:: with SMTP id qo28mr20744526ejb.43.1571873279342; Wed, 23 Oct 2019 16:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571873279; cv=none; d=google.com; s=arc-20160816; b=qZtSS2t/gwUeWGsbcTEHW0ZUeNZS3lCXI85i8dG2Bw9E2pOXZaeAXDobz2ZRMfh21T K6hekPnh4o8hSj+aY6SYwV2YTwiQsnETjQzgbDCDWRdXb1+ebo2IS/fmtuyoHsJAtD9w 3bPK9MbVS50ShtoklLaN38TthO8jnBctkn7SpTyUo1QhQXKgvRY8O6xi2jIv7yWGpgaE diMQ/ykLQTxBjYVO3Yfe0xo8+NFDWiQg9Lzye94cHr3JlJD6w1fv1XXfXs9d9iqFk7Uj 3n+hMwIvJ2GITWDrSm1IwAwoyMryZe/EWN8mmkqhivfpPghX+z872l4qNhim79QzH6oS 4VzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=P7oNQc7kKtPoOu/mJDBDn/7n+Lei3A+oBCVOcpST4X0=; b=cPn5EmcrzXDyNSlKR9zntTRofQme5ssuLj3SKS9SnIxKUSZbo0F9gXCVifEYXETaeX f6N2Kfgr2dr1dVE7gatrPsFEoknTZj7Hcy05FymiYMRqqGK9MLnFIUvaaa8hWImCqp4l VpR2KfDlMLse/EDwq2EDM4ziEF8ol74bPoEu4fN0aUtgzh5xXBZh3dMQ3uPc8IgaIO68 CIgiOFNNz1rZMO0yLCg8eYWcl3KvNy7dNdWbIxq+hQar/z4BNrjbiQm8TpxCI9tk/kZs oGPocFlLFap3UNC4yoW9quVLcD2SFHOgiM4+4fJNT3etrMPfO3oZvvTszqoVq4rUMmco /X0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o22si468233ejm.429.2019.10.23.16.27.34; Wed, 23 Oct 2019 16:27:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392191AbfJWOZB (ORCPT + 99 others); Wed, 23 Oct 2019 10:25:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:39862 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725852AbfJWOZA (ORCPT ); Wed, 23 Oct 2019 10:25:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6384FB422; Wed, 23 Oct 2019 14:24:38 +0000 (UTC) Date: Wed, 23 Oct 2019 16:24:37 +0200 From: Michal Hocko To: Johannes Weiner Cc: Andrew Morton , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 7/8] mm: vmscan: split shrink_node() into node part and memcgs part Message-ID: <20191023142437.GH17610@dhcp22.suse.cz> References: <20191022144803.302233-1-hannes@cmpxchg.org> <20191022144803.302233-8-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191022144803.302233-8-hannes@cmpxchg.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 22-10-19 10:48:02, Johannes Weiner wrote: > This function is getting long and unwieldy, split out the memcg bits. > > The updated shrink_node() handles the generic (node) reclaim aspects: > - global vmpressure notifications > - writeback and congestion throttling > - reclaim/compaction management > - kswapd giving up on unreclaimable nodes > > It then calls a new shrink_node_memcgs() which handles cgroup specifics: > - the cgroup tree traversal > - memory.low considerations > - per-cgroup slab shrinking callbacks > - per-cgroup vmpressure notifications > > Signed-off-by: Johannes Weiner Acked-by: Michal Hocko > --- > mm/vmscan.c | 28 ++++++++++++++++++---------- > 1 file changed, 18 insertions(+), 10 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index db073b40c432..65baa89740dd 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2722,18 +2722,10 @@ static bool pgdat_memcg_congested(pg_data_t *pgdat, struct mem_cgroup *memcg) > (memcg && memcg_congested(pgdat, memcg)); > } > > -static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > +static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) > { > - struct reclaim_state *reclaim_state = current->reclaim_state; > struct mem_cgroup *root = sc->target_mem_cgroup; > - unsigned long nr_reclaimed, nr_scanned; > - bool reclaimable = false; > struct mem_cgroup *memcg; > -again: > - memset(&sc->nr, 0, sizeof(sc->nr)); > - > - nr_reclaimed = sc->nr_reclaimed; > - nr_scanned = sc->nr_scanned; > > memcg = mem_cgroup_iter(root, NULL, NULL); > do { > @@ -2786,6 +2778,22 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > sc->nr_reclaimed - reclaimed); > > } while ((memcg = mem_cgroup_iter(root, memcg, NULL))); > +} > + > +static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > +{ > + struct reclaim_state *reclaim_state = current->reclaim_state; > + struct mem_cgroup *root = sc->target_mem_cgroup; > + unsigned long nr_reclaimed, nr_scanned; > + bool reclaimable = false; > + > +again: > + memset(&sc->nr, 0, sizeof(sc->nr)); > + > + nr_reclaimed = sc->nr_reclaimed; > + nr_scanned = sc->nr_scanned; > + > + shrink_node_memcgs(pgdat, sc); > > if (reclaim_state) { > sc->nr_reclaimed += reclaim_state->reclaimed_slab; > @@ -2793,7 +2801,7 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > } > > /* Record the subtree's reclaim efficiency */ > - vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true, > + vmpressure(sc->gfp_mask, root, true, > sc->nr_scanned - nr_scanned, > sc->nr_reclaimed - nr_reclaimed); > > -- > 2.23.0 > -- Michal Hocko SUSE Labs