Received: by 10.213.65.68 with SMTP id h4csp49911imn; Sat, 24 Mar 2018 13:14:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELuyRfBRYL0oewY3My9NE4yNXYFD/NMQE9dtvsatyrt95tUsVTPqwmxZiFjJW+XFCvujeY87 X-Received: by 10.98.13.23 with SMTP id v23mr24236800pfi.202.1521922443189; Sat, 24 Mar 2018 13:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521922443; cv=none; d=google.com; s=arc-20160816; b=OeyD8KPkYXE/jgafNSGzVlSvv1Ly7sjJ00NkOdC8UlN7JLZ4ax8oNFMdhdR2xyRYIm k0RjCjrBytngtY33qCnUPUN6qizPY+OcXyu2GbHzobcx3OXWIqTnF/ztBtXN7/S7GjEJ MWAW0xShbNAvRww5KPt+z41Tw9inuZkCAl0JhHBZ1+9r+mCHVwJcS2z/f2oIGr+767Fh gjX2XOsEF51SoqOMn05P6IuNSZqHhF5F5NMrQ4AtI9XCysjGHPjFy9KmKxoQHJV0mseA KsrQ5rhbcL9vh8jwVTRqF3Y4yceiWkFM64KXS1Pl47djKyX4qg2ozJLwcmh8rOXS1t+i 5SYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=PfoZG+OfM+KQ+mxZczu+Cw2Lg1ZMn5RkC1C2x5VqBWE=; b=0I3l3V1yyrHVQhxJabAS62fAdMamc3Ezgw4g6aDn/t7mySb0l4q5jw4ozZi9lWsm9/ n7P0WM7g+ZDF2abUxUAXv+xwJlDQZdJAqw8rnvyq2CChnmQW2if+ZJi/Y/tJSb12MaCA ODC/7zoeCbG1+6ah0SFoLd9QIXjFUOe+CJfIzEAxGBw24NhmKtypdYaKHCa0xVHmWb7n mHbpOoK8R9kqn/liATwGuEuw6kk89nLStu0RFJzS5CRC9nvU8Zf1UErIN4SbvF2vYiwo brTNK4OoU7vhoGa/A4Kz5hsMBywf7ooEtCGYyc+n6dmyk5m1tvVzjyC8MN2sPDMWU1RY j1ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kr7y+hDs; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s23-v6si11886835plp.592.2018.03.24.13.13.49; Sat, 24 Mar 2018 13:14:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kr7y+hDs; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753439AbeCXULQ (ORCPT + 99 others); Sat, 24 Mar 2018 16:11:16 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:40769 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752920AbeCXULO (ORCPT ); Sat, 24 Mar 2018 16:11:14 -0400 Received: by mail-lf0-f67.google.com with SMTP id e5-v6so22903198lfb.7 for ; Sat, 24 Mar 2018 13:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PfoZG+OfM+KQ+mxZczu+Cw2Lg1ZMn5RkC1C2x5VqBWE=; b=Kr7y+hDsfL3MaB9ahaD4gCxZYeGbf9u5diTPnH+cESUBu8IRgI0kZ4GgnRzxYwqxnA 94mRo+k2qQfhXB600RJ9GffDY9UVNTpl+KsK6UGxzkA4ak4pdeHhfQQJcwUJZnbiF2kN 6zHFA3EBq4/xz9pvwmu5qDdOdw1G41gK60snfzF2nprImDebM5cdG8SPBVebsuNHFNcg XIktEm+8vgOJ5LSRG2ocp0KqlIbCwr89cox598C+i/POfKU+Z7UnvhNknAVDO1L5fuHN RHM7OJttQyGSOvEHVZLqMn8W753vxKRNcJFEP2fm6LAI7RRbLBoAKeIhWge5Bk0t9y5p QKkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PfoZG+OfM+KQ+mxZczu+Cw2Lg1ZMn5RkC1C2x5VqBWE=; b=uh0BXEdnabFsbtwYgDLBpuQHlid9olVOMgpNPChZUq5+U+2+RdYhMQrKAAloYhOJd/ 6Ou/Cnwa8wHgKm9OGnB0zxoT3poYy/sXVcheLNkfW83OOGZFPbR1frpaBljIzAUdCPtv igDIE7d5BgeZd2qsJaxVFdvH6DgdZG7XYy/qhmWyrpycUqTm1pB58FKK3JJRZXHV8dPa MGkK2Z5W4K12sZDGtqi12wdH+AzZCrmxJc9qKTmHMGdM+mHh4JDCAMYIL5DUBSB9q8ys bHLvIeZLBt05xz4sB3no0oL9Zz0n/MFrdcHa3liLGJdRnGxvBbq2LyIyOBwHmOHvUTCG ckZQ== X-Gm-Message-State: AElRT7E3FC+zdA9vPBpXz3ncLmfk+eY2FxPR5xm835X95fk0HY91AUOr 5oxnKQXgHcr2h03DUtkfcnY= X-Received: by 2002:a19:cf89:: with SMTP id f131-v6mr218890lfg.130.1521922272787; Sat, 24 Mar 2018 13:11:12 -0700 (PDT) Received: from esperanza (81.5.110.211.dhcp.mipt-telecom.ru. [81.5.110.211]) by smtp.gmail.com with ESMTPSA id f46-v6sm3014873lfh.56.2018.03.24.13.11.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Mar 2018 13:11:12 -0700 (PDT) Date: Sat, 24 Mar 2018 23:11:10 +0300 From: Vladimir Davydov To: Kirill Tkhai Cc: viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, hillf.zj@alibaba-inc.com, ying.huang@intel.com, mgorman@techsingularity.net, shakeelb@google.com, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org Subject: Re: [PATCH 09/10] mm: Iterate only over charged shrinkers during memcg shrink_slab() Message-ID: <20180324201109.r4udxibbg4t23apg@esperanza> References: <152163840790.21546.980703278415599202.stgit@localhost.localdomain> <152163857170.21546.16040899989532143840.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152163857170.21546.16040899989532143840.stgit@localhost.localdomain> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 21, 2018 at 04:22:51PM +0300, Kirill Tkhai wrote: > Using the preparations made in previous patches, in case of memcg > shrink, we may avoid shrinkers, which are not set in memcg's shrinkers > bitmap. To do that, we separate iterations over memcg-aware and > !memcg-aware shrinkers, and memcg-aware shrinkers are chosen > via for_each_set_bit() from the bitmap. In case of big nodes, > having many isolated environments, this gives significant > performance growth. See next patch for the details. > > Note, that the patch does not respect to empty memcg shrinkers, > since we never clear the bitmap bits after we set it once. > Their shrinkers will be called again, with no shrinked objects > as result. This functionality is provided by next patch. > > Signed-off-by: Kirill Tkhai > --- > mm/vmscan.c | 54 +++++++++++++++++++++++++++++++++++++++++------------- > 1 file changed, 41 insertions(+), 13 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 265cf069b470..e1fd16bc7a9b 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -327,6 +327,8 @@ static int alloc_shrinker_id(struct shrinker *shrinker) > > if (!(shrinker->flags & SHRINKER_MEMCG_AWARE)) > return 0; > + BUG_ON(!(shrinker->flags & SHRINKER_NUMA_AWARE)); > + > retry: > ida_pre_get(&bitmap_id_ida, GFP_KERNEL); > down_write(&bitmap_rwsem); > @@ -366,7 +368,8 @@ static void add_shrinker(struct shrinker *shrinker) > down_write(&shrinker_rwsem); > if (shrinker->flags & SHRINKER_MEMCG_AWARE) > mcg_shrinkers[shrinker->id] = shrinker; > - list_add_tail(&shrinker->list, &shrinker_list); > + else > + list_add_tail(&shrinker->list, &shrinker_list); I don't think we should remove per-memcg shrinkers from the global shrinker list - this is confusing. It won't be critical if we iterate over all shrinkers on global reclaim, will it? > up_write(&shrinker_rwsem); > } > > @@ -701,6 +705,39 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > if (!down_read_trylock(&shrinker_rwsem)) > goto out; > > +#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) > + if (!memcg_kmem_enabled() || memcg) { > + struct shrinkers_map *map; > + int i; > + > + map = rcu_dereference_protected(SHRINKERS_MAP(memcg), true); > + if (map) { > + for_each_set_bit(i, map->map[nid], bitmap_nr_ids) { > + struct shrink_control sc = { > + .gfp_mask = gfp_mask, > + .nid = nid, > + .memcg = memcg, > + }; > + > + shrinker = mcg_shrinkers[i]; > + if (!shrinker) { > + clear_bit(i, map->map[nid]); > + continue; > + } > + freed += do_shrink_slab(&sc, shrinker, priority); > + > + if (rwsem_is_contended(&shrinker_rwsem)) { > + freed = freed ? : 1; > + goto unlock; > + } > + } > + } > + > + if (memcg_kmem_enabled() && memcg) > + goto unlock; May be, factor this out to a separate function, say shrink_slab_memcg? Just for the sake of code legibility.