[patch V2 08/50] posix-cpu-timers: Save interval only for armed timers

Thomas Gleixner posted 50 patches 1 year, 8 months ago
There is a newer version of this series
[patch V2 08/50] posix-cpu-timers: Save interval only for armed timers
Posted by Thomas Gleixner 1 year, 8 months ago
There is no point to return the interval for timers which have been
disarmed.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
V2: Split out into new patch to make review simpler - Frederic
---
 kernel/time/posix-cpu-timers.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -809,17 +809,15 @@ static void posix_cpu_timer_get(struct k
 
 	rcu_read_lock();
 	p = cpu_timer_task_rcu(timer);
-	if (p) {
+	if (p && cpu_timer_getexpires(&timer->it.cpu)) {
 		itp->it_interval = ktime_to_timespec64(timer->it_interval);
 
-		if (cpu_timer_getexpires(&timer->it.cpu)) {
-			if (CPUCLOCK_PERTHREAD(timer->it_clock))
-				now = cpu_clock_sample(clkid, p);
-			else
-				now = cpu_clock_sample_group(clkid, p, false);
+		if (CPUCLOCK_PERTHREAD(timer->it_clock))
+			now = cpu_clock_sample(clkid, p);
+		else
+			now = cpu_clock_sample_group(clkid, p, false);
 
-			__posix_cpu_timer_get(timer, itp, now);
-		}
+		__posix_cpu_timer_get(timer, itp, now);
 	}
 	rcu_read_unlock();
 }
Re: [patch V2 08/50] posix-cpu-timers: Save interval only for armed timers
Posted by Anna-Maria Behnsen 1 year, 8 months ago
Thomas Gleixner <tglx@linutronix.de> writes:

> There is no point to return the interval for timers which have been
> disarmed.
>

common_timer_get() returns/updates interval unconditionally - so
behavior then differs.

Thanks,

	Anna-Maria
Re: [patch V2 08/50] posix-cpu-timers: Save interval only for armed timers
Posted by Thomas Gleixner 1 year, 8 months ago
On Thu, Apr 11 2024 at 16:25, Anna-Maria Behnsen wrote:

> Thomas Gleixner <tglx@linutronix.de> writes:
>
>> There is no point to return the interval for timers which have been
>> disarmed.
>>
> common_timer_get() returns/updates interval unconditionally - so
> behavior then differs.

Good catch! We really want to make this consistent.