]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
posix-cpu-timers: Use dedicated flag for CPU timer nanosleep
authorThomas Gleixner <tglx@linutronix.de>
Tue, 5 Nov 2024 08:14:35 +0000 (09:14 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 7 Nov 2024 01:14:43 +0000 (02:14 +0100)
POSIX CPU timer nanosleep creates a k_itimer on stack and uses the sigq
pointer to detect the nanosleep case in the expiry function.

Prepare for embedding sigqueue into struct k_itimer by using a dedicated
flag for nanosleep.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20241105064213.238550394@linutronix.de
include/linux/posix-timers.h
kernel/time/posix-cpu-timers.c

index b1de21731a082f73285a4a4bfad50b2cdfdee208..bcd01208d795519f0f5888e00b5a55ddcaf51c29 100644 (file)
@@ -42,6 +42,7 @@ static inline int clockid_to_fd(const clockid_t clk)
  * @pid:       Pointer to target task PID
  * @elist:     List head for the expiry list
  * @firing:    Timer is currently firing
+ * @nanosleep: Timer is used for nanosleep and is not a regular posix-timer
  * @handling:  Pointer to the task which handles expiry
  */
 struct cpu_timer {
@@ -50,6 +51,7 @@ struct cpu_timer {
        struct pid                      *pid;
        struct list_head                elist;
        bool                            firing;
+       bool                            nanosleep;
        struct task_struct __rcu        *handling;
 };
 
index a282a3c0060543f42b290c63921cb09d0ad1f01f..0c441d8c26047b033ff9554502a285cfc2985fc3 100644 (file)
@@ -596,7 +596,7 @@ static void cpu_timer_fire(struct k_itimer *timer)
 
        timer->it_status = POSIX_TIMER_DISARMED;
 
-       if (unlikely(timer->sigq == NULL)) {
+       if (unlikely(ctmr->nanosleep)) {
                /*
                 * This a special case for clock_nanosleep,
                 * not a normal timer from sys_timer_create.
@@ -1493,6 +1493,7 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags,
        timer.it_overrun = -1;
        error = posix_cpu_timer_create(&timer);
        timer.it_process = current;
+       timer.it.cpu.nanosleep = true;
 
        if (!error) {
                static struct itimerspec64 zero_it;