From patchwork Fri Aug 5 15:40:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 73371 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp2002173qga; Fri, 5 Aug 2016 08:42:04 -0700 (PDT) X-Received: by 10.66.14.161 with SMTP id q1mr37429973pac.103.1470411722429; Fri, 05 Aug 2016 08:42:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si21007260pav.72.2016.08.05.08.42.02; Fri, 05 Aug 2016 08:42:02 -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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161577AbcHEPl5 (ORCPT + 27 others); Fri, 5 Aug 2016 11:41:57 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:36802 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161551AbcHEPlw (ORCPT ); Fri, 5 Aug 2016 11:41:52 -0400 Received: by mail-wm0-f53.google.com with SMTP id q128so36129644wma.1 for ; Fri, 05 Aug 2016 08:41:51 -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; bh=dEC7bFEm8j8QLm9I5jtN7Wg1g0ecj5fiSX9S3GbD+go=; b=CtQUrBCqK7I3XPiqygJ57hsjrqVahAdsNwltLMhi0ria1FLE/TV32fmVvYuFCDVkdH oSZ3yo7/ptB7I3mLR3iScxjpfKOcOAKE4yX59J/UVV09UzeS6KzmnO6gHp5lkdNSTdUh SCcbFK/elAnnz3O55Aue7CZdZW0RtBkCBf7zU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dEC7bFEm8j8QLm9I5jtN7Wg1g0ecj5fiSX9S3GbD+go=; b=CLDf80MWgkhQgqRZyiFVYBG1SOkiMRS1ZpbDEGCBR5rAniNzSWyfKg2TNTfCwJ48vq 9xavEAfIAN6uZRR+RYXOgPGgIRUmTwqFT5H86Ap5/PLjb7vE0RB6MLCHRueP6UtVQJfX TEtzwn6Vn/WVh4iAnUnPHULYwXREkDWtDvZPFRprNZkFEwg67zb5GIAzcIKBVGPXsaOE CznPBu5zCszj2z7B24RqiaoNGkLT9myi/q3Kfnkr48cGUB4WfpicJG4MTPlySrQzp1CS o809PwOw65BAoy5jku0s85eMyAKdMwSFXJsNb7el7xVwsmt1HyQU0KA6LZxqj9mF5Z+R m6Zw== X-Gm-Message-State: AEkoous/Hcv8XOX4Av5MDKdfb4cpIQCAEAMegqtaARUsrIPXoD+xP6wnCxXSlJhMvbsHO6Eg X-Received: by 10.28.193.202 with SMTP id r193mr4358414wmf.27.1470411710622; Fri, 05 Aug 2016 08:41:50 -0700 (PDT) Received: from localhost.localdomain ([78.129.231.120]) by smtp.gmail.com with ESMTPSA id gg10sm18406540wjd.4.2016.08.05.08.41.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Aug 2016 08:41:49 -0700 (PDT) From: Leo Yan To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2] sched/fair: refine maximum periods for decay_load Date: Fri, 5 Aug 2016 23:40:59 +0800 Message-Id: <1470411659-28584-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In current code, decay_load() will consider to set load value to zero after passing 32*64 ms. So this means max_load * (0.5^64) ~= 0. Kernel can support maximum number of processes and threads to 2^29 and set task with highest priority with nice=-20 (weight = 88761). So in worst case, one CPU may have maximum load value is: max_load = 2^29 * 88761 < 2^46 In theory after pass 46 periods we can ensure load value to be decayed to zero. So this patch is to change maximum periods from 64 to 46. Signed-off-by: Leo Yan --- kernel/sched/fair.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e342159..bbd01eb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2622,7 +2622,15 @@ static __always_inline u64 decay_load(u64 val, u64 n) if (!n) return val; - else if (unlikely(n > LOAD_AVG_PERIOD * 63)) + /* + * Kernel can support maximum number of processes and threads up to + * 2^29 and task has highest weight 88761 with nice=-20. + * + * maximum load = 2^29 * 88761 < 2^46 + * + * So pass 46 periods can ensure maximum load to be decayed to zero. + */ + else if (unlikely(n >= LOAD_AVG_PERIOD * 46)) return 0; /* after bounds checking we can collapse to 32-bit */