[patch 17/45] posix-cpu-timers: Make k_itimer::it_active consistent
From: Thomas Gleixner
Date: Tue Jun 06 2023 - 10:38:38 EST
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@xxxxxxxxxxxxx>
---
kernel/time/posix-cpu-timers.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -453,6 +453,7 @@ static void disarm_timer(struct k_itimer
struct cpu_timer *ctmr = &timer->it.cpu;
struct posix_cputimer_base *base;
+ timer->it_active = 0;
if (!cpu_timer_dequeue(ctmr))
return;
@@ -559,6 +560,7 @@ static void arm_timer(struct k_itimer *t
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;
@@ -668,6 +670,7 @@ static int posix_cpu_timer_set(struct k_
ret = TIMER_RETRY;
} else {
cpu_timer_dequeue(ctmr);
+ timer->it_active = 0;
}
/*
@@ -787,6 +790,7 @@ static u64 collect_timerqueue(struct tim
while ((next = timerqueue_getnext(head))) {
struct cpu_timer *ctmr;
+ struct k_itimer *ktmr;
u64 expires;
ctmr = container_of(next, struct cpu_timer, node);
@@ -799,6 +803,8 @@ static u64 collect_timerqueue(struct tim
/* See posix_cpu_timer_wait_running() */
rcu_assign_pointer(ctmr->handling, current);
cpu_timer_dequeue(ctmr);
+ ktmr = container_of(ctmr, struct k_itimer, it.cpu);
+ ktmr->it_active = 0;
list_add_tail(&ctmr->elist, firing);
}