2023-05-23 12:47:39

by Joel Granados

[permalink] [raw]
Subject: [PATCH v4 0/8] sysctl: Completely remove register_sysctl_table from sources

This is part of the general push to deprecate register_sysctl_paths and
register_sysctl_table. It contains 2 patchsets that were originally sent
separately. I have put them together because the second followed the first.

Parport driver uses the "CHILD" pointer in the ctl_table structure to create
its directory structure. We move to the newer register_sysctl call and remove
the pointer madness. I have separated the parport into 5 patches to clarify the
different changes needed for the 3 calls to register_sysctl_paths.

We no longer export the register_sysctl_table call as parport was the
last user from outside proc_sysctl.c. Also modified documentation slightly
so register_sysctl_table is no longer mentioned.

Replace register_sysctl_table with register_sysctl effectively effectively
transitioning 5 base paths ("kernel", "vm", "fs", "dev" and "debug") to the new
call. Besides removing the actual function, I also removed it from the checks
done in check-sysctl-docs. @mcgrof went a bit further and removed 2 more
functions.

Testing for this change was done in the same way as with previous sysctl
replacement patches: I made sure that the result of `find /proc/sys/ | sha1sum`
was the same before and after the patchset.

V4:
* (mcgrof) : use of register_sysctl_init instead of register_sysctl
* (mcgrof) : removed register_sysctl_table and __register_sysctl_base
* Added a unregister call to properly unwind things when there is an error
* Added kernel proc subdirectories "kernel/usermodehelper" and "kernel/keys"

V3:
* Added a return error value when register fails
* Made sure to free the memory on error when calling parport_proc_register
* Added a bloat-o-meter output to measure bloat
* Replaced kmalloc with kzalloc
* Added comments about testing
* Improved readability when using snprintf

Have pushed this through 0-day. Waiting on results..

Best
Joel

Joel Granados (8):
parport: Move magic number "15" to a define
parport: Remove register_sysctl_table from parport_proc_register
parport: Remove register_sysctl_table from
parport_device_proc_register
parport: Remove register_sysctl_table from
parport_default_proc_register
parport: Removed sysctl related defines
sysctl: stop exporting register_sysctl_table
sysctl: Refactor base paths registrations
sysctl: Remove register_sysctl_table

drivers/parport/procfs.c | 174 ++++++++++++++++++++------------------
drivers/parport/share.c | 2 +-
fs/proc/proc_sysctl.c | 162 +----------------------------------
fs/sysctls.c | 5 +-
include/linux/parport.h | 2 +
include/linux/sysctl.h | 31 +------
kernel/sysctl.c | 30 ++-----
scripts/check-sysctl-docs | 10 ---
8 files changed, 110 insertions(+), 306 deletions(-)

--
2.30.2



2023-05-23 12:49:19

by Joel Granados

[permalink] [raw]
Subject: [PATCH v4 4/8] parport: Remove register_sysctl_table from parport_default_proc_register

This is part of the general push to deprecate register_sysctl_paths and
register_sysctl_table. Simply change the full path "dev/parport/default"
to point to an already existing set of table entries (vars). We also
remove the unused elements from parport_default_table.

To make sure the resulting directory structure did not change we
made sure that `find /proc/sys/dev/ | sha1sum` was the same before and
after the change.

Signed-off-by: Joel Granados <[email protected]>
Reviewed-by: Luis Chamberlain <[email protected]>
Signed-off-by: Luis Chamberlain <[email protected]>
---
drivers/parport/procfs.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 22d211c95168..1a26918d2cc8 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -430,22 +430,6 @@ parport_default_sysctl_table = {
.extra2 = (void*) &parport_max_spintime_value
},
{}
- },
- {
- {
- .procname = "default",
- .mode = 0555,
- .child = parport_default_sysctl_table.vars
- },
- {}
- },
- {
- PARPORT_PARPORT_DIR(parport_default_sysctl_table.default_dir),
- {}
- },
- {
- PARPORT_DEV_DIR(parport_default_sysctl_table.parport_dir),
- {}
}
};

@@ -601,7 +585,7 @@ static int __init parport_default_proc_register(void)
int ret;

parport_default_sysctl_table.sysctl_header =
- register_sysctl_table(parport_default_sysctl_table.dev_dir);
+ register_sysctl("dev/parport/default", parport_default_sysctl_table.vars);
if (!parport_default_sysctl_table.sysctl_header)
return -ENOMEM;
ret = parport_bus_init();
--
2.30.2


2023-05-23 12:49:43

by Joel Granados

[permalink] [raw]
Subject: [PATCH v4 5/8] parport: Removed sysctl related defines

The partport driver used to rely on defines to include different
directories in sysctl. Now that we have made the transition to
register_sysctl from regsiter_sysctl_table, they are no longer needed.

Signed-off-by: Joel Granados <[email protected]>
Reviewed-by: Luis Chamberlain <[email protected]>
Signed-off-by: Luis Chamberlain <[email protected]>
---
drivers/parport/procfs.c | 7 -------
1 file changed, 7 deletions(-)

diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 1a26918d2cc8..cbb1fb5127ce 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -243,13 +243,6 @@ do { \
return 0;
}

-#define PARPORT_PORT_DIR(CHILD) { .procname = NULL, .mode = 0555, .child = CHILD }
-#define PARPORT_PARPORT_DIR(CHILD) { .procname = "parport", \
- .mode = 0555, .child = CHILD }
-#define PARPORT_DEV_DIR(CHILD) { .procname = "dev", .mode = 0555, .child = CHILD }
-#define PARPORT_DEVICES_ROOT_DIR { .procname = "devices", \
- .mode = 0555, .child = NULL }
-
static const unsigned long parport_min_timeslice_value =
PARPORT_MIN_TIMESLICE_VALUE;

--
2.30.2


2023-05-24 04:54:27

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH v4 0/8] sysctl: Completely remove register_sysctl_table from sources

On Tue, May 23, 2023 at 02:22:12PM +0200, Joel Granados wrote:
> This is part of the general push to deprecate register_sysctl_paths and
> register_sysctl_table. It contains 2 patchsets that were originally sent
> separately. I have put them together because the second followed the first.
>
> Parport driver uses the "CHILD" pointer in the ctl_table structure to create
> its directory structure. We move to the newer register_sysctl call and remove
> the pointer madness. I have separated the parport into 5 patches to clarify the
> different changes needed for the 3 calls to register_sysctl_paths.
>
> We no longer export the register_sysctl_table call as parport was the
> last user from outside proc_sysctl.c. Also modified documentation slightly
> so register_sysctl_table is no longer mentioned.
>
> Replace register_sysctl_table with register_sysctl effectively effectively
> transitioning 5 base paths ("kernel", "vm", "fs", "dev" and "debug") to the new
> call. Besides removing the actual function, I also removed it from the checks
> done in check-sysctl-docs. @mcgrof went a bit further and removed 2 more
> functions.
>
> Testing for this change was done in the same way as with previous sysctl
> replacement patches: I made sure that the result of `find /proc/sys/ | sha1sum`
> was the same before and after the patchset.

Thanks! Queued up onto sysctl-next!

Luis