Received: by 10.213.65.68 with SMTP id h4csp36543imn; Sat, 24 Mar 2018 12:46:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELs3J/uTsidFSIQpWADDVBvzSi2PVyfwOtJ1NleUgSfuhg1/iM40VIAxoihZQdXOTCoGuRKQ X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr34562776pls.308.1521920819630; Sat, 24 Mar 2018 12:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521920819; cv=none; d=google.com; s=arc-20160816; b=F8KpZEhx4kuUXkDlc4nN3ycXJjLXINNZ4wl9I2e6oKyYA8gEKpEWleAbGIfvJABjvc rg3bjT5SDISOYsIIKQun6yDPv9t8s0YXNrWbhCo3qjoHgNtqUbaLT4MnWbmzfi6zu8Ii kGlq6tO6y/WonF1kiX0tyJgvoRjbh7waOeH/Lx++3jQx4gMn+Esm1Hh+nEhQHgWV++oH rYFxW4hfNePJcwRqk4IMs08PyaXeK+yFK01K4G8ULmFmu+ce5L4A7b6XjkW098vMHlrv 2hpBA05kc25WuCBCGaHwOYN6JwDt2CvHnn2at7+7/Hkh9x2DtxfxSbQVdnwSUAE5X4NC N4Zw== 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=U0YWY+ZVzy2XlfWcVqPivKBjyBCeJycNDU+Ppy09EwI=; b=Ucnh+WjHcTkzz2sB2xFmz6FmUviTjf5jjRvmRUM5Henpnrdaw4OjExsxsQu9xQYAG6 CHt126VOcqRiILY3zaKj1roGe3sw+UxWyc2QW1eh5KLO+cvxOOwSYSp7lQV1oRnGS2YL 2h2nKz50pw1bJ4N+U1eVOyO3M2hp2TG+kmPB/6yY3egMJsIySttno3XXaDvZsw+Vn/x3 U8efMFNXEuwEB7GpE/oedgmeRsvW3B8wvB76GHSOM6tkKgMKLhgD22Nrh8AHSt0Fsy/x lrwmksCm5F1tKdcKtPPLJ77BGK6HUR7rnpMRh9yC7spnw3bx4WGxx2hp5pG7+7oHvoEW UgPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IbmNEZhH; 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 c72si6441149pfk.369.2018.03.24.12.46.43; Sat, 24 Mar 2018 12:46: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IbmNEZhH; 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 S1752788AbeCXTpq (ORCPT + 99 others); Sat, 24 Mar 2018 15:45:46 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:45874 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752633AbeCXTpp (ORCPT ); Sat, 24 Mar 2018 15:45:45 -0400 Received: by mail-lf0-f65.google.com with SMTP id l4-v6so18497847lfg.12 for ; Sat, 24 Mar 2018 12:45:44 -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=U0YWY+ZVzy2XlfWcVqPivKBjyBCeJycNDU+Ppy09EwI=; b=IbmNEZhHh0atJ/5KAmvbS9vS+XKwGUAf9XvaVqTlvxS8/eWtH+UZQMjPa08h5dKhJl GGhBmXmnG50LkCKTOVtycXQsDGdYGjsdlLpVAfHKcTqfybZOBtokmXS/iNPAO7RcIiYy QZZD1PEXntRcVQLgEnbNtbRzvqss7ADC0HXg4QsDr2edB8lM7d1UKkY/up/iPn2lUfpL EiqO+GJTP+WGKPsgsvSYiO+oJacoHb2cSFD8BJnVJ4AZL/RhETFUF/h4/47JCaP5YdTa IGM3KHWyuCWYF19SMqRPlxIoEAWLeS4512uT/l905e59MmVoeOgO+ikpGRUYg3Ryx0tF LZ9A== 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=U0YWY+ZVzy2XlfWcVqPivKBjyBCeJycNDU+Ppy09EwI=; b=GpFaUnBU4JqT8yLO5Cp81O4SVDLrAVx40MEdAU5C4hfNlHUW25uAjWUpWexP+TeCpn WjHXTB3RBOwxIkdLSYYmeW/6bJnxldpHyjvuEB6wa+ftWJR6arhyVNMVXq4noUvTOpjU 4HrErrk+DQGSnDPBTD/g2eTS0EZwPATDwVnNiaY5FWyvBnR3MJYvKLlJ5LfjVVBou3SC HJv0JJ5DkPh0YAW7j9dKKoD+m3D1i+NNpOx9TLikyrlE/IaC7Lk0WTKT06+2qbi9OJl9 IRKfoGLQD5LpNkZ6fGNeq/xgH0gJNd4vmVuqgsJ8T3EKKgVK7A+67+xoA56pkr8WYjS0 ctBQ== X-Gm-Message-State: AElRT7EBOhzpTJDS5QnsO1g8LQrqgbeybQ6sshHEq/CsYnxcKITks56Y z2vN/83+aU3W4oHVWjY8gn4= X-Received: by 10.46.88.88 with SMTP id x24mr8048954ljd.144.1521920743656; Sat, 24 Mar 2018 12:45:43 -0700 (PDT) Received: from esperanza (81.5.110.211.dhcp.mipt-telecom.ru. [81.5.110.211]) by smtp.gmail.com with ESMTPSA id q28-v6sm3003696lfq.63.2018.03.24.12.45.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Mar 2018 12:45:42 -0700 (PDT) Date: Sat, 24 Mar 2018 22:45:40 +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 08/10] mm: Set bit in memcg shrinker bitmap on first list_lru item apearance Message-ID: <20180324194540.rvejbnjg6knkwwia@esperanza> References: <152163840790.21546.980703278415599202.stgit@localhost.localdomain> <152163856059.21546.11414341109878480074.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152163856059.21546.11414341109878480074.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:40PM +0300, Kirill Tkhai wrote: > Introduce set_shrinker_bit() function to set shrinker-related > bit in memcg shrinker bitmap, and set the bit after the first > item is added and in case of reparenting destroyed memcg's items. > > This will allow next patch to make shrinkers be called only, > in case of they have charged objects at the moment, and > to improve shrink_slab() performance. > > Signed-off-by: Kirill Tkhai > --- > include/linux/shrinker.h | 7 +++++++ > mm/list_lru.c | 22 ++++++++++++++++++++-- > mm/vmscan.c | 7 +++++++ > 3 files changed, 34 insertions(+), 2 deletions(-) > > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h > index 738de8ef5246..24aeed1bc332 100644 > --- a/include/linux/shrinker.h > +++ b/include/linux/shrinker.h > @@ -78,4 +78,11 @@ struct shrinker { > > extern __must_check int register_shrinker(struct shrinker *); > extern void unregister_shrinker(struct shrinker *); > +#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) > +extern void set_shrinker_bit(struct mem_cgroup *, int, int); > +#else > +static inline void set_shrinker_bit(struct mem_cgroup *memcg, int node, int id) > +{ > +} > +#endif IMO this function, as well as other shrinker bitmap manipulation functions, should be defined in memcontrol.[hc] and have mem_cgroup_ prefix. > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 9d1df5d90eca..265cf069b470 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -378,6 +378,13 @@ static void del_shrinker(struct shrinker *shrinker) > list_del(&shrinker->list); > up_write(&shrinker_rwsem); > } > + > +void set_shrinker_bit(struct mem_cgroup *memcg, int nid, int nr) > +{ > + struct shrinkers_map *map = SHRINKERS_MAP(memcg); > + > + set_bit(nr, map->map[nid]); > +} Shouldn't we use rcu_read_lock here? After all, the map can be reallocated right from under our feet.