Skip to content

Commit 888d3c9

Browse files
committed
Merge tag 'sysctl-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/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/ZAD+cpbrqlc5vmry@bombadil.infradead.org [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 ...
2 parents b6a7828 + e3184de commit 888d3c9

30 files changed

Lines changed: 248 additions & 449 deletions

File tree

arch/arm/kernel/isa.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,11 @@ static struct ctl_table ctl_isa_vars[4] = {
4040

4141
static struct ctl_table_header *isa_sysctl_header;
4242

43-
static struct ctl_table ctl_isa[2] = {
44-
{
45-
.procname = "isa",
46-
.mode = 0555,
47-
.child = ctl_isa_vars,
48-
}, {}
49-
};
50-
51-
static struct ctl_table ctl_bus[2] = {
52-
{
53-
.procname = "bus",
54-
.mode = 0555,
55-
.child = ctl_isa,
56-
}, {}
57-
};
58-
5943
void __init
6044
register_isa_ports(unsigned int membase, unsigned int portbase, unsigned int portshift)
6145
{
6246
isa_membase = membase;
6347
isa_portbase = portbase;
6448
isa_portshift = portshift;
65-
isa_sysctl_header = register_sysctl_table(ctl_bus);
49+
isa_sysctl_header = register_sysctl("bus/isa", ctl_isa_vars);
6650
}

arch/csky/abiv1/alignment.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,9 @@ static struct ctl_table alignment_tbl[5] = {
332332
{}
333333
};
334334

335-
static struct ctl_table sysctl_table[2] = {
336-
{
337-
.procname = "csky_alignment",
338-
.mode = 0555,
339-
.child = alignment_tbl},
340-
{}
341-
};
342-
343-
static struct ctl_path sysctl_path[2] = {
344-
{.procname = "csky"},
345-
{}
346-
};
347-
348335
static int __init csky_alignment_init(void)
349336
{
350-
register_sysctl_paths(sysctl_path, sysctl_table);
337+
register_sysctl_init("csky/csky_alignment", alignment_tbl);
351338
return 0;
352339
}
353340

arch/ia64/kernel/crash.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,6 @@ static struct ctl_table kdump_ctl_table[] = {
234234
},
235235
{ }
236236
};
237-
238-
static struct ctl_table sys_table[] = {
239-
{
240-
.procname = "kernel",
241-
.mode = 0555,
242-
.child = kdump_ctl_table,
243-
},
244-
{ }
245-
};
246237
#endif
247238

248239
static int
@@ -257,7 +248,7 @@ machine_crash_setup(void)
257248
if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
258249
return ret;
259250
#ifdef CONFIG_SYSCTL
260-
register_sysctl_table(sys_table);
251+
register_sysctl("kernel", kdump_ctl_table);
261252
#endif
262253
return 0;
263254
}

drivers/hv/vmbus_drv.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,15 +1460,6 @@ static struct ctl_table hv_ctl_table[] = {
14601460
{}
14611461
};
14621462

1463-
static struct ctl_table hv_root_table[] = {
1464-
{
1465-
.procname = "kernel",
1466-
.mode = 0555,
1467-
.child = hv_ctl_table
1468-
},
1469-
{}
1470-
};
1471-
14721463
/*
14731464
* vmbus_bus_init -Main vmbus driver initialization routine.
14741465
*
@@ -1547,7 +1538,7 @@ static int vmbus_bus_init(void)
15471538
* message recording won't be available in isolated
15481539
* guests should the following registration fail.
15491540
*/
1550-
hv_ctl_table_hdr = register_sysctl_table(hv_root_table);
1541+
hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table);
15511542
if (!hv_ctl_table_hdr)
15521543
pr_err("Hyper-V: sysctl table register error");
15531544

drivers/md/md.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,6 @@ static struct ctl_table raid_table[] = {
322322
{ }
323323
};
324324

325-
static struct ctl_table raid_dir_table[] = {
326-
{
327-
.procname = "raid",
328-
.maxlen = 0,
329-
.mode = S_IRUGO|S_IXUGO,
330-
.child = raid_table,
331-
},
332-
{ }
333-
};
334-
335-
static struct ctl_table raid_root_table[] = {
336-
{
337-
.procname = "dev",
338-
.maxlen = 0,
339-
.mode = 0555,
340-
.child = raid_dir_table,
341-
},
342-
{ }
343-
};
344-
345325
static int start_readonly;
346326

