public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled
@ 2025-06-07 11:41 Liya Huang
  2025-06-12 13:22 ` 1425075683
  2025-06-13 16:53 ` Thomas Gleixner
  0 siblings, 2 replies; 3+ messages in thread
From: Liya Huang @ 2025-06-07 11:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liya Huang

    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")

---
Signed-off-by: Liya Huang <1425075683@qq.com>
---
 kernel/fork.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 168681fc4b25a9fddcb90ce155c027551455f4ee..9632e863c17b44424fadc40b2445034ec5cd20d6 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -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,
-- 
Liya Huang <1425075683@qq.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled
  2025-06-07 11:41 [PATCH] posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled Liya Huang
@ 2025-06-12 13:22 ` 1425075683
  2025-06-13 16:53 ` Thomas Gleixner
  1 sibling, 0 replies; 3+ messages in thread
From: 1425075683 @ 2025-06-12 13:22 UTC (permalink / raw)
  To: 1425075683; +Cc: nico, tglx, linux-kernel

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.

---
diff --git a/kernel/fork.c b/kernel/fork.c
index 168681fc4b25a9fddcb90ce155c027551455f4ee..9632e863c17b44424fadc40b2445034ec5cd20d6 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -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 <1425075683@qq.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled
  2025-06-07 11:41 [PATCH] posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled Liya Huang
  2025-06-12 13:22 ` 1425075683
@ 2025-06-13 16:53 ` Thomas Gleixner
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2025-06-13 16:53 UTC (permalink / raw)
  To: Liya Huang, linux-kernel; +Cc: Liya Huang

On Sat, Jun 07 2025 at 19:41, Liya Huang wrote:
>     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.

I have no idea what you are trying to say here. See below.

> 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")

Can you please format your change logs properly as everybody else
does? These indents provide zero value.

> ---
> Signed-off-by: Liya Huang <1425075683@qq.com>
> ---
>  kernel/fork.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 168681fc4b25a9fddcb90ce155c027551455f4ee..9632e863c17b44424fadc40b2445034ec5cd20d6 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -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

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-13 16:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-07 11:41 [PATCH] posix-timers: omit posix_cpu_timers_init_group when CONFIG_POSIX_TIMERS is disabled Liya Huang
2025-06-12 13:22 ` 1425075683
2025-06-13 16:53 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox