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

From: Joel Granados
Date: Tue May 23 2023 - 08:22:34 EST


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