[PATCH v2 5/5] timer_migration: Spare write when nothing changed

Anna-Maria Behnsen posted 5 patches 1 year, 5 months ago
[PATCH v2 5/5] timer_migration: Spare write when nothing changed
Posted by Anna-Maria Behnsen 1 year, 5 months ago
The wakeup value is written unconditionally in tmigr_cpu_new_timer(). When
there was no new next timer expiry that needs to be propagated, then the
value that was read before is written. This is not required.

Move write to the place where wakeup value could have changed.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 kernel/time/timer_migration.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 7971512a60b0..3fb47e4b4ce4 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1248,14 +1248,13 @@ u64 tmigr_cpu_new_timer(u64 nextexp)
 		if (nextexp != tmc->cpuevt.nextevt.expires ||
 		    tmc->cpuevt.ignore) {
 			ret = tmigr_new_timer(tmc, nextexp);
+			/*
+			 * Make sure the reevaluation of timers in idle path
+			 * will not miss an event.
+			 */
+			WRITE_ONCE(tmc->wakeup, ret);
 		}
 	}
-	/*
-	 * Make sure the reevaluation of timers in idle path will not miss an
-	 * event.
-	 */
-	WRITE_ONCE(tmc->wakeup, ret);
-
 	trace_tmigr_cpu_new_timer_idle(tmc, nextexp);
 	raw_spin_unlock(&tmc->lock);
 	return ret;

-- 
2.39.2
Re: [PATCH v2 5/5] timer_migration: Spare write when nothing changed
Posted by Frederic Weisbecker 1 year, 5 months ago
Le Mon, Jun 24, 2024 at 04:53:57PM +0200, Anna-Maria Behnsen a écrit :
> The wakeup value is written unconditionally in tmigr_cpu_new_timer(). When
> there was no new next timer expiry that needs to be propagated, then the
> value that was read before is written. This is not required.
> 
> Move write to the place where wakeup value could have changed.
> 
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>