Blob Blame History Raw
From: Mike Galbraith <mgalbraith@suse.de>
Date: Wed Aug  2 10:55:41 CEST 2017
Subject: NOHZ_FULL: RT jitter reduction
Patch-mainline: Never, RT specific
References: SLE Realtime Extension

Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
---
 kernel/sched/core.c       |    5 +++--
 kernel/time/clocksource.c |    6 +++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3264,12 +3264,13 @@ u64 scheduler_tick_max_deferment(void)
 	struct rq *rq = this_rq();
 	unsigned long next, now = READ_ONCE(jiffies);
 
-	next = rq->last_sched_tick + HZ;
+	next = (rq->last_sched_tick + HZ) | (rq->clock & 0x3f);
 
 	if (time_before_eq(next, now))
 		return 0;
 
-	return jiffies_to_nsecs(next - now);
+	/* Add noise to avoid CPUs colliding at tick boundaries */
+	return jiffies_to_nsecs(next - now) | (rq->clock & 0xfffff);
 }
 #endif
 
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -278,9 +278,13 @@ static void clocksource_watchdog(unsigne
 	 * to each other.
 	 */
 	next_cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask);
+skip_nohz_full:
 	if (next_cpu >= nr_cpu_ids)
 		next_cpu = cpumask_first(cpu_online_mask);
-
+	if (next_cpu && tick_nohz_full_cpu(next_cpu)) {
+		next_cpu = cpumask_next(next_cpu, cpu_online_mask);
+		goto skip_nohz_full;
+	}
 	/*
 	 * Arm timer if not already pending: could race with concurrent
 	 * pair clocksource_stop_watchdog() clocksource_start_watchdog().