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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 CA38AC433FE for ; Fri, 4 Dec 2020 18:55:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6343A22CA1 for ; Fri, 4 Dec 2020 18:55:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730327AbgLDSzi (ORCPT ); Fri, 4 Dec 2020 13:55:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbgLDSzh (ORCPT ); Fri, 4 Dec 2020 13:55:37 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58741C061A51 for ; Fri, 4 Dec 2020 10:54:51 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id 1so6451950qka.0 for ; Fri, 04 Dec 2020 10:54:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rg7lrS/4cr2DIOho7mbjVZXSDz3+KMSUQybW7MPBlNA=; b=twndtQ1CF5ITaAzRNV/5rAfbKfs+6rjo4uTloJ1pRExv5sQhw1SELhyHv/uLbYchHG OTGkOYTH1eBROSNK+yTXPNY62q7M+aOkghEDJ584QyK2euCGKPBdsdakiW1Cwic33peI glBoNZbYxdxPfibwDuInPMBJ+f3IXfiGqHjz56KaIG8jGSC6Jth5BgqVuCJSCTxOL58a yWVIgJVys6vFWeVmIHMhhLOFar4qS0BX8QJzRClyQU9UjNct0DdeQLYYQyyiKHJVZUV/ axI8PAqs1DqDTd9/kv9P7gjaA66x1EatLotAAc6sXtbvkA3ugA0ba8mdPPwQlm6ycK7D aO3A== 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=rg7lrS/4cr2DIOho7mbjVZXSDz3+KMSUQybW7MPBlNA=; b=XiwmGBboRZbOWDV+9Oy9qFtfQjo9T1Ot3ps1TJgOICggNkfl7SfewB+BpmyKd48mcM wrrQ02n3Podr9WME5fXOZODxzHMQM49B/gqpegNLCT22qXvGDk/X59bJbrSTBcnZH9t4 B9de2X/91ceeVJc5WBKuIBmB/WJmUKiobN5ClrFsfbire0FcjKhaDOgvhIA+3yQLQgOR PJpBLKLQ14c92mRQg+Pi2qTv9RCNj1uswhTIVzdv6neQpzxSlauddexnvrrf+dMIVa6x e8jNVZz7O2YIpRybWYVWZ/CsXHWUXM/ijBzWtbhMheYWrn2QrkmeCtYzzqaSeIHJJV3f gibA== X-Gm-Message-State: AOAM532OS0xNdG66F7mcvC8JDWL0t9oF6JFu9tsnDV6nN9Td88+yogxd sJEgrPCSD7L8kefwur3cixeoaw== X-Google-Smtp-Source: ABdhPJyQVuWk9koWKozYjk4xSbqAGSTa/BUZAQJ0yr3p51asd8OHOsW1+VTpzgu+YAEf8hAdK7BrVw== X-Received: by 2002:a37:6358:: with SMTP id x85mr10465468qkb.405.1607108090466; Fri, 04 Dec 2020 10:54:50 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:a180]) by smtp.gmail.com with ESMTPSA id 60sm1938803qth.14.2020.12.04.10.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 10:54:49 -0800 (PST) Date: Fri, 4 Dec 2020 13:52:47 -0500 From: Johannes Weiner To: Yang Shi Cc: Roman Gushchin , Kirill Tkhai , Shakeel Butt , Dave Chinner , Michal Hocko , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Subject: Re: [PATCH 4/9] mm: vmscan: use a new flag to indicate shrinker is registered Message-ID: <20201204185247.GA182921@cmpxchg.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020 at 02:25:20PM -0800, Yang Shi wrote: > 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. It's always possible to shuffle things around for cleanup later on, too. We don't have to provide binary compatibility for existing flags, and changing a couple of adjacent bits isn't a big deal to keep things neat. Or am I missing something?