From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933074AbdBVPS3 (ORCPT ); Wed, 22 Feb 2017 10:18:29 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33735 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933122AbdBVPSJ (ORCPT ); Wed, 22 Feb 2017 10:18:09 -0500 Date: Wed, 22 Feb 2017 16:18:05 +0100 From: Frederic Weisbecker To: Matt Fleming Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Mike Galbraith , Morten Rasmussen , stable@vger.kernel.org, Vincent Guittot Subject: Re: [PATCH v2 1/2] sched/loadavg: Avoid loadavg spikes caused by delayed NO_HZ accounting Message-ID: <20170222151802.GB2576@lerouge> References: <20170217120731.11868-1-matt@codeblueprint.co.uk> <20170217120731.11868-2-matt@codeblueprint.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170217120731.11868-2-matt@codeblueprint.co.uk> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 17, 2017 at 12:07:30PM +0000, Matt Fleming wrote: > 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. > > Fixes: commit 5167e8d ("sched/nohz: Rewrite and fix load-avg computation -- again") > Cc: Peter Zijlstra > Cc: Mike Galbraith > Cc: Morten Rasmussen > Cc: Vincent Guittot Acked-by: Frederic Weisbecker Thanks it's much clearer now!