sysctl: Remove sentinel elements from kernel dir
cover sysctl: Remove sentinel elements from kernel dir
What?
These commits remove the sentinel element (last empty element) from the sysctl arrays of all the files under the "kernel/" directory that use a sysctl array for registration. The merging of the preparation patches (in https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
to mainline allows us to just remove sentinel elements without changing behavior (more info here [1]).
These commits are part of a bigger set (here
https://github.com/Joelgranados/linux/tree/tag/sysctl_remove_empty_elem_V5)
that remove the ctl_table sentinel. Make the review process easier by chunking the commits into manageable pieces. Each chunk can be reviewed separately without noise from parallel sets.
Sending the "kernel/*" chunk now that the "drivers/" has been mostly reviewed [6]. After this and the "fs/*" are reviewed we only miss 2 more chunks ("net/*" and miscellaneous) to complete the sentinel removal. Hurray!!!
Why?
By removing the sysctl sentinel elements we avoid kernel bloat as ctl_table arrays get moved out of kernel/sysctl.c into their own respective subsystems. This move was started long ago to avoid merge conflicts; the sentinel removal bit came after Mathew Wilcox suggested it to avoid bloating the kernel by one element as arrays moved out. This patchset will reduce the overall build time size of the kernel and run time memory bloat by about ~64 bytes per declared ctl_table array. I have consolidated some links that shed light on the history of this effort [2].
Testing:
* Ran sysctl selftests (./tools/testing/selftests/sysctl/sysctl.sh)
* Ran this through 0-day with no errors or warnings
Size saving after this patchset:
* bloat-o-meter
- The "yesall" config saves 1984 bytes [4]
- The "tiny" config saves 771 bytes [5]
* If you want to know how many bytes are saved after all the chunks are merged see [3]
Base commit:
tag: sysctl-6.7-rc1 (8b793bcda61f)
Comments/feedback greatly appreciated
Best
Joel
[1]
We are able to remove a sentinel table without behavioral change by introducing a table_size argument in the same place where procname is checked for NULL. The idea is for it to keep stopping when it hits ->procname == NULL, while the sentinel is still present. And when the sentinel is removed, it will stop on the table_size. You can go to
(https://lore.kernel.org/all/[email protected]/)
for more information.
[2]
Links Related to the ctl_table sentinel removal:
* E-mail threads that summarize the sentinel effort
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/
https://lore.kernel.org/all/[email protected]/
* Replacing the register functions:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
* E-mail threads discussing prposal
https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]
[3]
Size saving after removing all sentinels:
These are the bytes that we save after removing all the sentinels (this plus all the other chunks). I included them to get an idea of how much memory we are talking about.
* bloat-o-meter:
- The "yesall" configuration results save 9158 bytes
https://lore.kernel.org/all/[email protected]/
- The "tiny" config + CONFIG_SYSCTL save 1215 bytes
https://lore.kernel.org/all/[email protected]/
* memory usage:
In memory savings are measured to be 7296 bytes. (here is how to measure [7])
[4]
add/remove: 0/0 grow/shrink: 0/31 up/down: 0/-1984 (-1984)
Function old new delta watchdog_sysctls 576 512 -64 watchdog_hardlockup_sysctl 128 64 -64 vm_table 1344 1280 -64 uts_kern_table 448 384 -64 usermodehelper_table 192 128 -64 user_table 832 768 -64 user_event_sysctls 128 64 -64 timer_sysctl 128 64 -64 signal_debug_table 128 64 -64 seccomp_sysctl_table 192 128 -64 sched_rt_sysctls 256 192 -64 sched_fair_sysctls 256 192 -64 sched_energy_aware_sysctls 128 64 -64 sched_dl_sysctls 192 128 -64 sched_core_sysctls 384 320 -64 sched_autogroup_sysctls 128 64 -64 printk_sysctls 512 448 -64 pid_ns_ctl_table_vm 128 64 -64 pid_ns_ctl_table 128 64 -64 latencytop_sysctl 128 64 -64 kprobe_sysctls 128 64 -64 kexec_core_sysctls 256 192 -64 kern_table 2560 2496 -64 kern_reboot_table 192 128 -64 kern_panic_table 192 128 -64 kern_exit_table 128 64 -64 kern_delayacct_table 128 64 -64 kern_acct_table 128 64 -64 hung_task_sysctls 448 384 -64 ftrace_sysctls 128 64 -64 bpf_syscall_table 192 128 -64
Total: Before=429912331, After=429910347, chg -0.00%
[5]
add/remove: 0/1 grow/shrink: 0/12 up/down: 0/-771 (-771)
Function old new deltasched_core_sysctl_init 43 40 -3
vm_table 1024 960 -64 uts_kern_table 448 384 -64 usermodehelper_table 192 128 -64 user_table 576 512 -64 signal_debug_table 128 64 -64 sched_rt_sysctls 256 192 -64 sched_fair_sysctls 128 64 -64 sched_dl_sysctls 192 128 -64 sched_core_sysctls 64 - -64 kern_table 1792 1728 -64 kern_panic_table 128 64 -64 kern_exit_table 128 64 -64
Total: Before=1886645, After=1885874, chg -0.04%
[7]
To measure the in memory savings apply this on top of this patchset.
"
fs/proc/proc_sysctl.c +5 -0
@@ -976,6 +976,8 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set, table[0 ].procname = new_name; table[0 ].mode =S_IFDIR |S_IRUGO |S_IXUGO ;init_header (&new->header, set->dir.header.root, set, node, table,1 ); +// Counts additional sentinel used for each new dir. +printk ("%ld sysctl saved mem kzalloc \n" ,sizeof (struct ctl_table ));return new; }
@@ -1199,6 +1201,9 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ link_name += len; link++; } +// Counts additional sentinel used for each new registration +// +printk ("%ld sysctl saved mem kzalloc \n" ,sizeof (struct ctl_table ));init_header (links, dir->header.root, dir->header.set, node, link_table, head->ctl_table_size); links->nreg = nr_entries;
"
and then run the following bash script in the kernel:
accum=0
for n in $(dmesg | grep kzalloc | awk '{print $3}') ; do
echo $n
accum=$(calc "$accum + $n")done
echo $accum
---
---
Joel Granados (10):
kernel misc: Remove the now superfluous sentinel elements from ctl_table array
umh: Remove the now superfluous sentinel elements from ctl_table array
ftrace: Remove the now superfluous sentinel elements from ctl_table array
timekeeping: Remove the now superfluous sentinel elements from ctl_table array
seccomp: Remove the now superfluous sentinel elements from ctl_table array
scheduler: Remove the now superfluous sentinel elements from ctl_table array
printk: Remove the now superfluous sentinel elements from ctl_table array
kprobes: Remove the now superfluous sentinel elements from ctl_table array
delayacct: Remove the now superfluous sentinel elements from ctl_table array
bpf: Remove the now superfluous sentinel elements from ctl_table array
kernel/acct.c | 1 - kernel/bpf/syscall.c | 1 - kernel/delayacct.c | 1 - kernel/exit.c | 1 - kernel/hung_task.c | 1 - kernel/kexec_core.c | 1 - kernel/kprobes.c | 1 - kernel/latencytop.c | 1 - kernel/panic.c | 1 - kernel/pid_namespace.c | 1 - kernel/pid_sysctl.h | 1 - kernel/printk/sysctl.c | 1 - kernel/reboot.c | 1 - kernel/sched/autogroup.c | 1 - kernel/sched/core.c | 1 - kernel/sched/deadline.c | 1 - kernel/sched/fair.c | 1 - kernel/sched/rt.c | 1 - kernel/sched/topology.c | 1 - kernel/seccomp.c | 1 - kernel/signal.c | 1 - kernel/stackleak.c | 1 - kernel/sysctl.c | 2 -- kernel/time/timer.c | 1 - kernel/trace/ftrace.c | 1 - kernel/trace/trace_events_user.c | 1 - kernel/ucount.c | 3 +-- kernel/umh.c | 1 - kernel/utsname_sysctl.c | 1 - kernel/watchdog.c | 2 -- 30 files changed, 1 insertion(+), 33 deletions(-)
---
base-commit: 8b793bcda61f6c3ed4f5b2ded7530ef6749580cb
change-id: 20231107-jag-sysctl_remove_empty_elem_kernel-7de90cfd0c0a
Best regards,
Signature · 1 line
Joel Granados <[email protected]>
PATCH 1/10 kernel misc: Remove the now superfluous sentinel elements from ctl_table array
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove the sentinel from ctl_table arrays. Reduce by one the values used to compare the size of the adjusted arrays.
--- kernel/acct.c | 1 - kernel/exit.c | 1 - kernel/hung_task.c | 1 - kernel/kexec_core.c | 1 - kernel/latencytop.c | 1 - kernel/panic.c | 1 - kernel/pid_namespace.c | 1 - kernel/pid_sysctl.h | 1 - kernel/reboot.c | 1 - kernel/signal.c | 1 - kernel/stackleak.c | 1 - kernel/sysctl.c | 2 -- kernel/ucount.c | 3 +-- kernel/utsname_sysctl.c | 1 - kernel/watchdog.c | 2 -- 15 files changed, 1 insertion(+), 18 deletions(-)
kernel/acct.c +0 -1
@@ -84,7 +84,6 @@ static struct ctl_table kern_acct_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - { } };static __init int kernel_acct_sysctls_init (void )
kernel/exit.c +0 -1
@@ -90,7 +90,6 @@ static struct ctl_table kern_exit_table[] = { .mode = 0644, .proc_handler = proc_douintvec, }, - { } };static __init int kernel_exit_sysctls_init (void )
kernel/hung_task.c +0 -1
@@ -313,7 +313,6 @@ static struct ctl_table hung_task_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_NEG_ONE, }, - {} };static void __init hung_task_sysctl_init (void )
kernel/kexec_core.c +0 -1
@@ -1005,7 +1005,6 @@ static struct ctl_table kexec_core_sysctls[] = { .mode = 0644, .proc_handler = kexec_limit_handler, }, - { } };static int __init kexec_core_sysctl_init (void )
kernel/latencytop.c +0 -1
@@ -85,7 +85,6 @@ static struct ctl_table latencytop_sysctl[] = { .mode = 0644, .proc_handler = sysctl_latencytop, }, - {} };#endif
kernel/panic.c +0 -1
@@ -99,7 +99,6 @@ static struct ctl_table kern_panic_table[] = { .mode = 0644, .proc_handler = proc_douintvec, }, - { } };static __init int kernel_panic_sysctls_init (void )
kernel/pid_namespace.c +0 -1
@@ -312,7 +312,6 @@ static struct ctl_table pid_ns_ctl_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = &pid_max, }, - { } };#endif /* CONFIG_CHECKPOINT_RESTORE */
kernel/pid_sysctl.h +0 -1
@@ -41,7 +41,6 @@ static struct ctl_table pid_ns_ctl_table_vm[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, - { } };static inline void register_pid_ns_sysctl_table_vm (void ) {
kernel/reboot.c +0 -1
@@ -1272,7 +1272,6 @@ static struct ctl_table kern_reboot_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - { } };static void __init kernel_reboot_sysctls_init (void )
kernel/signal.c +0 -1
@@ -4800,7 +4800,6 @@ static struct ctl_table signal_debug_table[] = { .proc_handler = proc_dointvec },#endif - { } };static int __init init_signal_sysctls (void )
kernel/stackleak.c +0 -1
@@ -54,7 +54,6 @@ static struct ctl_table stackleak_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static int __init stackleak_sysctls_init (void )
kernel/sysctl.c +0 -2
@@ -2043,7 +2043,6 @@ static struct ctl_table kern_table[] = { .extra2 = SYSCTL_INT_MAX, },#endif - { } }; static struct ctl_table vm_table[] = {
@@ -2249,7 +2248,6 @@ static struct ctl_table vm_table[] = { .extra2 = (void *)&mmap_rnd_compat_bits_max, },#endif - { } };int __init sysctl_init_bases (void )
kernel/ucount.c +1 -2
@@ -87,7 +87,6 @@ static struct ctl_table user_table[] = {UCOUNT_ENTRY ("max_fanotify_groups" ), UCOUNT_ENTRY("max_fanotify_marks"), #endif - { } };#endif /* CONFIG_SYSCTL */
@@ -96,7 +95,7 @@ bool setup_userns_sysctls(struct user_namespace *ns)#ifdef CONFIG_SYSCTL struct ctl_table *tbl; -BUILD_BUG_ON (ARRAY_SIZE (user_table) !=UCOUNT_COUNTS +1 ); +BUILD_BUG_ON (ARRAY_SIZE (user_table) !=UCOUNT_COUNTS );setup_sysctl_set (&ns->set, &set_root, set_is_seen); tbl =kmemdup (user_table,sizeof (user_table),GFP_KERNEL );if (tbl) {
kernel/utsname_sysctl.c +0 -1
@@ -120,7 +120,6 @@ static struct ctl_table uts_kern_table[] = { .proc_handler = proc_do_uts_string, .poll = &domainname_poll, }, - {} };#ifdef CONFIG_PROC_SYSCTL
kernel/watchdog.c +0 -2
@@ -924,7 +924,6 @@ static struct ctl_table watchdog_sysctls[] = { },#endif /* CONFIG_SMP */ #endif - {} }; static struct ctl_table watchdog_hardlockup_sysctl[] = {
@@ -937,7 +936,6 @@ static struct ctl_table watchdog_hardlockup_sysctl[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static void __init watchdog_sysctl_init (void )
Signature · 1 line
2.30.2
PATCH 2/10 umh: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel element from usermodehelper_table
--- kernel/umh.c | 1 - 1 file changed, 1 deletion(-)
kernel/umh.c +0 -1
@@ -560,7 +560,6 @@ static struct ctl_table usermodehelper_table[] = { .mode = 0600, .proc_handler = proc_cap_handler, }, - { } };static int __init init_umh_sysctls (void )
Signature · 1 line
2.30.2
PATCH 3/10 ftrace: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel elements from ftrace_sysctls and user_event_sysctls
--- kernel/trace/ftrace.c | 1 - kernel/trace/trace_events_user.c | 1 - 2 files changed, 2 deletions(-)
kernel/trace/ftrace.c +0 -1
@@ -8264,7 +8264,6 @@ static struct ctl_table ftrace_sysctls[] = { .mode = 0644, .proc_handler = ftrace_enable_sysctl, }, - {} };static int __init ftrace_sysctl_init (void )
kernel/trace/trace_events_user.c +0 -1
@@ -2694,7 +2694,6 @@ static struct ctl_table user_event_sysctls[] = { .mode = 0644, .proc_handler = set_max_user_events_sysctl, }, - {} };static int __init trace_events_user_init (void )
Signature · 1 line
2.30.2
PATCH 4/10 timekeeping: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel element from time_sysctl
--- kernel/time/timer.c | 1 - 1 file changed, 1 deletion(-)
kernel/time/timer.c +0 -1
@@ -260,7 +260,6 @@ static struct ctl_table timer_sysctl[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static int __init timer_sysctl_init (void )
Signature · 1 line
2.30.2
PATCH 5/10 seccomp: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel element from seccomp_sysctl_table.
--- kernel/seccomp.c | 1 - 1 file changed, 1 deletion(-)
kernel/seccomp.c +0 -1
@@ -2445,7 +2445,6 @@ static struct ctl_table seccomp_sysctl_table[] = { .mode = 0644, .proc_handler = seccomp_actions_logged_handler, }, - { } };static int __init seccomp_sysctl_init (void )
Signature · 1 line
2.30.2
PATCH 6/10 scheduler: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
rm sentinel element from ctl_table arrays
--- kernel/sched/autogroup.c | 1 - kernel/sched/core.c | 1 - kernel/sched/deadline.c | 1 - kernel/sched/fair.c | 1 - kernel/sched/rt.c | 1 - kernel/sched/topology.c | 1 - 6 files changed, 6 deletions(-)
kernel/sched/autogroup.c +0 -1
@@ -19,7 +19,6 @@ static struct ctl_table sched_autogroup_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static void __init sched_autogroup_sysctl_init (void )
kernel/sched/core.c +0 -1
@@ -4712,7 +4712,6 @@ static struct ctl_table sched_core_sysctls[] = { .extra2 = SYSCTL_FOUR, },#endif /* CONFIG_NUMA_BALANCING */ - {} };static int __init sched_core_sysctl_init (void ) {
kernel/sched/deadline.c +0 -1
@@ -43,7 +43,6 @@ static struct ctl_table sched_dl_sysctls[] = { .proc_handler = proc_douintvec_minmax, .extra2 = (void *)&sysctl_sched_dl_period_max, }, - {} };static int __init sched_dl_sysctl_init (void )
kernel/sched/fair.c +0 -1
@@ -172,7 +172,6 @@ static struct ctl_table sched_fair_sysctls[] = { .extra1 = SYSCTL_ZERO, },#endif /* CONFIG_NUMA_BALANCING */ - {} };static int __init sched_fair_sysctl_init (void )
kernel/sched/rt.c +0 -1
@@ -52,7 +52,6 @@ static struct ctl_table sched_rt_sysctls[] = { .mode = 0644, .proc_handler = sched_rr_handler, }, - {} };static int __init sched_rt_sysctl_init (void )
kernel/sched/topology.c +0 -1
@@ -250,7 +250,6 @@ static struct ctl_table sched_energy_aware_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static int __init sched_energy_aware_sysctl_init (void )
Signature · 1 line
2.30.2
PATCH 7/10 printk: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
rm sentinel element from printk_sysctls
--- kernel/printk/sysctl.c | 1 - 1 file changed, 1 deletion(-)
kernel/printk/sysctl.c +0 -1
@@ -76,7 +76,6 @@ static struct ctl_table printk_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, - {} };void __init printk_sysctl_init (void )
Signature · 1 line
2.30.2
PATCH 8/10 kprobes: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel element from kprobe_sysclts
--- kernel/kprobes.c | 1 - 1 file changed, 1 deletion(-)
kernel/kprobes.c +0 -1
@@ -968,7 +968,6 @@ static struct ctl_table kprobe_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static void __init kprobe_sysctls_init (void )
Signature · 1 line
2.30.2
PATCH 9/10 delayacct: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel element from kern_delayacct_table
--- kernel/delayacct.c | 1 - 1 file changed, 1 deletion(-)
kernel/delayacct.c +0 -1
@@ -74,7 +74,6 @@ static struct ctl_table kern_delayacct_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - { } };static __init int kernel_delayacct_sysctls_init (void )
Signature · 1 line
2.30.2
PATCH 10/10 bpf: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosThis commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Remove sentinel element from bpf_syscall_table.
--- kernel/bpf/syscall.c | 1 - 1 file changed, 1 deletion(-)
kernel/bpf/syscall.c +0 -1
@@ -5679,7 +5679,6 @@ static struct ctl_table bpf_syscall_table[] = { .mode = 0644, .proc_handler = bpf_stats_handler, }, - { } };static int __init bpf_syscall_sysctl_init (void )
Signature · 1 line
2.30.2
Re: [PATCH 06/10] scheduler: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosQuoted 11 lines · On Tue, Nov 07, 2023 at 02:45:06PM +0100, Joel Granados via B4 Relay wrote:
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)rm sentinel element from
ctl_tablearraysSigned-off-by Joel Granados <[email protected]>
Quoted 8 lines
--- kernel/sched/autogroup.c | 1 - kernel/sched/core.c | 1 - kernel/sched/deadline.c | 1 - kernel/sched/fair.c | 1 - kernel/sched/rt.c | 1 - kernel/sched/topology.c | 1 - 6 files changed, 6 deletions(-)
Re: [PATCH 10/10] bpf: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosQuoted 9 lines · On Tue, Nov 7, 2023 at 5:45 AM Joel Granados via B4 Relay…
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Quoted 7 lines
Remove sentinel element from
bpf_syscall_table.Signed-off-by Joel Granados <[email protected]>--- kernel/bpf/syscall.c | 1 - 1 file changed, 1 deletion(-)
LGTM.
Quoted 16 lines
kernel/bpf/syscall.c +0
-2@@ -5679,7 +5679,6 @@ static struct ctl_table bpf_syscall_table[] = { .mode = 0644, .proc_handler = bpf_stats_handler, }, - { } };static int __init bpf_syscall_sysctl_init (void ) --2.30.2
Re: [PATCH 05/10] seccomp: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosQuoted 11 lines · On Tue, Nov 07, 2023 at 02:45:05PM +0100, Joel Granados via B4 Relay wrote:
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)Remove sentinel element from
seccomp_sysctl_table.Signed-off-by Joel Granados <[email protected]>
Signature · 1 line
Kees Cook
Re: [PATCH 08/10] kprobes: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosQuoted 9 lines · On Tue, 07 Nov 2023 14:45:08 +0100 Joel Granados via B4 Relay…
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)Remove sentinel element from
kprobe_sysclts
Looks good to me.
Thanks,
Quoted 22 lines
Signed-off-by Joel Granados <[email protected]>--- kernel/kprobes.c | 1 - 1 file changed, 1 deletion(-)kernel/kprobes.c +0
-1@@ -968,7 +968,6 @@ static struct ctl_table kprobe_sysctls[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, - {} };static void __init kprobe_sysctls_init (void )Signature · 2 lines
-- 2.30.2
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Re: [PATCH 03/10] ftrace: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosQuoted 10 lines · On Tue, 07 Nov 2023 14:45:03 +0100 Joel Granados via B4 Relay…
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)Remove sentinel elements from
ftrace_sysctlsanduser_event_sysctls
Both looks good to me. (since register_sysctl_init() uses ARRAY_SIZE() macro to get the array size.)
Quoted 34 lines
Signed-off-by Joel Granados <[email protected]>--- kernel/trace/ftrace.c | 1 - kernel/trace/trace_events_user.c | 1 - 2 files changed, 2 deletions(-)kernel/trace/ftrace.c +0
-1@@ -8264,7 +8264,6 @@ static struct ctl_table ftrace_sysctls[] = { .mode = 0644, .proc_handler = ftrace_enable_sysctl, }, - {} };static int __init ftrace_sysctl_init (void )kernel/trace/trace_events_user.c +0
-1@@ -2694,7 +2694,6 @@ static struct ctl_table user_event_sysctls[] = { .mode = 0644, .proc_handler = set_max_user_events_sysctl, }, - {} };static int __init trace_events_user_init (void )Signature · 2 lines
-- 2.30.2
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Re: [PATCH 03/10] ftrace: Remove the now superfluous sentinel elements from ctl_table array
Quoted 11 lines · On Wed, 8 Nov 2023 19:29:49 +0900 Masami Hiramatsu (Google)…
Quoted 8 lines · On Tue, 07 Nov 2023 14:45:03 +0100 Joel Granados via B4 Relay…
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Quoted 7 lines
Quoted 2 lines
Remove sentinel elements from
ftrace_sysctlsanduser_event_sysctlsBoth looks good to me. (since
register_sysctl_init()usesARRAY_SIZE()macro to get the array size.)
Agreed.
-- Steve
Re: [PATCH 07/10] printk: Remove the now superfluous sentinel elements from ctl_table array
In reply to Joel GranadosQuoted 11 lines · On Tue 2023-11-07 14:45:07, Joel Granados via B4 Relay wrote:
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)rm sentinel element from
printk_sysctlsSigned-off-by Joel Granados <[email protected]>
I am a bit sceptical if the size and time reduction is worth the effort. I feel that this change makes the access a bit less secure.
Well, almost all arrays are static so that it should just work. The patch does what it says. Feel free to use:
Best Regards,
Petr
Re: [PATCH 07/10] printk: Remove the now superfluous sentinel elements from ctl_table array
Hey Petr
I missed this message somehow....
Quoted 9 lines · Petr Mladek
Quoted 8 lines · On Tue 2023-11-07 14:45:07, Joel Granados via B4 Relay wrote:
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)
Quoted 6 lines
Quoted 3 lines
rm sentinel element from
printk_sysctlsSigned-off-by Joel Granados <[email protected]>I am a bit sceptical if the size and time reduction is worth the effort. I feel that this change makes the access a bit less secure.
In what way "less secure"? Can you expand on that?
Notice that if you pass a pointer to the register functions, you will get a warning/error on compilation.
Quoted 3 lines
Well, almost all arrays are static so that it should just work. The patch does what it says. Feel free to use:
Thx for the review. will do.
Quoted 5 lines
Reviewed-by Petr Mladek <[email protected]>Best Regards,
Petr
Signature · 1 line
Joel Granados
Petr Mladek
maintainerRe: [PATCH 07/10] printk: Remove the now superfluous sentinel elements from ctl_table array
Quoted 16 lines · Joel Granados
Hey Petr
I missed this message somehow....
Quoted 11 lines · Petr Mladek
Quoted 10 lines · On Tue 2023-11-07 14:45:07, Joel Granados via B4 Relay wrote:
From: Joel Granados <[email protected]>
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the
ctl_tablearrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/)rm sentinel element from
printk_sysctls
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Joel Granados <[email protected]>I am a bit sceptical if the size and time reduction is worth the effort. I feel that this change makes the access a bit less secure.
In what way "less secure"? Can you expand on that?
Notice that if you pass a pointer to the register functions, you will get a warning/error on compilation.
I have vague memories that some arrays were not static or the length has been somehow manipulated. But I might be wrong.
You are right that it should be safe with the static arrays. And the NULL sentinel might be more error-prone after all.
Let's forget my mumbles.
Best Regards,
Petr