Skip to contentSkip to conversation

sched/fair: Update rq clock before updating nohz cpu load

PATCH In review Matt Fleming 3 participants 3 messages May 3, 2016 – May 5, 2016 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/fair: Update rq clock before updating nohz cpu load

If we're accessing rq_clock() (e.g. in sched_avg_update()) we should update the rq clock before calling cpu_load_update(), otherwise any time calculations will be stale.

All other paths currently call update_rq_clock().

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Rik van Riel <[email protected]>
---
 kernel/sched/fair.c | 1 +
 1 file changed, 1 insertion(+)
kernel/sched/fair.c +1 -0
index b8a33abce650..aa9ba82f0d7c 100644
@@ -4723,6 +4723,7 @@ void cpu_load_update_nohz_stop(void)
 
 	load = weighted_cpuload(cpu_of(this_rq));
 	raw_spin_lock(&this_rq->lock);
+	update_rq_clock(this_rq);
 	cpu_load_update_nohz(this_rq, curr_jiffies, load);
 	raw_spin_unlock(&this_rq->lock);
 }
Signature · 1 line
2.7.3
Reviewed-by on v1 1/1
#1 lore raw

2016-05-04 3:46 GMT+08:00 Matt Fleming <[email protected]>:

Quoted 6 lines

If we're accessing rq_clock() (e.g. in sched_avg_update()) we should update the rq clock before calling cpu_load_update(), otherwise any time calculations will be stale.

All other paths currently call update_rq_clock().

Quoted 8 lines
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Rik van Riel <[email protected]>
Quoted 19 lines
---
 kernel/sched/fair.c | 1 +
 1 file changed, 1 insertion(+)
kernel/sched/fair.c +1 -1
index b8a33abce650..aa9ba82f0d7c 100644
@@ -4723,6 +4723,7 @@ void cpu_load_update_nohz_stop(void)
 
        load = weighted_cpuload(cpu_of(this_rq));
        raw_spin_lock(&this_rq->lock);
+       update_rq_clock(this_rq);
        cpu_load_update_nohz(this_rq, curr_jiffies, load);
        raw_spin_unlock(&this_rq->lock);
 }
--

2.7.3

Signature · 2 lines
Regards,
Wanpeng Li
#2 lore raw

[tip:sched/core] sched/fair: Update rq clock before updating nohz CPU load

In reply to Matt Fleming
sched/fair: Update rq clock before updating nohz CPU load
Commit-ID:  b52fad2db5d792d89975cebf2fe1646a7af28ed0
Gitweb:     http://git.kernel.org/tip/b52fad2db5d792d89975cebf2fe1646a7af28ed0
Author:     Matt Fleming <[email protected]>
AuthorDate: Tue, 3 May 2016 20:46:54 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 May 2016 09:41:09 +0200

sched/fair: Update rq clock before updating nohz CPU load

If we're accessing rq_clock() (e.g. in sched_avg_update()) we should update the rq clock before calling cpu_load_update(), otherwise any time calculations will be stale.

All other paths currently call update_rq_clock().

---
 kernel/sched/fair.c | 1 +
 1 file changed, 1 insertion(+)
kernel/sched/fair.c +1 -0
index 8c381a6..7a00c7c 100644
@@ -4724,6 +4724,7 @@ void cpu_load_update_nohz_stop(void)
 
 	load = weighted_cpuload(cpu_of(this_rq));
 	raw_spin_lock(&this_rq->lock);
+	update_rq_clock(this_rq);
 	cpu_load_update_nohz(this_rq, curr_jiffies, load);
 	raw_spin_unlock(&this_rq->lock);
 }