2024-05-16 19:13:33

by Costa Shulyupin

[permalink] [raw]
Subject: [PATCH v1 5/7] [NOT-FOR-MERGE] test timers affinity adjustment

There must be no timers on the specified cpu
at the end of timers_resettle_from_cpu.

Signed-off-by: Costa Shulyupin <[email protected]>
---
kernel/time/timer.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 2d15c0e7b0550..b7d253d230453 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -2658,6 +2658,27 @@ int timers_prepare_cpu(unsigned int cpu)
return 0;
}

+static int count_timers(int cpu)
+{
+ struct timer_base *base;
+ int b, v, count = 0;
+
+ for (b = 0; b < NR_BASES; b++) {
+ base = per_cpu_ptr(&timer_bases[b], cpu);
+ raw_spin_lock_irq(&base->lock);
+
+ for (v = 0; v < WHEEL_SIZE; v++) {
+ struct hlist_node *c;
+
+ hlist_for_each(c, base->vectors + v)
+ count++;
+ }
+ raw_spin_unlock_irq(&base->lock);
+ }
+
+ return count;
+}
+
/**
* timers_resettle_from_cpu - resettles timers from
* specified cpu to housekeeping cpus.
@@ -2697,6 +2718,7 @@ void timers_resettle_from_cpu(unsigned int cpu)
raw_spin_unlock_irq(&new_base->lock);
}
local_irq_enable();
+ WARN_ON(count_timers(cpu));
}

int timers_dead_cpu(unsigned int cpu)
--
2.45.0