Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3301997lfo; Mon, 23 May 2022 01:07:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf+I5fWYhVJK9T5qeymj/p45n1f+JURlWPPnzcEMDA+WD/A4QAlHsyaXcppM2xjpfvTgxu X-Received: by 2002:a17:90a:4414:b0:1df:9b8f:c3cc with SMTP id s20-20020a17090a441400b001df9b8fc3ccmr25358809pjg.56.1653293276688; Mon, 23 May 2022 01:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653293276; cv=none; d=google.com; s=arc-20160816; b=L+3uS/5anTg3bZhn+MKRL+9mEXjVRb70wH3pyAGVrVdNOM9XlmvBMPNWn0wPxBSV8D /b5nkWBb/MaDh9n/0qtGcKANVBN+cfnBQAFkfB8TG5eLtEJZvEchaqi9SMy21uxpqGuv Gew+LIs6n2z8iMyS16GmUG5Q3sxJK1mrEGOujDOeleA4jyaNwhEUo8SLC0FD7hqJshOQ WHNDsCQsuZPPeoy3rtg7FO7GsZ85PB5ACI/PkqBMbLcQxhyh4yVJZxO0bkMD19Ecq3w9 Os3TrrXv5qVc7Ie9O3Q9/Qe0ydgzR3yca20Cz7hYjV07tFjoujXca2lmZ12VSQyisGdl BGRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=F5eyjWrzyQRAet2h2zzIhMgprOHdczgT1J41NuiNraQ=; b=NSbOAGygXeiANBvNm1MFltOFL5DBJbLHZU3KkKPS6MY5kT9OYrRei06jkExF4zs9cC p44NQC1XGHglVba9T54rxwNdoXsT2PjKPiKrT8RFyCOOs1bNeOdBUZmbcjaPD/BNup0m 6pZ4SpiqPirb3WaJr97/i8i7EwoFGT/S89Vu8X2r7JRweF1qFr4OvO1cLDGSRAIbAXeO DGtrfgWEMhfLgyf9BLtPI/iNofzEe8NPBPK2hfSi9JhaaH4iWQ3bePK8Tvy7seYtwPhx 4NKMENxj7HFTLX8wMkmaiwpBBgaXiI7Ktd7R/gIMVvmvPOu+lQ+GKVe2sLyaO1UiMurX +Lbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nv12-20020a17090b1b4c00b001dc391fd23csi14408936pjb.134.2022.05.23.01.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01577168D02; Mon, 23 May 2022 00:03:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344838AbiETQ6T (ORCPT + 99 others); Fri, 20 May 2022 12:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237714AbiETQ6S (ORCPT ); Fri, 20 May 2022 12:58:18 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78A717CC8F for ; Fri, 20 May 2022 09:58:16 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id s5x6nCvSAWo1ms5x6nwSpM; Fri, 20 May 2022 18:58:15 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 20 May 2022 18:58:15 +0200 X-ME-IP: 86.243.180.246 Message-ID: Date: Fri, 20 May 2022 18:58:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v3 2/6] mm: shrinkers: introduce debugfs interface for memory shrinkers Content-Language: fr To: Roman Gushchin , Andrew Morton , linux-mm@kvack.org Cc: Dave Chinner , linux-kernel@vger.kernel.org, Kent Overstreet , Hillf Danton References: <20220509183820.573666-1-roman.gushchin@linux.dev> <20220509183820.573666-3-roman.gushchin@linux.dev> From: Christophe JAILLET In-Reply-To: <20220509183820.573666-3-roman.gushchin@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 09/05/2022 à 20:38, Roman Gushchin a écrit : > This commit introduces the /sys/kernel/debug/shrinker debugfs > interface which provides an ability to observe the state of > individual kernel memory shrinkers. > > Because the feature adds some memory overhead (which shouldn't be > large unless there is a huge amount of registered shrinkers), it's > guarded by a config option (enabled by default). > > This commit introduces the "count" interface for each shrinker > registered in the system. > > The output is in the following format: > ... > ... > ... > > To reduce the size of output on machines with many thousands cgroups, > if the total number of objects on all nodes is 0, the line is omitted. > > If the shrinker is not memcg-aware or CONFIG_MEMCG is off, 0 is > printed as cgroup inode id. If the shrinker is not numa-aware, 0's are > printed for all nodes except the first one. > > This commit gives debugfs entries simple numeric names, which are not > very convenient. The following commit in the series will provide > shrinkers with more meaningful names. > > Signed-off-by: Roman Gushchin > --- > include/linux/shrinker.h | 19 ++++- > lib/Kconfig.debug | 9 +++ > mm/Makefile | 1 + > mm/shrinker_debug.c | 171 +++++++++++++++++++++++++++++++++++++++ > mm/vmscan.c | 6 +- > 5 files changed, 203 insertions(+), 3 deletions(-) > create mode 100644 mm/shrinker_debug.c > > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h > index 76fbf92b04d9..2ced8149c513 100644 > --- a/include/linux/shrinker.h > +++ b/include/linux/shrinker.h > @@ -72,6 +72,10 @@ struct shrinker { > #ifdef CONFIG_MEMCG > /* ID in shrinker_idr */ > int id; > +#endif > +#ifdef CONFIG_SHRINKER_DEBUG > + int debugfs_id; > + struct dentry *debugfs_entry; > #endif > /* objs pending delete, per node */ > atomic_long_t *nr_deferred; > @@ -94,4 +98,17 @@ extern int register_shrinker(struct shrinker *shrinker); > extern void unregister_shrinker(struct shrinker *shrinker); > extern void free_prealloced_shrinker(struct shrinker *shrinker); > extern void synchronize_shrinkers(void); > -#endif > + > +#ifdef CONFIG_SHRINKER_DEBUG > +extern int shrinker_debugfs_add(struct shrinker *shrinker); > +extern void shrinker_debugfs_remove(struct shrinker *shrinker); > +#else /* CONFIG_SHRINKER_DEBUG */ > +static inline int shrinker_debugfs_add(struct shrinker *shrinker) > +{ > + return 0; > +} > +static inline void shrinker_debugfs_remove(struct shrinker *shrinker) > +{ > +} > +#endif /* CONFIG_SHRINKER_DEBUG */ > +#endif /* _LINUX_SHRINKER_H */ > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index 3fd7a2e9eaf1..5fa65a649798 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -733,6 +733,15 @@ config SLUB_STATS > out which slabs are relevant to a particular load. > Try running: slabinfo -DA > > +config SHRINKER_DEBUG > + default y The previous version of the serie had default 'n'. Is it intentional to have it now activated by default? It looked more like a tuning functionality when fine grained mangement of shrinker is needed. > + bool "Enable shrinker debugging support" > + depends on DEBUG_FS > + help > + Say Y to enable the shrinker debugfs interface which provides > + visibility into the kernel memory shrinkers subsystem. > + Disable it to avoid an extra memory footprint. > + [...]