All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table()
@ 2023-03-02 20:46 Luis Chamberlain
  2023-03-02 20:46 ` [PATCH 1/7] scsi: simplify sysctl registration with register_sysctl() Luis Chamberlain
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

As the large array of sysctls in kernel/sysctl.c is reduced we get to
the point of wanting to optimize how we register sysctls by only dealing
with flat simple structures, with no subdirectories. In particular the
last empty element should not be needed. We'll get there, and save some
memory, but as we move forward that path will be come the more relevant
path to use in the sysctl registration. It is much simpler as it avoids
recursion.

Turns out we can also convert existing users of register_sysctl_table()
which just need their subdirectories created for them. This effort
addresses most users of register_sysctl_table() in drivers/ except
parport -- that needs a bit more review.

This is part of the process to deprecate older sysctl users which uses
APIs which can incur recursion, but don't need it [0]. This is the
second effort.

Yes -- we'll get to the point *each* of these conversions means saving
one empty syctl, but that change needs a bit more careful review before
merging. But since these conversion are also deleting tables for
subdirectories, the delta in size of the kernel should not incrase
really.

The most complex change is the sgi-xp change which does deal with
a case where we have a subdirectory with an entry, I just split
that in two registrations. No point in keeping recursion just for
a few minor if we can simplify code around. More eyeballs / review /
testing on that change is appreciated.

Sending these out early so they can get tested properly early on
linux-next. I'm happy to take these via sysctl-next [0] but since
I don' think register_sysctl_table() will be nuked on v6.4 I think
it's fine for each of these to go into each respective tree. I can
pick up last stragglers on sysctl-next. If you want me to take this
via sysctl-next too, just let me know and I'm happy to do that. Either
way works.

[0] https://lkml.kernel.org/r/20230302202826.776286-1-mcgrof@kernel.org

Luis Chamberlain (7):
  scsi: simplify sysctl registration with register_sysctl()
  ipmi: simplify sysctl registration
  hv: simplify sysctl registration
  md: simplify sysctl registration
  sgi-xp: simplify sysctl registration
  tty: simplify sysctl registration
  xen: simplify sysctl registration for balloon

 drivers/char/ipmi/ipmi_poweroff.c | 16 +---------------
 drivers/hv/vmbus_drv.c            | 11 +----------
 drivers/md/md.c                   | 22 +---------------------
 drivers/misc/sgi-xp/xpc_main.c    | 24 ++++++++++--------------
 drivers/scsi/scsi_sysctl.c        | 16 +---------------
 drivers/tty/tty_io.c              | 20 +-------------------
 drivers/xen/balloon.c             | 20 +-------------------
 7 files changed, 16 insertions(+), 113 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/7] scsi: simplify sysctl registration with register_sysctl()
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-02 20:46 ` [PATCH 2/7] ipmi: simplify sysctl registration Luis Chamberlain
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl() can do the directory creation for you so just use that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/scsi/scsi_sysctl.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_sysctl.c b/drivers/scsi/scsi_sysctl.c
index 7259704a7f52..7f0914ea168f 100644
--- a/drivers/scsi/scsi_sysctl.c
+++ b/drivers/scsi/scsi_sysctl.c
@@ -21,25 +21,11 @@ static struct ctl_table scsi_table[] = {
 	{ }
 };
 
