Commit bd29d773 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Frederic Weisbecker

posix-cpu-timers: Do not arm SIGEV_NONE timers

There is no point in arming SIGEV_NONE timers as they never deliver a
signal. timer_gettime() is handling the expiry time correctly and that's
all SIGEV_NONE timers care about.

Prevent arming them and remove the expiry handler code which just disarms
them.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Reviewed-by: default avatarAnna-Maria Behnsen <anna-maria@linutronix.de>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
parent d471ff39
...@@ -584,12 +584,7 @@ static void cpu_timer_fire(struct k_itimer *timer) ...@@ -584,12 +584,7 @@ static void cpu_timer_fire(struct k_itimer *timer)
{ {
struct cpu_timer *ctmr = &timer->it.cpu; struct cpu_timer *ctmr = &timer->it.cpu;
if ((timer->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) { if (unlikely(timer->sigq == NULL)) {
/*
* User don't want any signal.
*/
cpu_timer_setexpires(ctmr, 0);
} else if (unlikely(timer->sigq == NULL)) {
/* /*
* This a special case for clock_nanosleep, * This a special case for clock_nanosleep,
* not a normal timer from sys_timer_create. * not a normal timer from sys_timer_create.
...@@ -625,6 +620,7 @@ static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *i ...@@ -625,6 +620,7 @@ static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *i
static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
struct itimerspec64 *new, struct itimerspec64 *old) struct itimerspec64 *new, struct itimerspec64 *old)
{ {
bool sigev_none = timer->it_sigev_notify == SIGEV_NONE;
clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock);
u64 old_expires, new_expires, old_incr, val; u64 old_expires, new_expires, old_incr, val;
struct cpu_timer *ctmr = &timer->it.cpu; struct cpu_timer *ctmr = &timer->it.cpu;
...@@ -688,7 +684,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -688,7 +684,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
if (CPUCLOCK_PERTHREAD(timer->it_clock)) if (CPUCLOCK_PERTHREAD(timer->it_clock))
val = cpu_clock_sample(clkid, p); val = cpu_clock_sample(clkid, p);
else else
val = cpu_clock_sample_group(clkid, p, true); val = cpu_clock_sample_group(clkid, p, !sigev_none);
/* Retrieve the previous expiry value if requested. */ /* Retrieve the previous expiry value if requested. */
if (old) { if (old) {
...@@ -708,19 +704,20 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -708,19 +704,20 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
goto out; goto out;
} }
if (new_expires != 0 && !(timer_flags & TIMER_ABSTIME)) { /* Convert relative expiry time to absolute */
if (new_expires && !(timer_flags & TIMER_ABSTIME))
new_expires += val; new_expires += val;
}
/* Set the new expiry time (might be 0) */
cpu_timer_setexpires(ctmr, new_expires);
/* /*
* Install the new expiry time (or zero). * Arm the timer if it is not disabled, the new expiry value has
* For a timer with no notification action, we don't actually * not yet expired and the timer requires signal delivery.
* arm the timer (we'll just fake it for timer_gettime). * SIGEV_NONE timers are never armed.
*/ */
cpu_timer_setexpires(ctmr, new_expires); if (!sigev_none && new_expires && val < new_expires)
if (new_expires != 0 && val < new_expires) {
arm_timer(timer, p); arm_timer(timer, p);
}
unlock_task_sighand(p, &flags); unlock_task_sighand(p, &flags);
/* /*
...@@ -739,7 +736,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, ...@@ -739,7 +736,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
timer->it_overrun_last = 0; timer->it_overrun_last = 0;
timer->it_overrun = -1; timer->it_overrun = -1;
if (val >= new_expires) { if (!sigev_none && val >= new_expires) {
if (new_expires != 0) { if (new_expires != 0) {
/* /*
* The designated time already passed, so we notify * The designated time already passed, so we notify
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment