]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
posix-timers: Store PID type in the timer
authorThomas Gleixner <tglx@linutronix.de>
Tue, 5 Nov 2024 08:14:41 +0000 (09:14 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 7 Nov 2024 01:14:44 +0000 (02:14 +0100)
instead of re-evaluating the signal delivery mode everywhere.

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.519086500@linutronix.de
include/linux/posix-timers.h
kernel/time/posix-timers.c

index 200098d27cc04065f216aacf18520f0d16732aaa..947176582de9e5d59657cce76a7505d8298ce9ab 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/alarmtimer.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
+#include <linux/pid.h>
 #include <linux/posix-timers_types.h>
 #include <linux/rcuref.h>
 #include <linux/spinlock.h>
@@ -180,6 +181,7 @@ struct k_itimer {
        s64                     it_overrun_last;
        unsigned int            it_signal_seq;
        int                     it_sigev_notify;
+       enum pid_type           it_pid_type;
        ktime_t                 it_interval;
        struct signal_struct    *it_signal;
        union {
index 53bd3c4de92c5a5c8b9f7652dfce7ca808efdc29..f18d64c7cd3bdc5b0b81e662bca6dd612b7b67a2 100644 (file)
@@ -298,7 +298,6 @@ out:
 int posix_timer_queue_signal(struct k_itimer *timr)
 {
        enum posix_timer_state state = POSIX_TIMER_DISARMED;
-       enum pid_type type;
        int ret;
 
        lockdep_assert_held(&timr->it_lock);
@@ -308,8 +307,7 @@ int posix_timer_queue_signal(struct k_itimer *timr)
 
        timr->it_status = state;
 
-       type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID;
-       ret = send_sigqueue(timr->sigq, timr->it_pid, type, timr->it_signal_seq);
+       ret = send_sigqueue(timr->sigq, timr->it_pid, timr->it_pid_type, timr->it_signal_seq);
        /* If we failed to send the signal the timer stops. */
        return ret > 0;
 }
@@ -496,6 +494,11 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
                new_timer->it_pid = get_pid(task_tgid(current));
        }
 
+       if (new_timer->it_sigev_notify & SIGEV_THREAD_ID)
+               new_timer->it_pid_type = PIDTYPE_PID;
+       else
+               new_timer->it_pid_type = PIDTYPE_TGID;
+
        new_timer->sigq->info.si_tid   = new_timer->it_id;
        new_timer->sigq->info.si_code  = SI_TIMER;