-static struct ctl_table scsi_dir_table[] = {
-	{ .procname	= "scsi",
-	  .mode		= 0555,
-	  .child	= scsi_table },
-	{ }
-};
-
-static struct ctl_table scsi_root_table[] = {
-	{ .procname	= "dev",
-	  .mode		= 0555,
-	  .child	= scsi_dir_table },
-	{ }
-};
-
 static struct ctl_table_header *scsi_table_header;
 
 int __init scsi_init_sysctl(void)
 {
-	scsi_table_header = register_sysctl_table(scsi_root_table);
+	scsi_table_header = register_sysctl("dev/scsi", scsi_table);
 	if (!scsi_table_header)
 		return -ENOMEM;
 	return 0;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/7] ipmi: simplify sysctl registration
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
  2023-03-02 20:46 ` [PATCH 1/7] scsi: simplify sysctl registration with register_sysctl() Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-02 22:17   ` Corey Minyard
  2023-03-02 20:46 ` [PATCH 3/7] hv: " Luis Chamberlain
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl() can do the directory creation for you so just use
that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/char/ipmi/ipmi_poweroff.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 163ec9749e55..870659d91db2 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -659,20 +659,6 @@ static struct ctl_table ipmi_table[] = {
 	{ }
 };
 
-static struct ctl_table ipmi_dir_table[] = {
-	{ .procname	= "ipmi",
-	  .mode		= 0555,
-	  .child	= ipmi_table },
-	{ }
-};
-
-static struct ctl_table ipmi_root_table[] = {
-	{ .procname	= "dev",
-	  .mode		= 0555,
-	  .child	= ipmi_dir_table },
-	{ }
-};
-
 static struct ctl_table_header *ipmi_table_header;
 #endif /* CONFIG_PROC_FS */
 
@@ -689,7 +675,7 @@ static int __init ipmi_poweroff_init(void)
 		pr_info("Power cycle is enabled\n");
 
 #ifdef CONFIG_PROC_FS
-	ipmi_table_header = register_sysctl_table(ipmi_root_table);
+	ipmi_table_header = register_sysctl("dev/ipmi", ipmi_table);
 	if (!ipmi_table_header) {
 		pr_err("Unable to register powercycle sysctl\n");
 		rv = -ENOMEM;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/7] hv: simplify sysctl registration
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
  2023-03-02 20:46 ` [PATCH 1/7] scsi: simplify sysctl registration with register_sysctl() Luis Chamberlain
  2023-03-02 20:46 ` [PATCH 2/7] ipmi: simplify sysctl registration Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-03  0:59   ` Michael Kelley (LINUX)
  2023-03-06 15:27   ` Wei Liu
  2023-03-02 20:46 ` [PATCH 4/7] md: " Luis Chamberlain
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl() can do the directory creation for you so just use
that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/hv/vmbus_drv.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index d24dd65b33d4..229353f1e9c2 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1460,15 +1460,6 @@ static struct ctl_table hv_ctl_table[] = {
 	{}
 };
 
-static struct ctl_table hv_root_table[] = {
-	{
-		.procname	= "kernel",
-		.mode		= 0555,
-		.child		= hv_ctl_table
-	},
-	{}
-};
-
 /*
  * vmbus_bus_init -Main vmbus driver initialization routine.
  *
@@ -1547,7 +1538,7 @@ static int vmbus_bus_init(void)
 		 * message recording won't be available in isolated
 		 * guests should the following registration fail.
 		 */
