From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52DABC433FE for ; Thu, 3 Dec 2020 22:25:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8C99B22285 for ; Thu, 3 Dec 2020 22:25:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C99B22285 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 87F226B0036; Thu, 3 Dec 2020 17:25:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 806996B005C; Thu, 3 Dec 2020 17:25:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D0858D0001; Thu, 3 Dec 2020 17:25:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 513166B0036 for ; Thu, 3 Dec 2020 17:25:34 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 13F5A8249980 for ; Thu, 3 Dec 2020 22:25:34 +0000 (UTC) X-FDA: 77553403788.01.fang28_4603950273bf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id E36991004B781 for ; Thu, 3 Dec 2020 22:25:33 +0000 (UTC) X-HE-Tag: fang28_4603950273bf X-Filterd-Recvd-Size: 5848 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Dec 2020 22:25:33 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id q13so5034553lfr.10 for ; Thu, 03 Dec 2020 14:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lZUGplS6otRHZGB4uiEDdWMeSyvXO6myoGBH5DWzVgY=; b=st5i+4HyffCKXte4m5SNX0NoAfoeMZo+7DYMbOn/WSWRpGMwDOEEjVmjvqCfNNK4+E wDfsSmm8xaAj+8E4q1Ha76gyKXlHlZmh/uFE/3G5kIdvjZjP2/ABU/E9E1Vm6tXFl8UY eeCr0UjpemF06+PayWaIfgkEtpFz60pK0RYlaJx/eve8aH4iaixxcg8H6ZPSAWpX2k4O 8CUP8k4CuqUicjrNbPIEhRfl7J1XduT73pfCkdQkodNYMsiXaM773QwzLrF4MSs3Ol9u IIVHogLCC7TG+zCfNJlN4F61Uww5HZnVH3dxgPhmAfQ9P3hfTGMHi3VatmUcqgo1mgPo L4FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lZUGplS6otRHZGB4uiEDdWMeSyvXO6myoGBH5DWzVgY=; b=mpz8EWNYYhyZnSxfYttk8TrfxfLNIrBXiFglwSAscbeJ9h1NoO2Fh1yuh+9HpipemC jb4sd4hl0uVe9yXnAIGaq4mXUv90RrakcJtO9IY76URQ4kcMVbPwdaw7v71FRPfZDQEA C+aE9gKuiQjGBuFjw6Efdy1aB+XuO5xNm6MedMMo5Z97Mml4dJmUQ9vE/UUroJnRGcey Hk03nnbv7MTvZcHmdVZL+1PEZap/MtfIn/FpHNumCMBGoVWtkHTMCF6QpBDxKe0Spe1l wmlqayh6d3FjivMi7waHQAWuhVSyluIAykyT4tk/YwJOSrBXL3322NCamW7EnhEWCuwX +d6Q== X-Gm-Message-State: AOAM533eNGUPNWRTa977OTPHtjusbEGqkE8sgSR8fDQk+qsRVEAB3Iy2 sPqFW+izn89zEwak0EBvziRwz9eWVdfOHZK2jRE= X-Google-Smtp-Source: ABdhPJw2KPcZ7OEA4t573BTxnublS3r8cLhXi4GH9AhB5ze7Ibd5eeYqJNdDp+L42MWu1By0HZpJj2+ibW285RfIpws= X-Received: by 2002:a19:6a07:: with SMTP id u7mr2012587lfu.252.1607034331908; Thu, 03 Dec 2020 14:25:31 -0800 (PST) MIME-Version: 1.0 References: <20201202182725.265020-1-shy828301@gmail.com> <20201202182725.265020-5-shy828301@gmail.com> <20201203030104.GF1375014@carbon.DHCP.thefacebook.com> <20201203200820.GC1571588@carbon.DHCP.thefacebook.com> In-Reply-To: <20201203200820.GC1571588@carbon.DHCP.thefacebook.com> From: Yang Shi Date: Thu, 3 Dec 2020 14:25:20 -0800 Message-ID: Subject: Re: [PATCH 4/9] mm: vmscan: use a new flag to indicate shrinker is registered To: Roman Gushchin Cc: Kirill Tkhai , Shakeel Butt , Dave Chinner , Johannes Weiner , Michal Hocko , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Dec 3, 2020 at 12:09 PM Roman Gushchin wrote: > > On Wed, Dec 02, 2020 at 08:59:40PM -0800, Yang Shi wrote: > > On Wed, Dec 2, 2020 at 7:01 PM Roman Gushchin wrote: > > > > > > On Wed, Dec 02, 2020 at 10:27:20AM -0800, Yang Shi wrote: > > > > Currently registered shrinker is indicated by non-NULL shrinker->nr_deferred. > > > > This approach is fine with nr_deferred atthe shrinker level, but the following > > > > patches will move MEMCG_AWARE shrinkers' nr_deferred to memcg level, so their > > > > shrinker->nr_deferred would always be NULL. This would prevent the shrinkers > > > > from unregistering correctly. > > > > > > > > Introduce a new "state" field to indicate if shrinker is registered or not. > > > > We could use the highest bit of flags, but it may be a little bit complicated to > > > > extract that bit and the flags is accessed frequently by vmscan (every time shrinker > > > > is called). So add a new field in "struct shrinker", we may waster a little bit > > > > memory, but it should be very few since there should be not too many registered > > > > shrinkers on a normal system. > > > > > > > > Signed-off-by: Yang Shi > > > > --- > > > > include/linux/shrinker.h | 4 ++++ > > > > mm/vmscan.c | 13 +++++++++---- > > > > 2 files changed, 13 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h > > > > index 0f80123650e2..0bb5be88e41d 100644 > > > > --- a/include/linux/shrinker.h > > > > +++ b/include/linux/shrinker.h > > > > @@ -35,6 +35,9 @@ struct shrink_control { > > > > > > > > #define SHRINK_STOP (~0UL) > > > > #define SHRINK_EMPTY (~0UL - 1) > > > > + > > > > +#define SHRINKER_REGISTERED 0x1 > > > > + > > > > /* > > > > * A callback you can register to apply pressure to ageable caches. > > > > * > > > > @@ -66,6 +69,7 @@ struct shrinker { > > > > long batch; /* reclaim batch size, 0 = default */ > > > > int seeks; /* seeks to recreate an obj */ > > > > unsigned flags; > > > > + unsigned state; > > > > > > Hm, can't it be another flag? It seems like we have a plenty of free bits. > > > > I thought about this too. But I was not convinced by myself that > > messing flags with state is a good practice. We may add more flags in > > the future, so we may end up having something like: > > > > flag > > flag > > flag > > state > > flag > > flag > > ... > > > > Maybe we could use the highest bit for state? > > Or just > state > flag > flag > flag > flag > flag > ... > > ? It is fine too. We should not add more states in foreseeable future.