347327
/*
@@ -9653,7 +9633,7 @@ static int __init md_init(void)
96539633
mdp_major = ret;
96549634

96559635
register_reboot_notifier(&md_notifier);
9656-
raid_table_header = register_sysctl_table(raid_root_table);
9636+
raid_table_header = register_sysctl("dev/raid", raid_table);
96579637

96589638
md_geninit();
96599639
return 0;

drivers/scsi/scsi_sysctl.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,11 @@ static struct ctl_table scsi_table[] = {
2121
{ }
2222
};
2323

24-
static struct ctl_table scsi_dir_table[] = {
25-
{ .procname = "scsi",
26-
.mode = 0555,
27-
.child = scsi_table },
28-
{ }
29-
};
30-
31-
static struct ctl_table scsi_root_table[] = {
32-
{ .procname = "dev",
33-
.mode = 0555,
34-
.child = scsi_dir_table },
35-
{ }
36-
};
37-
3824
static struct ctl_table_header *scsi_table_header;
3925

4026
int __init scsi_init_sysctl(void)
4127
{
42-
scsi_table_header = register_sysctl_table(scsi_root_table);
28+
scsi_table_header = register_sysctl("dev/scsi", scsi_table);
4329
if (!scsi_table_header)
4430
return -ENOMEM;
4531
return 0;

drivers/xen/balloon.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,6 @@ static struct ctl_table balloon_table[] = {
9797
{ }
9898
};
9999

100-
static struct ctl_table balloon_root[] = {
101-
{
102-
.procname = "balloon",
103-
.mode = 0555,
104-
.child = balloon_table,
105-
},
106-
{ }
107-
};
108-
109-
static struct ctl_table xen_root[] = {
110-
{
111-
.procname = "xen",
112-
.mode = 0555,
113-
.child = balloon_root,
114-
},
115-
{ }
116-
};
117-
118100
#else
119101
#define xen_hotplug_unpopulated 0
120102
#endif
@@ -747,7 +729,7 @@ static int __init balloon_init(void)
747729
#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
748730
set_online_page_callback(&xen_online_page);
749731
register_memory_notifier(&xen_memory_nb);
750-
register_sysctl_table(xen_root);
732+
register_sysctl_init("xen/balloon", balloon_table);
751733
#endif
752734

753735
balloon_add_regions();

fs/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# Rewritten to use lists instead of if-statements.
77
#
88

9-
obj-$(CONFIG_SYSCTL) += sysctls.o
109

1110
obj-y := open.o read_write.o file_table.o super.o \
1211
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
@@ -50,7 +49,7 @@ obj-$(CONFIG_FS_MBCACHE) += mbcache.o
5049
obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o
5150
obj-$(CONFIG_NFS_COMMON) += nfs_common/
5251
obj-$(CONFIG_COREDUMP) += coredump.o
53-
obj-$(CONFIG_SYSCTL) += drop_caches.o
52+
obj-$(CONFIG_SYSCTL) += drop_caches.o sysctls.o
5453

5554
obj-$(CONFIG_FHANDLE) += fhandle.o
5655
obj-y += iomap/

fs/cachefiles/error_inject.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,9 @@ static struct ctl_table cachefiles_sysctls[] = {
2222
{}
2323
};
2424

25-
static struct ctl_table cachefiles_sysctls_root[] = {
26-
{
27-
.procname = "cachefiles",
28-
.mode = 0555,
29-
.child = cachefiles_sysctls,
30-
},
31-
{}
32-
};
33-
3425
int __init cachefiles_register_error_injection(void)
3526
{
36-
cachefiles_sysctl = register_sysctl_table(cachefiles_sysctls_root);
27+
cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls);
3728
if (!cachefiles_sysctl)
3829
return -ENOMEM;
3930
return 0;

fs/coda/sysctl.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,10 @@ static struct ctl_table coda_table[] = {
3939
{}
4040
};
4141

42-
static struct ctl_table fs_table[] = {
43-
{
44-
.procname = "coda",
45-
.mode = 0555,
46-
.child = coda_table
47-
},
48-
{}
49-
};
50-
5142
void coda_sysctl_init(void)
5243
{
5344
if ( !fs_table_header )
54-
fs_table_header = register_sysctl_table(fs_table);
45+
fs_table_header = register_sysctl("coda", coda_table);
5546
}
5647

5748
void coda_sysctl_clean(void)

0 commit comments

Comments
 (0)