Message ID | 20230526222207.982107-2-mcgrof@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3274vqr; Fri, 26 May 2023 15:50:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tH1LbczlyC3RiKNB+QQGSVEefh4ES8MciJn2TjUwFyHaGuy7VcikB71xwX9AyVJmXdD+M X-Received: by 2002:a17:902:8c92:b0:1b0:2390:3674 with SMTP id t18-20020a1709028c9200b001b023903674mr1099774plo.65.1685141431355; Fri, 26 May 2023 15:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685141431; cv=none; d=google.com; s=arc-20160816; b=WpsGqQTiAN2y5X4MNQNZHkGRtui8jglgvXW8BHqbZpf6o6NLbDQ/ZVBeA/27ERQmaF TFF1768XW1yIiwO7qh4TzMBs5YZyNzGtBjwkP25nf5y5pqes5oRt4oFlyvNi/xd0IiP4 zfd31NQ4tS9wXDcKTTxBEZOiBGTvrrH3oEOton2aldT6hQyd2AkJDAiE7PHXo2ylwM52 Wbk+JYW5CXN0W7Kurx8Syzu+9Ain1P0F8ksCg65+mWRgAew1cJKfE4poTc0tQlq+q+Lb VScc2ucc4JR1Xkx9zYjJoKqKE0VMQFR86dUg45WGRIvWFEAUOHJUm65eGh6qyUnKRZG/ mJPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SHkCwnoLOgnVuVhD20vulZh61NLbbufsccKwdmPmKe0=; b=Mre3tisd3OBEe65Gy+ToIpPnhyiKfibpyC60TgsdB0wRTAi5jDAKKKOxbUtgf+2qyz m1D7VEMgjzYzP74elgjEkK/HGD1y4ul4EhY0HXCFiHxOXrbt/ZGgeqJP526KiGMhjNAc M17YxwKWONTNQ1KmHKfXidtdvvi82QUE7E+mRKzmI1b04+BxYXGUYfAUexA+TF1AZQn5 iiONaGaf1ONHL0FsT1iLgfaDnTTYgP+8pPPx5XtdyGqTgeECjb14qjACoDz7bZ6h37oU 59Yu7ULIyjom4UIND/Q8a1juCpXNZ4OhvKxQVGEBW4eVU3CYR/ZdLKHkdi/Pl0X7Kg6U iJlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ZVTTDYMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a1709029a0a00b001ab1411f3e6si4719863plp.260.2023.05.26.15.50.19; Fri, 26 May 2023 15:50:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ZVTTDYMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244282AbjEZWWz (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Fri, 26 May 2023 18:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242588AbjEZWWr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 26 May 2023 18:22:47 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFC2A9E; Fri, 26 May 2023 15:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=SHkCwnoLOgnVuVhD20vulZh61NLbbufsccKwdmPmKe0=; b=ZVTTDYMv5DZ18vLNN631PL2Hc6 RBK1fTpo0SJpvaC1HRR8H4tMN8NeRw61Xg6HzrcddCkECaU7Uzynq+MtPhsZ6zYbf9C+Sm2I/dlYg ODiS2hgc/KY16lhXZ+CsGTLXdz/n+YxrPqDMrp7CYbEW7vf1rfuIMjWV2OVVTMxvOEpDxVTYIA3HI jVq3ueGqNi3pamCmyKNGVHBoT/cIZhSQojGFK7HJwj12bmEl4mK2r9iryVC4W3hxPsldLvYnKf46j CKCyRXTjtFN1FOZOEzFMjY2PScnhTaSIq05z3QbDhemyQ8HDAvaxtS+NL9rk9gRQVkAmm4VP41MhK U3dV7iUg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q2fp1-0047Uk-2H; Fri, 26 May 2023 22:22:07 +0000 From: Luis Chamberlain <mcgrof@kernel.org> To: keescook@chromium.org, yzaikin@google.com, ebiederm@xmission.com, dave.hansen@intel.com, arnd@arndb.de, bp@alien8.de, James.Bottomley@HansenPartnership.com, deller@gmx.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, peterz@infradead.org, brgerst@gmail.com, christophe.jaillet@wanadoo.fr, kirill.shutemov@linux.intel.com, jroedel@suse.de Cc: j.granados@samsung.com, akpm@linux-foundation.org, willy@infradead.org, linux-parisc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain <mcgrof@kernel.org> Subject: [PATCH v2 1/2] sysctl: remove empty dev table Date: Fri, 26 May 2023 15:22:05 -0700 Message-Id: <20230526222207.982107-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230526222207.982107-1-mcgrof@kernel.org> References: <20230526222207.982107-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain <mcgrof@infradead.org> X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766998861877102299?= X-GMAIL-MSGID: =?utf-8?q?1766998861877102299?= |
Series |
kernel/sysctl.c: remove to major base directories
|
|
Commit Message
Luis Chamberlain
May 26, 2023, 10:22 p.m. UTC
Now that all the dev sysctls have been moved out we can remove the
dev sysctl base directory. We don't need to create base directories,
they are created for you as if using 'mkdir -p' with register_syctl()
and register_sysctl_init(). For details refer to sysctl_mkdir_p()
usage.
We save 90 bytes with this changes:
./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table
add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90)
Function old new delta
sysctl_init_bases 111 85 -26
dev_table 64 - -64
Total: Before=21257057, After=21256967, chg -0.00%
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
kernel/sysctl.c | 5 -----
1 file changed, 5 deletions(-)
Comments
On Fri, May 26, 2023 at 03:22:05PM -0700, Luis Chamberlain wrote: > Now that all the dev sysctls have been moved out we can remove the > dev sysctl base directory. We don't need to create base directories, > they are created for you as if using 'mkdir -p' with register_syctl() > and register_sysctl_init(). For details refer to sysctl_mkdir_p() > usage. > > We save 90 bytes with this changes: > > ./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table > add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90) > Function old new delta > sysctl_init_bases 111 85 -26 > dev_table 64 - -64 > Total: Before=21257057, After=21256967, chg -0.00% > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > --- > kernel/sysctl.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index fa2aa8bd32b6..a7fdb828afb6 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { > { } > }; > > -static struct ctl_table dev_table[] = { > - { } > -}; > - > int __init sysctl_init_bases(void) > { > register_sysctl_init("kernel", kern_table); > register_sysctl_init("vm", vm_table); > register_sysctl_init("debug", debug_table); > - register_sysctl_init("dev", dev_table); > > return 0; > } > -- > 2.39.2 > LGTM. Review But why was dev there to begin with? Best
On Mon, May 29, 2023 at 10:04:57PM +0200, Joel Granados wrote: > On Fri, May 26, 2023 at 03:22:05PM -0700, Luis Chamberlain wrote: > > Now that all the dev sysctls have been moved out we can remove the > > dev sysctl base directory. We don't need to create base directories, > > they are created for you as if using 'mkdir -p' with register_syctl() > > and register_sysctl_init(). For details refer to sysctl_mkdir_p() > > usage. > > > > We save 90 bytes with this changes: > > > > ./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table > > add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90) > > Function old new delta > > sysctl_init_bases 111 85 -26 > > dev_table 64 - -64 > > Total: Before=21257057, After=21256967, chg -0.00% > > > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > > --- > > kernel/sysctl.c | 5 ----- > > 1 file changed, 5 deletions(-) > > > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > > index fa2aa8bd32b6..a7fdb828afb6 100644 > > --- a/kernel/sysctl.c > > +++ b/kernel/sysctl.c > > @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { > > { } > > }; > > > > -static struct ctl_table dev_table[] = { > > - { } > > -}; > > - > > int __init sysctl_init_bases(void) > > { > > register_sysctl_init("kernel", kern_table); > > register_sysctl_init("vm", vm_table); > > register_sysctl_init("debug", debug_table); > > - register_sysctl_init("dev", dev_table); > > > > return 0; > > } > > -- > > 2.39.2 > > > LGTM. BTW, please use proper tags like Reviewed-by, and so on even if you use LGTM so that then if anyone uses things like b4 it can pick the tags for you. > But why was dev there to begin with? I will enhance the commit log to mention that, it was there because old APIs didn't create the directory for you, and now it is clear it is not needed. I checked ant he dev table was there since the beginning of sysctl.c on v2.5.0. Luis
On Tue, May 30, 2023 at 09:42:04AM -0700, Luis Chamberlain wrote: > On Mon, May 29, 2023 at 10:04:57PM +0200, Joel Granados wrote: > > On Fri, May 26, 2023 at 03:22:05PM -0700, Luis Chamberlain wrote: > > > Now that all the dev sysctls have been moved out we can remove the > > > dev sysctl base directory. We don't need to create base directories, > > > they are created for you as if using 'mkdir -p' with register_syctl() > > > and register_sysctl_init(). For details refer to sysctl_mkdir_p() > > > usage. > > > > > > We save 90 bytes with this changes: > > > > > > ./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table > > > add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90) > > > Function old new delta > > > sysctl_init_bases 111 85 -26 > > > dev_table 64 - -64 > > > Total: Before=21257057, After=21256967, chg -0.00% > > > > > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > > > --- > > > kernel/sysctl.c | 5 ----- > > > 1 file changed, 5 deletions(-) > > > > > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > > > index fa2aa8bd32b6..a7fdb828afb6 100644 > > > --- a/kernel/sysctl.c > > > +++ b/kernel/sysctl.c > > > @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { > > > { } > > > }; > > > > > > -static struct ctl_table dev_table[] = { > > > - { } > > > -}; > > > - > > > int __init sysctl_init_bases(void) > > > { > > > register_sysctl_init("kernel", kern_table); > > > register_sysctl_init("vm", vm_table); > > > register_sysctl_init("debug", debug_table); > > > - register_sysctl_init("dev", dev_table); > > > > > > return 0; > > > } > > > -- > > > 2.39.2 > > > > > LGTM. > > BTW, please use proper tags like Reviewed-by, and so on even if you use > LGTM so that then if anyone uses things like b4 it can pick the tags for > you. Sure thing. Will send the reviewed-by for the patches > > > But why was dev there to begin with? > > I will enhance the commit log to mention that, it was there because > old APIs didn't create the directory for you, and now it is clear it > is not needed. I checked ant he dev table was there since the beginning > of sysctl.c on v2.5.0. That would be great! > > Luis
On Fri, May 26, 2023 at 03:22:05PM -0700, Luis Chamberlain wrote: > Now that all the dev sysctls have been moved out we can remove the > dev sysctl base directory. We don't need to create base directories, > they are created for you as if using 'mkdir -p' with register_syctl() > and register_sysctl_init(). For details refer to sysctl_mkdir_p() > usage. > > We save 90 bytes with this changes: > > ./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table > add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90) > Function old new delta > sysctl_init_bases 111 85 -26 > dev_table 64 - -64 > Total: Before=21257057, After=21256967, chg -0.00% > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > --- > kernel/sysctl.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index fa2aa8bd32b6..a7fdb828afb6 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { > { } > }; > > -static struct ctl_table dev_table[] = { > - { } > -}; > - > int __init sysctl_init_bases(void) > { > register_sysctl_init("kernel", kern_table); > register_sysctl_init("vm", vm_table); > register_sysctl_init("debug", debug_table); > - register_sysctl_init("dev", dev_table); > > return 0; > } > -- > 2.39.2 > Reviewed-by: Joel Granados <j.granados@samsung.com>
On Tue, May 30, 2023 at 09:42:04AM -0700, Luis Chamberlain wrote: > On Mon, May 29, 2023 at 10:04:57PM +0200, Joel Granados wrote: > > On Fri, May 26, 2023 at 03:22:05PM -0700, Luis Chamberlain wrote: > > > Now that all the dev sysctls have been moved out we can remove the > > > dev sysctl base directory. We don't need to create base directories, > > > they are created for you as if using 'mkdir -p' with register_syctl() > > > and register_sysctl_init(). For details refer to sysctl_mkdir_p() > > > usage. > > > > > > We save 90 bytes with this changes: > > > > > > ./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table > > > add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90) > > > Function old new delta > > > sysctl_init_bases 111 85 -26 > > > dev_table 64 - -64 > > > Total: Before=21257057, After=21256967, chg -0.00% > > > > > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > > > --- > > > kernel/sysctl.c | 5 ----- > > > 1 file changed, 5 deletions(-) > > > > > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > > > index fa2aa8bd32b6..a7fdb828afb6 100644 > > > --- a/kernel/sysctl.c > > > +++ b/kernel/sysctl.c > > > @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { > > > { } > > > }; > > > > > > -static struct ctl_table dev_table[] = { > > > - { } > > > -}; > > > - > > > int __init sysctl_init_bases(void) > > > { > > > register_sysctl_init("kernel", kern_table); > > > register_sysctl_init("vm", vm_table); > > > register_sysctl_init("debug", debug_table); > > > - register_sysctl_init("dev", dev_table); > > > > > > return 0; > > > } > > > -- > > > 2.39.2 > > > > > LGTM. > > BTW, please use proper tags like Reviewed-by, and so on even if you use > LGTM so that then if anyone uses things like b4 it can pick the tags for > you. > > > But why was dev there to begin with? > > I will enhance the commit log to mention that, it was there because > old APIs didn't create the directory for you, and now it is clear it > is not needed. I checked ant he dev table was there since the beginning > of sysctl.c on v2.5.0. I've extended the commmit log with this very importance piece of information: The empty dev table has been in place since the v2.5.0 days because back then ordering was essentialy. But later commit 7ec66d06362d ("sysctl: Stop requiring explicit management of sysctl directories"), merged as of v3.4-rc1, the entire ordering of directories was replaced by allowing sysctl directory autogeneration. This new mechanism introduced on v3.4 allows for sysctl directories to automatically be created for sysctl tables when they are needed and automatically removes them when no sysctl tables use them. That commit also added a dedicated struct ctl_dir as a new type for these autogenerated directories. Luis
On Tue, May 30, 2023 at 03:55:10PM -0700, Luis Chamberlain wrote: > On Tue, May 30, 2023 at 09:42:04AM -0700, Luis Chamberlain wrote: > > On Mon, May 29, 2023 at 10:04:57PM +0200, Joel Granados wrote: > > > On Fri, May 26, 2023 at 03:22:05PM -0700, Luis Chamberlain wrote: > > > > Now that all the dev sysctls have been moved out we can remove the > > > > dev sysctl base directory. We don't need to create base directories, > > > > they are created for you as if using 'mkdir -p' with register_syctl() > > > > and register_sysctl_init(). For details refer to sysctl_mkdir_p() > > > > usage. > > > > > > > > We save 90 bytes with this changes: > > > > > > > > ./scripts/bloat-o-meter vmlinux.2.remove-sysctl-table vmlinux.3-remove-dev-table > > > > add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-90 (-90) > > > > Function old new delta > > > > sysctl_init_bases 111 85 -26 > > > > dev_table 64 - -64 > > > > Total: Before=21257057, After=21256967, chg -0.00% > > > > > > > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > > > > --- > > > > kernel/sysctl.c | 5 ----- > > > > 1 file changed, 5 deletions(-) > > > > > > > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > > > > index fa2aa8bd32b6..a7fdb828afb6 100644 > > > > --- a/kernel/sysctl.c > > > > +++ b/kernel/sysctl.c > > > > @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { > > > > { } > > > > }; > > > > > > > > -static struct ctl_table dev_table[] = { > > > > - { } > > > > -}; > > > > - > > > > int __init sysctl_init_bases(void) > > > > { > > > > register_sysctl_init("kernel", kern_table); > > > > register_sysctl_init("vm", vm_table); > > > > register_sysctl_init("debug", debug_table); > > > > - register_sysctl_init("dev", dev_table); > > > > > > > > return 0; > > > > } > > > > -- > > > > 2.39.2 > > > > > > > LGTM. > > > > BTW, please use proper tags like Reviewed-by, and so on even if you use > > LGTM so that then if anyone uses things like b4 it can pick the tags for > > you. > > > > > But why was dev there to begin with? > > > > I will enhance the commit log to mention that, it was there because > > old APIs didn't create the directory for you, and now it is clear it > > is not needed. I checked ant he dev table was there since the beginning > > of sysctl.c on v2.5.0. > > I've extended the commmit log with this very importance piece of > information: Awesome! > > The empty dev table has been in place since the v2.5.0 days because back > then ordering was essentialy. But later commit 7ec66d06362d ("sysctl: *essential ? > Stop requiring explicit management of sysctl directories"), merged as of > v3.4-rc1, the entire ordering of directories was replaced by allowing > sysctl directory autogeneration. This new mechanism introduced on v3.4 > allows for sysctl directories to automatically be created for sysctl > tables when they are needed and automatically removes them when no > sysctl tables use them. That commit also added a dedicated struct > ctl_dir as a new type for these autogenerated directories. > > Luis
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index fa2aa8bd32b6..a7fdb828afb6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2344,16 +2344,11 @@ static struct ctl_table debug_table[] = { { } }; -static struct ctl_table dev_table[] = { - { } -}; - int __init sysctl_init_bases(void) { register_sysctl_init("kernel", kern_table); register_sysctl_init("vm", vm_table); register_sysctl_init("debug", debug_table); - register_sysctl_init("dev", dev_table); return 0; }