Patch "sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
sched-loadavg-avoid-loadavg-spikes-caused-by-delayed-no_hz-accounting.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
6e5f32f7a43f45ee55c401c0b9585eb01f9629a8Mon Sep 17 00:00:00 2001
From: Matt Fleming <[email protected]>
Date: Fri, 17 Feb 2017 12:07:30 +0000
Subject: sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting
From: Matt Fleming <[email protected]>
commit 6e5f32f7a43f45ee55c401c0b9585eb01f9629a8 upstream.
If we crossed a sample window while in NO_HZ we will add LOAD_FREQ to the pending sample window time on exit, setting the next update not one window into the future, but two.
This situation on exiting NO_HZ is described by:
this_rq->calc_load_update < jiffies < calc_load_update
In this scenario, what we should be doing is:
this_rq->calc_load_update = calc_load_update [ next window ]
But what we actually do is:
this_rq->calc_load_update = calc_load_update + LOAD_FREQ [ next+1 window ]
This has the effect of delaying load average updates for potentially up to ~9seconds.
This can result in huge spikes in the load average values due to per-cpu uninterruptible task counts being out of sync when accumulated across all CPUs.
It's safe to update the per-cpu active count if we wake between sample windows because any load that we left in 'calc_load_idle' will have been zero'd when the idle load was folded in calc_global_load().
This issue is easy to reproduce before,
commit 9d89c257dfb9 ("sched/fair: Rewrite runnable load and utilization average tracking")
just by forking short-lived process pipelines built from ps(1) and grep(1) in a loop. I'm unable to reproduce the spikes after that commit, but the bug still seems to be present from code review.
--- kernel/sched/loadavg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/loadavg.c +2 -2
@@ -201,8 +201,9 @@ void calc_load_exit_idle(void)struct rq *this_rq =this_rq ();/* -* If we're still before the sample window, we're done. +* If we're still before the pending sample window, we're done. */ + this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update))return ;
@@ -211,7 +212,6 @@ void calc_load_exit_idle(void)* accounted through the nohz accounting, so skip the entire deal and * sync up for the next window. */ - this_rq->calc_load_update = calc_load_update;if (time_before (jiffies, this_rq->calc_load_update +10 )) this_rq->calc_load_update +=LOAD_FREQ ; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/sched-loadavg-avoid-loadavg-spikes-caused-by-delayed-no_hz-accounting.patch