Skip to content

Commit

Permalink
Merge tag 'sysctl-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/mcgrof/linux

Pull sysctl updates from Luis Chamberlain:
 "This only does a few sysctl moves from the kernel/sysctl.c file, the
  rest of the work has been put towards deprecating two API calls which
  incur recursion and prevent us from simplifying the registration
  process / saving memory per move. Most of the changes have been
  soaking on linux-next since v6.3-rc3.

  I've slowed down the kernel/sysctl.c moves due to Matthew Wilcox's
  feedback that we should see if we could *save* memory with these moves
  instead of incurring more memory. We currently incur more memory since
  when we move a syctl from kernel/sysclt.c out to its own file we end
  up having to add a new empty sysctl used to register it. To achieve
  saving memory we want to allow syctls to be passed without requiring
  the end element being empty, and just have our registration process
  rely on ARRAY_SIZE(). Without this, supporting both styles of sysctls
  would make the sysctl registration pretty brittle, hard to read and
  maintain as can be seen from Meng Tang's efforts to do just this [0].
  Fortunately, in order to use ARRAY_SIZE() for all sysctl registrations
  also implies doing the work to deprecate two API calls which use
  recursion in order to support sysctl declarations with subdirectories.

  And so during this development cycle quite a bit of effort went into
  this deprecation effort. I've annotated the following two APIs are
  deprecated and in few kernel releases we should be good to remove
  them:

   - register_sysctl_table()
   - register_sysctl_paths()

  During this merge window we should be able to deprecate and unexport
  register_sysctl_paths(), we can probably do that towards the end of
  this merge window.

  Deprecating register_sysctl_table() will take a bit more time but this
  pull request goes with a few example of how to do this.

  As it turns out each of the conversions to move away from either of
  these two API calls *also* saves memory. And so long term, all these
  changes *will* prove to have saved a bit of memory on boot.

  The way I see it then is if remove a user of one deprecated call, it
  gives us enough savings to move one kernel/sysctl.c out from the
  generic arrays as we end up with about the same amount of bytes.

  Since deprecating register_sysctl_table() and register_sysctl_paths()
  does not require maintainer coordination except the final unexport
  you'll see quite a bit of these changes from other pull requests, I've
  just kept the stragglers after rc3"

Link: https://lkml.kernel.org/r/[email protected] [0]

* tag 'sysctl-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: (29 commits)
  fs: fix sysctls.c built
  mm: compaction: remove incorrect #ifdef checks
  mm: compaction: move compaction sysctl to its own file
  mm: memory-failure: Move memory failure sysctls to its own file
  arm: simplify two-level sysctl registration for ctl_isa_vars
  ia64: simplify one-level sysctl registration for kdump_ctl_table
  utsname: simplify one-level sysctl registration for uts_kern_table
  ntfs: simplfy one-level sysctl registration for ntfs_sysctls
  coda: simplify one-level sysctl registration for coda_table
  fs/cachefiles: simplify one-level sysctl registration for cachefiles_sysctls
  xfs: simplify two-level sysctl registration for xfs_table
  nfs: simplify two-level sysctl registration for nfs_cb_sysctls
  nfs: simplify two-level sysctl registration for nfs4_cb_sysctls
  lockd: simplify two-level sysctl registration for nlm_sysctls
  proc_sysctl: enhance documentation
  xen: simplify sysctl registration for balloon
  md: simplify sysctl registration
  hv: simplify sysctl registration
  scsi: simplify sysctl registration with register_sysctl()
  csky: simplify alignment sysctl registration
  ...
  • Loading branch information
torvalds committed Apr 27, 2023
2 parents b6a7828 + e3184de commit 888d3c9
Show file tree
Hide file tree
Showing 30 changed files with 248 additions and 449 deletions.
18 changes: 1 addition & 17 deletions arch/arm/kernel/isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,11 @@ static struct ctl_table ctl_isa_vars[4] = {

static struct ctl_table_header *isa_sysctl_header;

static struct ctl_table ctl_isa[2] = {
{
.procname = "isa",
.mode = 0555,
.child = ctl_isa_vars,
}, {}
};

static struct ctl_table ctl_bus[2] = {
{
.procname = "bus",
.mode = 0555,
.child = ctl_isa,
}, {}
};

void __init
register_isa_ports(unsigned int membase, unsigned int portbase, unsigned int portshift)
{
isa_membase = membase;
isa_portbase = portbase;
isa_portshift = portshift;
isa_sysctl_header = register_sysctl_table(ctl_bus);
isa_sysctl_header = register_sysctl("bus/isa", ctl_isa_vars);
}
15 changes: 1 addition & 14 deletions arch/csky/abiv1/alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,22 +332,9 @@ static struct ctl_table alignment_tbl[5] = {
{}
};

static struct ctl_table sysctl_table[2] = {
{
.procname = "csky_alignment",
.mode = 0555,
.child = alignment_tbl},
{}
};

static struct ctl_path sysctl_path[2] = {
{.procname = "csky"},
{}
};

static int __init csky_alignment_init(void)
{
register_sysctl_paths(sysctl_path, sysctl_table);
register_sysctl_init("csky/csky_alignment", alignment_tbl);
return 0;
}

Expand Down
11 changes: 1 addition & 10 deletions arch/ia64/kernel/crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,6 @@ static struct ctl_table kdump_ctl_table[] = {
},
{ }
};

static struct ctl_table sys_table[] = {
{
.procname = "kernel",
.mode = 0555,
.child = kdump_ctl_table,
},
{ }
};
#endif

static int
Expand All @@ -257,7 +248,7 @@ machine_crash_setup(void)
if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
return ret;
#ifdef CONFIG_SYSCTL
register_sysctl_table(sys_table);
register_sysctl("kernel", kdump_ctl_table);
#endif
return 0;
}
Expand Down
11 changes: 1 addition & 10 deletions drivers/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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");

Expand Down
22 changes: 1 addition & 21 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down Expand Up @@ -9653,7 +9633,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;
Expand Down
16 changes: 1 addition & 15 deletions drivers/scsi/scsi_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 1 addition & 19 deletions drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions fs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Rewritten to use lists instead of if-statements.
#

obj-$(CONFIG_SYSCTL) += sysctls.o

obj-y := open.o read_write.o file_table.o super.o \
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
Expand Down Expand Up @@ -50,7 +49,7 @@ obj-$(CONFIG_FS_MBCACHE) += mbcache.o
obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o
obj-$(CONFIG_NFS_COMMON) += nfs_common/
obj-$(CONFIG_COREDUMP) += coredump.o
obj-$(CONFIG_SYSCTL) += drop_caches.o
obj-$(CONFIG_SYSCTL) += drop_caches.o sysctls.o

obj-$(CONFIG_FHANDLE) += fhandle.o
obj-y += iomap/
Expand Down
11 changes: 1 addition & 10 deletions fs/cachefiles/error_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,9 @@ static struct ctl_table cachefiles_sysctls[] = {
{}
};

static struct ctl_table cachefiles_sysctls_root[] = {
{
.procname = "cachefiles",
.mode = 0555,
.child = cachefiles_sysctls,
},
{}
};

int __init cachefiles_register_error_injection(void)
{
cachefiles_sysctl = register_sysctl_table(cachefiles_sysctls_root);
cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls);
if (!cachefiles_sysctl)
return -ENOMEM;
return 0;
Expand Down
11 changes: 1 addition & 10 deletions fs/coda/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,10 @@ static struct ctl_table coda_table[] = {
{}
};

static struct ctl_table fs_table[] = {
{
.procname = "coda",
.mode = 0555,
.child = coda_table
},
{}
};

void coda_sysctl_init(void)
{
if ( !fs_table_header )
fs_table_header = register_sysctl_table(fs_table);
fs_table_header = register_sysctl("coda", coda_table);
}

void coda_sysctl_clean(void)
Expand Down
20 changes: 1 addition & 19 deletions fs/lockd/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,24 +510,6 @@ static struct ctl_table nlm_sysctls[] = {
{ }
};

static struct ctl_table nlm_sysctl_dir[] = {
{
.procname = "nfs",
.mode = 0555,
.child = nlm_sysctls,
},
{ }
};

static struct ctl_table nlm_sysctl_root[] = {
{
.procname = "fs",
.mode = 0555,
.child = nlm_sysctl_dir,
},
{ }
};

#endif /* CONFIG_SYSCTL */

/*
Expand Down Expand Up @@ -644,7 +626,7 @@ static int __init init_nlm(void)

#ifdef CONFIG_SYSCTL
err = -ENOMEM;
nlm_sysctl_table = register_sysctl_table(nlm_sysctl_root);
nlm_sysctl_table = register_sysctl("fs/nfs", nlm_sysctls);
if (nlm_sysctl_table == NULL)
goto err_sysctl;
#endif
Expand Down
21 changes: 2 additions & 19 deletions fs/nfs/nfs4sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,10 @@ static struct ctl_table nfs4_cb_sysctls[] = {
{ }
};

static struct ctl_table nfs4_cb_sysctl_dir[] = {
{
.procname = "nfs",
.mode = 0555,
.child = nfs4_cb_sysctls,
},
{ }
};

static struct ctl_table nfs4_cb_sysctl_root[] = {
{
.procname = "fs",
.mode = 0555,
.child = nfs4_cb_sysctl_dir,
},
{ }
};

int nfs4_register_sysctl(void)
{
nfs4_callback_sysctl_table = register_sysctl_table(nfs4_cb_sysctl_root);
nfs4_callback_sysctl_table = register_sysctl("fs/nfs",
nfs4_cb_sysctls);
if (nfs4_callback_sysctl_table == NULL)
return -ENOMEM;
return 0;
Expand Down
20 changes: 1 addition & 19 deletions fs/nfs/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,9 @@ static struct ctl_table nfs_cb_sysctls[] = {
{ }
};

static struct ctl_table nfs_cb_sysctl_dir[] = {
{
.procname = "nfs",
.mode = 0555,
.child = nfs_cb_sysctls,
},
{ }
};

static struct ctl_table nfs_cb_sysctl_root[] = {
{
.procname = "fs",
.mode = 0555,
.child = nfs_cb_sysctl_dir,
},
{ }
};

int nfs_register_sysctl(void)
{
nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root);
nfs_callback_sysctl_table = register_sysctl("fs/nfs", nfs_cb_sysctls);
if (nfs_callback_sysctl_table == NULL)
return -ENOMEM;
return 0;
Expand Down
12 changes: 1 addition & 11 deletions fs/ntfs/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ static struct ctl_table ntfs_sysctls[] = {
{}
};

/* Define the parent directory /proc/sys/fs. */
static struct ctl_table sysctls_root[] = {
{
.procname = "fs",
.mode = 0555,
.child = ntfs_sysctls
},
{}
};

/* Storage for the sysctls header. */
static struct ctl_table_header *sysctls_root_table;

Expand All @@ -54,7 +44,7 @@ int ntfs_sysctl(int add)
{
if (add) {
BUG_ON(sysctls_root_table);
sysctls_root_table = register_sysctl_table(sysctls_root);
sysctls_root_table = register_sysctl("fs", ntfs_sysctls);
if (!sysctls_root_table)
return -ENOMEM;
} else {
Expand Down
Loading

0 comments on commit 888d3c9

Please sign in to comment.