-		hv_ctl_table_hdr = register_sysctl_table(hv_root_table);
+		hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table);
 		if (!hv_ctl_table_hdr)
 			pr_err("Hyper-V: sysctl table register error");
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/7] md: simplify sysctl registration
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
                   ` (2 preceding siblings ...)
  2023-03-02 20:46 ` [PATCH 3/7] hv: " Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-03 18:16   ` Song Liu
  2023-03-02 20:46 ` [PATCH 5/7] sgi-xp: " Luis Chamberlain
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl() can do the directory creation for you so just use
that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/md/md.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 927a43db5dfb..546b1b81eb28 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -322,26 +322,6 @@ static struct ctl_table raid_table[] = {
 	{ }
 };
 
-static struct ctl_table raid_dir_table[] = {
-	{
-		.procname	= "raid",
-		.maxlen		= 0,
-		.mode		= S_IRUGO|S_IXUGO,
-		.child		= raid_table,
-	},
-	{ }
-};
-
-static struct ctl_table raid_root_table[] = {
-	{
-		.procname	= "dev",
-		.maxlen		= 0,
-		.mode		= 0555,
-		.child		= raid_dir_table,
-	},
-	{  }
-};
-
 static int start_readonly;
 
 /*
@@ -9650,7 +9630,7 @@ static int __init md_init(void)
 	mdp_major = ret;
 
 	register_reboot_notifier(&md_notifier);
-	raid_table_header = register_sysctl_table(raid_root_table);
+	raid_table_header = register_sysctl("dev/raid", raid_table);
 
 	md_geninit();
 	return 0;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/7] sgi-xp: simplify sysctl registration
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
                   ` (3 preceding siblings ...)
  2023-03-02 20:46 ` [PATCH 4/7] md: " Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-07 22:24   ` Steve Wahl
  2023-03-02 20:46 ` [PATCH 6/7] tty: " Luis Chamberlain
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

Although this driver is a good use case for having a directory
that is not other directories and then subdirectories with more
entries, the usage of register_sysctl_table() can recurse and
increases complexity so to avoid that just split out the
registration to each directory with its own entries.

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl() can do the directory creation for you so just use
that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/misc/sgi-xp/xpc_main.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index b2c3c22fc13c..6da509d692bb 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -93,7 +93,7 @@ int xpc_disengage_timelimit = XPC_DISENGAGE_DEFAULT_TIMELIMIT;
 static int xpc_disengage_min_timelimit;	/* = 0 */
 static int xpc_disengage_max_timelimit = 120;
 
-static struct ctl_table xpc_sys_xpc_hb_dir[] = {
+static struct ctl_table xpc_sys_xpc_hb[] = {
 	{
 	 .procname = "hb_interval",
 	 .data = &xpc_hb_interval,
@@ -112,11 +112,7 @@ static struct ctl_table xpc_sys_xpc_hb_dir[] = {
 	 .extra2 = &xpc_hb_check_max_interval},
 	{}
 };
-static struct ctl_table xpc_sys_xpc_dir[] = {
-	{
-	 .procname = "hb",
-	 .mode = 0555,
-	 .child = xpc_sys_xpc_hb_dir},
+static struct ctl_table xpc_sys_xpc[] = {
 	{
 	 .procname = "disengage_timelimit",
 	 .data = &xpc_disengage_timelimit,
@@ -127,14 +123,9 @@ static struct ctl_table xpc_sys_xpc_dir[] = {
 	 .extra2 = &xpc_disengage_max_timelimit},
 	{}
 };
-static struct ctl_table xpc_sys_dir[] = {
-	{
-	 .procname = "xpc",
-	 .mode = 0555,
-	 .child = xpc_sys_xpc_dir},
-	{}
-};
+
 static struct ctl_table_header *xpc_sysctl;
+static struct ctl_table_header *xpc_sysctl_hb;
 
 /* non-zero if any remote partition disengage was timed out */
 int xpc_disengage_timedout;
@@ -1041,6 +1032,8 @@ xpc_do_exit(enum xp_retval reason)
 
 	if (xpc_sysctl)
 		unregister_sysctl_table(xpc_sysctl);
+	if (xpc_sysctl_hb)
+		unregister_sysctl_table(xpc_sysctl_hb);
 
 	xpc_teardown_partitions();
 
@@ -1243,7 +1236,8 @@ xpc_init(void)
 		goto out_1;
 	}
 
-	xpc_sysctl = register_sysctl_table(xpc_sys_dir);
+	xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc);
+	xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb);
 
 	/*
 	 * Fill the partition reserved page with the information needed by
@@ -1308,6 +1302,8 @@ xpc_init(void)
 	(void)unregister_die_notifier(&xpc_die_notifier);
 	(void)unregister_reboot_notifier(&xpc_reboot_notifier);
 out_2:
+	if (xpc_sysctl_hb)
+		unregister_sysctl_table(xpc_sysctl_hb);
 	if (xpc_sysctl)
 		unregister_sysctl_table(xpc_sysctl);
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/7] tty: simplify sysctl registration
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
                   ` (4 preceding siblings ...)
  2023-03-02 20:46 ` [PATCH 5/7] sgi-xp: " Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-02 20:46 ` [PATCH 7/7] xen: simplify sysctl registration for balloon Luis Chamberlain
  2023-03-09 22:18 ` [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
  7 siblings, 0 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl_init() can do the directory creation for you so just use
that

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/tty/tty_io.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 36fb945fdad4..766750e355ac 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3614,31 +3614,13 @@ static struct ctl_table tty_table[] = {
 	{ }
 };
 
-static struct ctl_table tty_dir_table[] = {
-	{
-		.procname	= "tty",
-		.mode		= 0555,
-		.child		= tty_table,
-	},
-	{ }
-};
-
-static struct ctl_table tty_root_table[] = {
-	{
-		.procname	= "dev",
-		.mode		= 0555,
-		.child		= tty_dir_table,
-	},
-	{ }
-};
-
 /*
  * Ok, now we can initialize the rest of the tty devices and can count
  * on memory allocations, interrupts etc..
  */
 int __init tty_init(void)
 {
-	register_sysctl_table(tty_root_table);
+	register_sysctl_init("dev/tty", tty_table);
 	cdev_init(&tty_cdev, &tty_fops);
 	if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
 	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/7] xen: simplify sysctl registration for balloon
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
                   ` (5 preceding siblings ...)
  2023-03-02 20:46 ` [PATCH 6/7] tty: " Luis Chamberlain
@ 2023-03-02 20:46 ` Luis Chamberlain
  2023-03-06  8:10   ` Juergen Gross
  2023-03-09 22:18 ` [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
  7 siblings, 1 reply; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-02 20:46 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel, Luis Chamberlain

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl_init() can do the directory creation for you so just
use that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/xen/balloon.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 617a7f4f07a8..586a1673459e 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -97,24 +97,6 @@ static struct ctl_table balloon_table[] = {
 	{ }
 };
 
-static struct ctl_table balloon_root[] = {
-	{
-		.procname	= "balloon",
-		.mode		= 0555,
-		.child		= balloon_table,
-	},
-	{ }
-};
-
-static struct ctl_table xen_root[] = {
-	{
-		.procname	= "xen",
-		.mode		= 0555,
-		.child		= balloon_root,
-	},
-	{ }
-};
-
 #else
 #define xen_hotplug_unpopulated 0
 #endif
@@ -747,7 +729,7 @@ static int __init balloon_init(void)
 #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
 	set_online_page_callback(&xen_online_page);
 	register_memory_notifier(&xen_memory_nb);
-	register_sysctl_table(xen_root);
+	register_sysctl_init("xen/balloon", balloon_table);
 #endif
 
 	balloon_add_regions();
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/7] ipmi: simplify sysctl registration
  2023-03-02 20:46 ` [PATCH 2/7] ipmi: simplify sysctl registration Luis Chamberlain
@ 2023-03-02 22:17   ` Corey Minyard
  0 siblings, 0 replies; 15+ messages in thread
From: Corey Minyard @ 2023-03-02 22:17 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: ebiederm, keescook, yzaikin, jejb, martin.petersen, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel, j.granados, zhangpeng362,
	tangmeng, willy, nixiaoming, sujiaxun, patches, linux-fsdevel,
	apparmor, linux-raid, linux-scsi, linux-hyperv,
	openipmi-developer, linux-kernel

On Thu, Mar 02, 2023 at 12:46:07PM -0800, Luis Chamberlain wrote:
> register_sysctl_table() is a deprecated compatibility wrapper.
> register_sysctl() can do the directory creation for you so just use
> that.

Thanks, I have included this in my tree for the next merge window.

-corey

> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  drivers/char/ipmi/ipmi_poweroff.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
> index 163ec9749e55..870659d91db2 100644
> --- a/drivers/char/ipmi/ipmi_poweroff.c
> +++ b/drivers/char/ipmi/ipmi_poweroff.c
> @@ -659,20 +659,6 @@ static struct ctl_table ipmi_table[] = {
>  	{ }
>  };
>  
> -static struct ctl_table ipmi_dir_table[] = {
> -	{ .procname	= "ipmi",
> -	  .mode		= 0555,
> -	  .child	= ipmi_table },
> -	{ }
> -};
> -
> -static struct ctl_table ipmi_root_table[] = {
> -	{ .procname	= "dev",
> -	  .mode		= 0555,
> -	  .child	= ipmi_dir_table },
> -	{ }
> -};
> -
>  static struct ctl_table_header *ipmi_table_header;
>  #endif /* CONFIG_PROC_FS */
>  
> @@ -689,7 +675,7 @@ static int __init ipmi_poweroff_init(void)
>  		pr_info("Power cycle is enabled\n");
>  
>  #ifdef CONFIG_PROC_FS
> -	ipmi_table_header = register_sysctl_table(ipmi_root_table);
> +	ipmi_table_header = register_sysctl("dev/ipmi", ipmi_table);
>  	if (!ipmi_table_header) {
>  		pr_err("Unable to register powercycle sysctl\n");
>  		rv = -ENOMEM;
> -- 
> 2.39.1
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 3/7] hv: simplify sysctl registration
  2023-03-02 20:46 ` [PATCH 3/7] hv: " Luis Chamberlain
@ 2023-03-03  0:59   ` Michael Kelley (LINUX)
  2023-03-06 15:27   ` Wei Liu
  1 sibling, 0 replies; 15+ messages in thread
From: Michael Kelley (LINUX) @ 2023-03-03  0:59 UTC (permalink / raw)
  To: Luis Chamberlain, ebiederm, keescook, yzaikin, jejb,
	martin.petersen, minyard, KY Srinivasan, Haiyang Zhang, wei.liu,
	Dexuan Cui, song, robinmholt, steve.wahl, mike.travis, arnd,
	gregkh, jirislaby, jgross, sstabellini, oleksandr_tyshchenko,
	xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel

From: Luis Chamberlain <mcgrof@infradead.org> On Behalf Of Luis Chamberlain Sent: Thursday, March 2, 2023 12:46 PM
>
> register_sysctl_table() is a deprecated compatibility wrapper.
> register_sysctl() can do the directory creation for you so just use
> that.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  drivers/hv/vmbus_drv.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index d24dd65b33d4..229353f1e9c2 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1460,15 +1460,6 @@ static struct ctl_table hv_ctl_table[] = {
>  	{}
>  };
> 
> -static struct ctl_table hv_root_table[] = {
> -	{
> -		.procname	= "kernel",
> -		.mode		= 0555,
> -		.child		= hv_ctl_table
> -	},
> -	{}
> -};
> -
>  /*
>   * vmbus_bus_init -Main vmbus driver initialization routine.
>   *
> @@ -1547,7 +1538,7 @@ static int vmbus_bus_init(void)
>  		 * message recording won't be available in isolated
>  		 * guests should the following registration fail.
>  		 */
> -		hv_ctl_table_hdr = register_sysctl_table(hv_root_table);
> +		hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table);
>  		if (!hv_ctl_table_hdr)
>  			pr_err("Hyper-V: sysctl table register error");
> 
> --
> 2.39.1

Reviewed-by: Michael Kelley <mikelley@microsoft.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/7] md: simplify sysctl registration
  2023-03-02 20:46 ` [PATCH 4/7] md: " Luis Chamberlain
@ 2023-03-03 18:16   ` Song Liu
  0 siblings, 0 replies; 15+ messages in thread
From: Song Liu @ 2023-03-03 18:16 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, robinmholt, steve.wahl, mike.travis,
	arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel, j.granados, zhangpeng362,
	tangmeng, willy, nixiaoming, sujiaxun, patches, linux-fsdevel,
	apparmor, linux-raid, linux-scsi, linux-hyperv,
	openipmi-developer, linux-kernel

On Thu, Mar 2, 2023 at 12:46 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> register_sysctl_table() is a deprecated compatibility wrapper.
> register_sysctl() can do the directory creation for you so just use
> that.
>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Acked-by: Song Liu <song@kernel.org>

Thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] xen: simplify sysctl registration for balloon
  2023-03-02 20:46 ` [PATCH 7/7] xen: simplify sysctl registration for balloon Luis Chamberlain
@ 2023-03-06  8:10   ` Juergen Gross
  0 siblings, 0 replies; 15+ messages in thread
From: Juergen Gross @ 2023-03-06  8:10 UTC (permalink / raw)
  To: Luis Chamberlain, ebiederm, keescook, yzaikin, jejb,
	martin.petersen, minyard, kys, haiyangz, wei.liu, decui, song,
	robinmholt, steve.wahl, mike.travis, arnd, gregkh, jirislaby,
	sstabellini, oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 317 bytes --]

On 02.03.23 21:46, Luis Chamberlain wrote:
> register_sysctl_table() is a deprecated compatibility wrapper.
> register_sysctl_init() can do the directory creation for you so just
> use that.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/7] hv: simplify sysctl registration
  2023-03-02 20:46 ` [PATCH 3/7] hv: " Luis Chamberlain
  2023-03-03  0:59   ` Michael Kelley (LINUX)
@ 2023-03-06 15:27   ` Wei Liu
  1 sibling, 0 replies; 15+ messages in thread
From: Wei Liu @ 2023-03-06 15:27 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel, j.granados, zhangpeng362,
	tangmeng, willy, nixiaoming, sujiaxun, patches, linux-fsdevel,
	apparmor, linux-raid, linux-scsi, linux-hyperv,
	openipmi-developer, linux-kernel

On Thu, Mar 02, 2023 at 12:46:08PM -0800, Luis Chamberlain wrote:
> register_sysctl_table() is a deprecated compatibility wrapper.
> register_sysctl() can do the directory creation for you so just use
> that.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Reviewed-by: Wei Liu <wei.liu@kernel.org>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/7] sgi-xp: simplify sysctl registration
  2023-03-02 20:46 ` [PATCH 5/7] sgi-xp: " Luis Chamberlain
@ 2023-03-07 22:24   ` Steve Wahl
  0 siblings, 0 replies; 15+ messages in thread
From: Steve Wahl @ 2023-03-07 22:24 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl, arnd,
	gregkh, jirislaby, jgross, sstabellini, oleksandr_tyshchenko,
	xen-devel, j.granados, zhangpeng362, tangmeng, willy, nixiaoming,
	sujiaxun, patches, linux-fsdevel, apparmor, linux-raid,
	linux-scsi, linux-hyperv, openipmi-developer, linux-kernel

On Thu, Mar 02, 2023 at 12:46:10PM -0800, Luis Chamberlain wrote:
> Although this driver is a good use case for having a directory
> that is not other directories and then subdirectories with more
> entries, the usage of register_sysctl_table() can recurse and
> increases complexity so to avoid that just split out the
> registration to each directory with its own entries.
> 
> register_sysctl_table() is a deprecated compatibility wrapper.
> register_sysctl() can do the directory creation for you so just use
> that.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Reviewed-by: Steve Wahl <steve.wahl@hpe.com>

> ---
>  drivers/misc/sgi-xp/xpc_main.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
> index b2c3c22fc13c..6da509d692bb 100644
> --- a/drivers/misc/sgi-xp/xpc_main.c
> +++ b/drivers/misc/sgi-xp/xpc_main.c
> @@ -93,7 +93,7 @@ int xpc_disengage_timelimit = XPC_DISENGAGE_DEFAULT_TIMELIMIT;
>  static int xpc_disengage_min_timelimit;	/* = 0 */
>  static int xpc_disengage_max_timelimit = 120;
>  
> -static struct ctl_table xpc_sys_xpc_hb_dir[] = {
> +static struct ctl_table xpc_sys_xpc_hb[] = {
>  	{
>  	 .procname = "hb_interval",
>  	 .data = &xpc_hb_interval,
> @@ -112,11 +112,7 @@ static struct ctl_table xpc_sys_xpc_hb_dir[] = {
>  	 .extra2 = &xpc_hb_check_max_interval},
>  	{}
>  };
> -static struct ctl_table xpc_sys_xpc_dir[] = {
> -	{
> -	 .procname = "hb",
> -	 .mode = 0555,
> -	 .child = xpc_sys_xpc_hb_dir},
> +static struct ctl_table xpc_sys_xpc[] = {
>  	{
>  	 .procname = "disengage_timelimit",
>  	 .data = &xpc_disengage_timelimit,
> @@ -127,14 +123,9 @@ static struct ctl_table xpc_sys_xpc_dir[] = {
>  	 .extra2 = &xpc_disengage_max_timelimit},
>  	{}
>  };
> -static struct ctl_table xpc_sys_dir[] = {
> -	{
> -	 .procname = "xpc",
> -	 .mode = 0555,
> -	 .child = xpc_sys_xpc_dir},
> -	{}
> -};
> +
>  static struct ctl_table_header *xpc_sysctl;
> +static struct ctl_table_header *xpc_sysctl_hb;
>  
>  /* non-zero if any remote partition disengage was timed out */
>  int xpc_disengage_timedout;
> @@ -1041,6 +1032,8 @@ xpc_do_exit(enum xp_retval reason)
>  
>  	if (xpc_sysctl)
>  		unregister_sysctl_table(xpc_sysctl);
> +	if (xpc_sysctl_hb)
> +		unregister_sysctl_table(xpc_sysctl_hb);
>  
>  	xpc_teardown_partitions();
>  
> @@ -1243,7 +1236,8 @@ xpc_init(void)
>  		goto out_1;
>  	}
>  
> -	xpc_sysctl = register_sysctl_table(xpc_sys_dir);
> +	xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc);
> +	xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb);
>  
>  	/*
>  	 * Fill the partition reserved page with the information needed by
> @@ -1308,6 +1302,8 @@ xpc_init(void)
>  	(void)unregister_die_notifier(&xpc_die_notifier);
>  	(void)unregister_reboot_notifier(&xpc_reboot_notifier);
>  out_2:
> +	if (xpc_sysctl_hb)
> +		unregister_sysctl_table(xpc_sysctl_hb);
>  	if (xpc_sysctl)
>  		unregister_sysctl_table(xpc_sysctl);
>  
> -- 
> 2.39.1
> 

-- 
Steve Wahl, Hewlett Packard Enterprise

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table()
  2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
                   ` (6 preceding siblings ...)
  2023-03-02 20:46 ` [PATCH 7/7] xen: simplify sysctl registration for balloon Luis Chamberlain
@ 2023-03-09 22:18 ` Luis Chamberlain
  7 siblings, 0 replies; 15+ messages in thread
From: Luis Chamberlain @ 2023-03-09 22:18 UTC (permalink / raw)
  To: ebiederm, keescook, yzaikin, jejb, martin.petersen, minyard, kys,
	haiyangz, wei.liu, decui, song, robinmholt, steve.wahl,
	mike.travis, arnd, gregkh, jirislaby, jgross, sstabellini,
	oleksandr_tyshchenko, xen-devel
  Cc: j.granados, zhangpeng362, tangmeng, willy, nixiaoming, sujiaxun,
	patches, linux-fsdevel, apparmor, linux-raid, linux-scsi,
	linux-hyperv, openipmi-developer, linux-kernel

On Thu, Mar 02, 2023 at 12:46:05PM -0800, Luis Chamberlain wrote:
> I'm happy to take these via sysctl-next [0] but since
> I don' think register_sysctl_table() will be nuked on v6.4 I think
> it's fine for each of these to go into each respective tree. I can
> pick up last stragglers on sysctl-next. If you want me to take this
> via sysctl-next too, just let me know and I'm happy to do that. Either
> way works.

As I noted I've dropped the following already-picked-up patches from
my queue:

ipmi: simplify sysctl registration
sgi-xp: simplify sysctl registration
tty: simplify sysctl registration

I've taken the rest now through sysctl-next:

scsi: simplify sysctl registration with register_sysctl()
hv: simplify sysctl registration
md: simplify sysctl registration
xen: simplify sysctl registration for balloon

If a maintainer would prefer to take one on through their
tree fine by me too, just let me know and I'll drop the patch.

  Luis

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-03-09 22:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
2023-03-02 20:46 ` [PATCH 1/7] scsi: simplify sysctl registration with register_sysctl() Luis Chamberlain
2023-03-02 20:46 ` [PATCH 2/7] ipmi: simplify sysctl registration Luis Chamberlain
2023-03-02 22:17   ` Corey Minyard
2023-03-02 20:46 ` [PATCH 3/7] hv: " Luis Chamberlain
2023-03-03  0:59   ` Michael Kelley (LINUX)
2023-03-06 15:27   ` Wei Liu
2023-03-02 20:46 ` [PATCH 4/7] md: " Luis Chamberlain
2023-03-03 18:16   ` Song Liu
2023-03-02 20:46 ` [PATCH 5/7] sgi-xp: " Luis Chamberlain
2023-03-07 22:24   ` Steve Wahl
2023-03-02 20:46 ` [PATCH 6/7] tty: " Luis Chamberlain
2023-03-02 20:46 ` [PATCH 7/7] xen: simplify sysctl registration for balloon Luis Chamberlain
2023-03-06  8:10   ` Juergen Gross
2023-03-09 22:18 ` [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.