[patch V2 21/50] posix-cpu-timers: Make k_itimer::it_active consistent

Thomas Gleixner posted 50 patches 1 year, 8 months ago
There is a newer version of this series
[patch V2 21/50] posix-cpu-timers: Make k_itimer::it_active consistent
Posted by Thomas Gleixner 1 year, 8 months ago
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>
---
V2: Move the clearing to cpu_timer_fire() - Frederic
---
 kernel/time/posix-cpu-timers.c |    4 ++++
 1 file changed, 4 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;
 
@@ -584,6 +586,7 @@ static void cpu_timer_fire(struct k_itim
 {
 	struct cpu_timer *ctmr = &timer->it.cpu;
 
+	timer->it_active = 0;
 	if (unlikely(timer->sigq == NULL)) {
 		/*
 		 * This a special case for clock_nanosleep,
@@ -668,6 +671,7 @@ static int posix_cpu_timer_set(struct k_
 		ret = TIMER_RETRY;
 	} else {
 		cpu_timer_dequeue(ctmr);
+		timer->it_active = 0;
 	}
 
 	/*
Re: [patch V2 21/50] posix-cpu-timers: Make k_itimer::it_active consistent
Posted by Anna-Maria Behnsen 1 year, 8 months ago
Thomas Gleixner <tglx@linutronix.de> writes:

> 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>
> ---
> V2: Move the clearing to cpu_timer_fire() - Frederic
> ---
>  kernel/time/posix-cpu-timers.c |    4 ++++
>  1 file changed, 4 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;
>  
> @@ -584,6 +586,7 @@ static void cpu_timer_fire(struct k_itim
>  {
>  	struct cpu_timer *ctmr = &timer->it.cpu;
>  
> +	timer->it_active = 0;
>  	if (unlikely(timer->sigq == NULL)) {
>  		/*
>  		 * This a special case for clock_nanosleep,
> @@ -668,6 +671,7 @@ static int posix_cpu_timer_set(struct k_
>  		ret = TIMER_RETRY;
>  	} else {
>  		cpu_timer_dequeue(ctmr);
> +		timer->it_active = 0;

NIT: you could change the order of the above two commands, then it is in
the same order as the others.

with or without changing the NIT:
Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>