Subject: [PATCH v2 00/10] sysctl: Remove sentinel elements from kernel dir

From: Joel Granados <[email protected]>

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]

Comments/feedback greatly appreciated

Changes in v2:
- No functional changes; I resent it as I did not see it in the latest
sysctl-next. It might be a bit too late to include it in 6.7 version,
but this v2 can be used for 6.8 when it comes out.
- Rebased on top of v6.7-rc6
- Added trailers to the relevant commits.
- Link to v1: https://lore.kernel.org/r/20231107-jag-sysctl_remove_empty_elem_kernel-v1-0-e4ce1388dfa0@samsung.com
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 delta
sched_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%

[6]
https://lore.kernel.org/all/20231002-jag-sysctl_remove_empty_elem_drivers-v2-0-02dd0d46f71e@samsung.com

[7]
To measure the in memory savings apply this on top of this patchset.

"
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index c88854df0b62..e0073a627bac 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -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

---

Signed-off-by: Joel Granados <[email protected]>

---
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: ceb6a6f023fd3e8b07761ed900352ef574010bcb
change-id: 20231107-jag-sysctl_remove_empty_elem_kernel-7de90cfd0c0a

Best regards,
--
Joel Granados <[email protected]>



Subject: [PATCH v2 01/10] kernel misc: Remove the now superfluous sentinel elements from ctl_table array

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_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.

Signed-off-by: Joel Granados <[email protected]>
---
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(-)

diff --git a/kernel/acct.c b/kernel/acct.c
index 986c8214dabf..179848ad33e9 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -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)
diff --git a/kernel/exit.c b/kernel/exit.c
index aedc0832c9f4..6a6ea468a0c6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -92,7 +92,6 @@ static struct ctl_table kern_exit_table[] = {
.mode = 0644,
.proc_handler = proc_douintvec,
},
- { }
};

static __init int kernel_exit_sysctls_init(void)
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 9a24574988d2..a81cb511d954 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -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)
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index be5642a4ec49..b862285b97dc 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -988,7 +988,6 @@ static struct ctl_table kexec_core_sysctls[] = {
.mode = 0644,
.proc_handler = kexec_limit_handler,
},
- { }
};

static int __init kexec_core_sysctl_init(void)
diff --git a/kernel/latencytop.c b/kernel/latencytop.c
index 781249098cb6..84c53285f499 100644
--- a/kernel/latencytop.c
+++ b/kernel/latencytop.c
@@ -85,7 +85,6 @@ static struct ctl_table latencytop_sysctl[] = {
.mode = 0644,
.proc_handler = sysctl_latencytop,
},
- {}
};
#endif

diff --git a/kernel/panic.c b/kernel/panic.c
index 2807639aab51..01a82cdfd81a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -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)
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 3028b2218aa4..ca4fbba09d38 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -306,7 +306,6 @@ static struct ctl_table pid_ns_ctl_table[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = &pid_max,
},
- { }
};
#endif /* CONFIG_CHECKPOINT_RESTORE */

diff --git a/kernel/pid_sysctl.h b/kernel/pid_sysctl.h
index 2ee41a3a1dfd..fe9fb991dc42 100644
--- a/kernel/pid_sysctl.h
+++ b/kernel/pid_sysctl.h
@@ -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)
{
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 395a0ea3c7a8..1c3b2dfc42a9 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -1276,7 +1276,6 @@ static struct ctl_table kern_reboot_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
- { }
};

static void __init kernel_reboot_sysctls_init(void)
diff --git a/kernel/signal.c b/kernel/signal.c
index 47a7602dfe8d..737b0e630ed7 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -4812,7 +4812,6 @@ static struct ctl_table signal_debug_table[] = {
.proc_handler = proc_dointvec
},
#endif
- { }
};

static int __init init_signal_sysctls(void)
diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index 34c9d81eea94..d099f3affcf1 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -54,7 +54,6 @@ static struct ctl_table stackleak_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
- {}
};

static int __init stackleak_sysctls_init(void)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 157f7ce2942d..ad61cf11922c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2034,7 +2034,6 @@ static struct ctl_table kern_table[] = {
.extra2 = SYSCTL_INT_MAX,
},
#endif
- { }
};

static struct ctl_table vm_table[] = {
@@ -2240,7 +2239,6 @@ static struct ctl_table vm_table[] = {
.extra2 = (void *)&mmap_rnd_compat_bits_max,
},
#endif
- { }
};

int __init sysctl_init_bases(void)
diff --git a/kernel/ucount.c b/kernel/ucount.c
index 4aa6166cb856..e196da0204dc 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -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) {
diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
index 019e3a1566cf..76a772072557 100644
--- a/kernel/utsname_sysctl.c
+++ b/kernel/utsname_sysctl.c
@@ -120,7 +120,6 @@ static struct ctl_table uts_kern_table[] = {
.proc_handler = proc_do_uts_string,
.poll = &domainname_poll,
},
- {}
};

#ifdef CONFIG_PROC_SYSCTL
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 5cd6d4e26915..0f546d17c544 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -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)

--
2.30.2


Subject: [PATCH v2 04/10] timekeeping: Remove the now superfluous sentinel elements from ctl_table array

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_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

Signed-off-by: Joel Granados <[email protected]>
---
kernel/time/timer.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 63a8ce7177dd..475826ad78df 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -260,7 +260,6 @@ static struct ctl_table timer_sysctl[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
- {}
};

static int __init timer_sysctl_init(void)

--
2.30.2


Subject: [PATCH v2 02/10] umh: Remove the now superfluous sentinel elements from ctl_table array

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_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

Signed-off-by: Joel Granados <[email protected]>
---
kernel/umh.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/umh.c b/kernel/umh.c
index 1b13c5d34624..598b3ffe1522 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -560,7 +560,6 @@ static struct ctl_table usermodehelper_table[] = {
.mode = 0600,
.proc_handler = proc_cap_handler,
},
- { }
};

static int __init init_umh_sysctls(void)

--
2.30.2


Subject: [PATCH v2 07/10] printk: Remove the now superfluous sentinel elements from ctl_table array

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_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

Reviewed-by: Petr Mladek <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
---
kernel/printk/sysctl.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/printk/sysctl.c b/kernel/printk/sysctl.c
index c228343eeb97..3e47dedce9e5 100644
--- a/kernel/printk/sysctl.c
+++ b/kernel/printk/sysctl.c
@@ -76,7 +76,6 @@ static struct ctl_table printk_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
- {}
};

void __init printk_sysctl_init(void)

--
2.30.2


Subject: [PATCH v2 10/10] bpf: Remove the now superfluous sentinel elements from ctl_table array

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_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.

Acked-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
---
kernel/bpf/syscall.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0ed286b8a0f0..2790deabf639 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -5727,7 +5727,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


Subject: [PATCH v2 09/10] delayacct: Remove the now superfluous sentinel elements from ctl_table array

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_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

Signed-off-by: Joel Granados <[email protected]>
---
kernel/delayacct.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 6f0c358e73d8..e039b0f99a0b 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -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)

--
2.30.2


Subject: [PATCH v2 08/10] kprobes: Remove the now superfluous sentinel elements from ctl_table array

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_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

Acked-by: "Masami Hiramatsu (Google)" <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
---
kernel/kprobes.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index d5a0ee40bf66..1e0ea688cf7f 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -968,7 +968,6 @@ static struct ctl_table kprobe_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
- {}
};

static void __init kprobe_sysctls_init(void)

--
2.30.2


Subject: [PATCH v2 06/10] scheduler: Remove the now superfluous sentinel elements from ctl_table array

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_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

Acked-by: "Peter Zijlstra (Intel)" <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
---
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(-)

diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c
index 991fc9002535..db68a964e34e 100644
--- a/kernel/sched/autogroup.c
+++ b/kernel/sched/autogroup.c
@@ -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)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a708d225c28e..5631d0ec161b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4708,7 +4708,6 @@ static struct ctl_table sched_core_sysctls[] = {
.extra2 = SYSCTL_FOUR,
},
#endif /* CONFIG_NUMA_BALANCING */
- {}
};
static int __init sched_core_sysctl_init(void)
{
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index b28114478b82..58cf9defc3b9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -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)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d7a3c63a2171..8f5f016ebc46 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -157,7 +157,6 @@ static struct ctl_table sched_fair_sysctls[] = {
.extra1 = SYSCTL_ZERO,
},
#endif /* CONFIG_NUMA_BALANCING */
- {}
};

static int __init sched_fair_sysctl_init(void)
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 6aaf0a3d6081..350f4e8b3b2f 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -56,7 +56,6 @@ static struct ctl_table sched_rt_sysctls[] = {
.mode = 0644,
.proc_handler = sched_rr_handler,
},
- {}
};

static int __init sched_rt_sysctl_init(void)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 10d1391e7416..e3a354173005 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -322,7 +322,6 @@ static struct ctl_table sched_energy_aware_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
- {}
};

static int __init sched_energy_aware_sysctl_init(void)

--
2.30.2


2024-01-04 15:08:50

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH v2 00/10] sysctl: Remove sentinel elements from kernel dir

On Thu, Jan 04, 2024 at 04:02:21PM +0100, Joel Granados via B4 Relay wrote:
> From: Joel Granados <[email protected]>
>
> What?

The reason I wanted you to do the sentinel removal before the split was
so that there weren't two rounds of patches. Ironically, because you
refused to do it that way, not only are there two rounds of patches, but
I'm being cc'd on all of them, so I get all the $%*^ emails twice.

Please at least stop cc'ing me.

Subject: [PATCH v2 05/10] seccomp: Remove the now superfluous sentinel elements from ctl_table array

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_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.

Acked-by: Kees Cook <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
---
kernel/seccomp.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 255999ba9190..b727b4351c1b 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -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)

--
2.30.2


Subject: [PATCH v2 03/10] ftrace: Remove the now superfluous sentinel elements from ctl_table array

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_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

Acked-by: "Masami Hiramatsu (Google)" <[email protected]>
Acked-by: "Steven Rostedt (Google)" <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
---
kernel/trace/ftrace.c | 1 -
kernel/trace/trace_events_user.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8de8bec5f366..fd40d02a23c7 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -8264,7 +8264,6 @@ static struct ctl_table ftrace_sysctls[] = {
.mode = 0644,
.proc_handler = ftrace_enable_sysctl,
},
- {}
};

static int __init ftrace_sysctl_init(void)
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 9365ce407426..b15a103bb11d 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -2746,7 +2746,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)

--
2.30.2


2024-01-04 15:23:50

by Joel Granados

[permalink] [raw]
Subject: Re: [PATCH v2 00/10] sysctl: Remove sentinel elements from kernel dir

On Thu, Jan 04, 2024 at 03:05:42PM +0000, Matthew Wilcox wrote:
> On Thu, Jan 04, 2024 at 04:02:21PM +0100, Joel Granados via B4 Relay wrote:
> > From: Joel Granados <[email protected]>
> >
> > What?
>
> The reason I wanted you to do the sentinel removal before the split was
> so that there weren't two rounds of patches. Ironically, because you
> refused to do it that way, not only are there two rounds of patches, but
> I'm being cc'd on all of them, so I get all the $%*^ emails twice.
>
> Please at least stop cc'ing me.
Will do

--

Joel Granados


Attachments:
(No filename) (581.00 B)
signature.asc (673.00 B)
Download all attachments