posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled
Subsystems (3)
PATCH 1/1 posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled
When POSIX timers are disabled (CONFIG_POSIX_TIMERS=n), the helper function posix_cpu_timers_init_group() is effectively a no-op—but it still consumes valuable code space. To avoid generating an empty stub, we should conditionally compile this function out entirely when POSIX timers support is turned off.
This logic was originally introduced in commit b18b6a9cef7f ("timers:
Omit POSIX timer stuff from task_struct when disabled"), but was dropped in commit 244d49e30653 ("posix-cpu-timers: Move state tracking
to struct posix_cputimers")
---
--- kernel/fork.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/fork.c +4 -0
@@ -1883,6 +1883,7 @@ void __cleanup_sighand(struct sighand_struct *sighand) } } +#ifdef CONFIG_POSIX_TIMERS /* * Initialize POSIX timer handling for a thread group. */
@@ -1894,6 +1895,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) cpu_limit =READ_ONCE (sig->rlim[RLIMIT_CPU ].rlim_cur); posix_cputimers_group_init(pct, cpu_limit); } +#else +static inline void posix_cpu_timers_init_group (struct signal_struct *sig) { } +#endif static int copy_signal (unsigned long clone_flags,struct task_struct *tsk) {
---
base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca
change-id: 20250607-posix_cpu_timers_init_group-0439fe81f23a
Best regards,
Signature · 1 line
Liya Huang <[email protected]>
Hi all,
My apologies—I neglected to CC both of you on my last submission. Please find below the same patch, now with the correct CC list.
---
kernel/fork.c +4 -0
@@ -1883,6 +1883,7 @@ void __cleanup_sighand(struct sighand_struct *sighand) } } +#ifdef CONFIG_POSIX_TIMERS /* * Initialize POSIX timer handling for a thread group. */
@@ -1894,6 +1895,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) cpu_limit =READ_ONCE (sig->rlim[RLIMIT_CPU ].rlim_cur); posix_cputimers_group_init(pct, cpu_limit); } +#else +static inline void posix_cpu_timers_init_group (struct signal_struct *sig) { } +#endif static int copy_signal (unsigned long clone_flags,struct task_struct *tsk) {
---
Thanks for your understanding!
–-
Liya Huang <[email protected]>
Quoted 5 lines · Liya Huang
When POSIX timers are disabled (
CONFIG_POSIX_TIMERS=n), the helper functionposix_cpu_timers_init_group()is effectively a no-op—but it still consumes valuable code space. To avoid generating an empty stub, we should conditionally compile this function out entirely when POSIX timers support is turned off.
I have no idea what you are trying to say here. See below.
Quoted 4 lines
This logic was originally introduced in commit
b18b6a9cef7f("timers:
Omit POSIX timer stuff fromtask_structwhen disabled"), but was dropped in commit244d49e30653("posix-cpu-timers: Move state tracking
to structposix_cputimers")
Can you please format your change logs properly as everybody else does? These indents provide zero value.
Quoted 19 lines
---
Signed-off-by Liya Huang <[email protected]>--- kernel/fork.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/fork.c +1
-0@@ -1883,6 +1883,7 @@ void __cleanup_sighand(struct sighand_struct *sighand) } } +#ifdef CONFIG_POSIX_TIMERS /* * Initialize POSIX timer handling for a thread group. */
kernel/fork.c static void posix_cpu_timers_init_group(struct signal_struct *sig) · line 1900
Quoted 6 lines
kernel/fork.c +3
-0@@ -1894,6 +1895,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) cpu_limit =READ_ONCE (sig->rlim[RLIMIT_CPU ].rlim_cur); posix_cputimers_group_init(pct, cpu_limit); } +#else +static inline void posix_cpu_timers_init_group (struct signal_struct *sig) { } +#endif
If CONFIG_POSIX_TIMERS=n then posix_cputimers_group_init() is an empty inline function and the compiler optimizes posix_cpu_timers_init_group() away completely. If it does not, then the compiler wants to be fixed.
And no, we are not adding ugly ifdeffery just because.
Thanks,
tglx