[patch 6/7] tick/sched: Release seqcount before invoking calc_load_global()

From: Thomas Gleixner
Date: Tue Nov 17 2020 - 09:24:36 EST


calc_load_global() does not need the sequence count protection.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/time/tick-sched.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -20,6 +20,7 @@
#include <linux/sched/clock.h>
#include <linux/sched/stat.h>
#include <linux/sched/nohz.h>
+#include <linux/sched/loadavg.h>
#include <linux/module.h>
#include <linux/irq_work.h>
#include <linux/posix-timers.h>
@@ -107,7 +108,8 @@ static void tick_do_update_jiffies64(kti
tick_period);
}

- do_timer(ticks);
+ /* Advance jiffies to complete the jiffies_seq protected job */
+ jiffies_64 += ticks;

/*
* Keep the tick_next_period variable up to date. WRITE_ONCE()
@@ -116,7 +118,15 @@ static void tick_do_update_jiffies64(kti
WRITE_ONCE(tick_next_period,
ktime_add(last_jiffies_update, tick_period));

+ /*
+ * Release the sequence count. calc_global_load() below is not
+ * protected by it, but jiffies_lock needs to be held to prevent
+ * concurrent invocations.
+ */
write_seqcount_end(&jiffies_seq);
+
+ calc_global_load();
+
raw_spin_unlock(&jiffies_lock);
update_wall_time();
}