From patchwork Wed Apr 19 16:29:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 97645 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp402184qgf; Wed, 19 Apr 2017 09:30:10 -0700 (PDT) X-Received: by 10.36.250.4 with SMTP id v4mr21154294ith.13.1492619410144; Wed, 19 Apr 2017 09:30:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e79si3627551itd.46.2017.04.19.09.30.09; Wed, 19 Apr 2017 09:30:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938015AbdDSQ3r (ORCPT + 16 others); Wed, 19 Apr 2017 12:29:47 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:38183 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937966AbdDSQ3o (ORCPT ); Wed, 19 Apr 2017 12:29:44 -0400 Received: by mail-wm0-f45.google.com with SMTP id r190so27228597wme.1 for ; Wed, 19 Apr 2017 09:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tWfr8DZBy5bSY4VnaAo5AL0Qr0o4naJq2Zbb9HxWGiY=; b=LNpSpLx9vmlZ9CfUVF9gh+GwSDdwknXgtFX/6irD+qJVyz6ZH8Gn9mMzBeOFgoo1sP MzwJOP3ZaVJEhhAI6dedndhQgOYNOm9OaRqRExZVrdxtPbckOpDV6GUhEBfC95C3u5zX 3/S7VC5Z2RuiC/j50fm5nwl3QkDIMjwHrV/Ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tWfr8DZBy5bSY4VnaAo5AL0Qr0o4naJq2Zbb9HxWGiY=; b=Za3rHGEvVBW9xUxkjx/UgkoNTyJg1MTWAYdmFuJZNrm0QK4NpqP4Cx4TsL+rxL0alW 6bNdp3PSsI1hfb1VpaxOdzfoSeyaN5QkhX8ElzpRPwUATbtOvHVgOieDp1dFTaALX9Qf HN9oEYSkoU+7SVFaEfg2GY7ANKFbir6mbbq4Cq4RolvNrzlikKiPY/FxE+2eKCPmfB7T 6ZKmdIxfO4s1szHBzCiVJC3iSf2WTtmhYkzryVvXAVGzrD45YvsBK4soSucrTc/7JeRr b+OlcbGiClQNRqTy4qpMY7Wjdojn057J0I35XWH+Wt9jtqXfMGURg640HLU7w5j+ZQ7o 2pCw== X-Gm-Message-State: AN3rC/4qf9mjrZ21IMs8PpnPzdjI4odXiPigCuBbOVjrV3tNLuWRccak BA9SPIrgzFtBWwh8 X-Received: by 10.28.125.137 with SMTP id y131mr18949373wmc.141.1492619382641; Wed, 19 Apr 2017 09:29:42 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:ddb5:fd5c:4a08:a3bc]) by smtp.gmail.com with ESMTPSA id o9sm4451536wmd.4.2017.04.19.09.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Apr 2017 09:29:42 -0700 (PDT) From: Vincent Guittot To: mingo@kernel.org, linux-kernel@vger.kernel.org Cc: dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, yuyang.du@intel.com, pjt@google.com, bsegall@google.com, Vincent Guittot Subject: [PATCH 1/2] sched/cfs: make util/load_avg more stable Date: Wed, 19 Apr 2017 18:29:29 +0200 Message-Id: <1492619370-29246-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492619370-29246-1-git-send-email-vincent.guittot@linaro.org> References: <1492619370-29246-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the current implementation of load/util_avg, we assume that the ongoing time segment has fully elapsed, and util/load_sum is divided by LOAD_AVG_MAX, even if part of the time segment still remains. As a consequence, this remaining part is considered as idle time and generates unexpected variations of util_avg of a busy CPU in the range ]1002..1024[ whereas util_avg should stay at 1023. In order to keep the metric stable, we should not consider the ongoing time segment when computing load/util_avg but only the segments that have already fully elapsed. :if expand("%") == ""|browse confirm w|else|confirm w|endif Suggested-by: Peter Zijlstra Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3f83a35..f74da94 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3017,12 +3017,15 @@ ___update_load_avg(u64 now, int cpu, struct sched_avg *sa, /* * Step 2: update *_avg. */ - sa->load_avg = div_u64(sa->load_sum, LOAD_AVG_MAX); + sa->load_avg = div_u64((sa->load_sum - sa->period_contrib * weight), + (LOAD_AVG_MAX - 1024)); if (cfs_rq) { cfs_rq->runnable_load_avg = - div_u64(cfs_rq->runnable_load_sum, LOAD_AVG_MAX); + div_u64((cfs_rq->runnable_load_sum - sa->period_contrib * weight), + (LOAD_AVG_MAX - 1024)); } - sa->util_avg = sa->util_sum / LOAD_AVG_MAX; + sa->util_avg = (sa->util_sum - (running * sa->period_contrib << SCHED_CAPACITY_SHIFT)) / + (LOAD_AVG_MAX - 1024); return 1; }