Re: [PATCH] sysctl: Add a group of macro functions to initcall the sysctl table of each feature

From: Luis Chamberlain
Date: Wed Dec 08 2021 - 15:06:08 EST


On Wed, Dec 08, 2021 at 08:34:26PM +0800, Xiaoming Ni wrote:
> On 2021/12/8 10:44, Luis Chamberlain wrote:
> > On Wed, Dec 08, 2021 at 10:10:08AM +0800, Xiaoming Ni wrote:
> > > Root node of the tree, using "early_initcall":
> > > Basic framework, "fs", "kernel", "debug", "vm", "dev", "net"
> >
> > register_sysctl_base() and yes these use early_initcall() as-is on
> > linux-next.
> >
> > > Fork node. Select initcall_level based on the number of directory levels:
> > > Registration directory shared by multiple features.
> >
> > Sure.
> >
> /proc/sys/kernel/random/
> random_table
> driver/char/random.c
> /proc/sys/kernel/usermodehelper/
> usermodehelper_table
> kernel/umh.c
> /proc/sys/kernel/firmware_config/
> firmware_config_table
> drivers/base/firmware_loader/fallback_table.c
> /proc/sys/kernel/keys/
> key_sysctls
> security/keys/sysctl.c
> /proc/sys/fs/inotify/
> inotify_table
> fs/notify/inotify/inotify_user.c
> /proc/sys/fs/fanotify/
> fanotify_table
> fs/notify/fanotify/fanotify_user.c
> /proc/sys/fs/epoll
> epoll_table
> fs/eventpoll.c
>
> I haven't checked all the sysctl subdirectories, but it seems that many are
> not shared by multiple features.
> Most features use the sysctl mechanism simply to create a file interface for
> configuring parameters.
> There are few scenarios for creating directories for other features.
> There may be tree fork nodes, but only a few.
>
>
> > > Leaf node, use "late_initcall":
> > > File Interface
> >
> > I am not sure this gives enough guidance. What is the difference between
> > fork node and a leaf node?
> Leaf node:
> a) File, .child = NULL
> b) Directory, which is not shared by multiple features, .child != NULL

If we are going to use that nomenclature then we should document it as such.
Fine by me.

Luis