Skip to content

Commit

Permalink
posix-cpu-timers: Make k_itimer::it_active consistent
Browse files Browse the repository at this point in the history
Posix CPU timers are not updating k_itimer::it_active which makes it
impossible to base decisions in the common posix timer code on it.

Update it when queueing or dequeueing posix CPU timers.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
  • Loading branch information
Thomas Gleixner authored and Frederic Weisbecker committed Jul 29, 2024
1 parent 20f1338 commit 24aea4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/time/posix-cpu-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ static void disarm_timer(struct k_itimer *timer, struct task_struct *p)
struct cpu_timer *ctmr = &timer->it.cpu;
struct posix_cputimer_base *base;

timer->it_active = 0;
if (!cpu_timer_dequeue(ctmr))
return;

Expand Down Expand Up @@ -559,6 +560,7 @@ static void arm_timer(struct k_itimer *timer, struct task_struct *p)
struct cpu_timer *ctmr = &timer->it.cpu;
u64 newexp = cpu_timer_getexpires(ctmr);

timer->it_active = 1;
if (!cpu_timer_enqueue(&base->tqhead, ctmr))
return;

Expand All @@ -584,6 +586,7 @@ static void cpu_timer_fire(struct k_itimer *timer)
{
struct cpu_timer *ctmr = &timer->it.cpu;

timer->it_active = 0;
if (unlikely(timer->sigq == NULL)) {
/*
* This a special case for clock_nanosleep,
Expand Down Expand Up @@ -668,6 +671,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
ret = TIMER_RETRY;
} else {
cpu_timer_dequeue(ctmr);
timer->it_active = 0;
}

/*
Expand Down

0 comments on commit 24aea4c

Please sign in to comment.