Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2557820ybv; Mon, 24 Feb 2020 07:23:14 -0800 (PST) X-Google-Smtp-Source: APXvYqz8hiODBiFGViF9iYlsLvWQxtqbiS3zI7Ja/XhtRtW9HDlpBB5KEVY4Q+StsOCYsWYa1MRU X-Received: by 2002:a05:6808:5d1:: with SMTP id d17mr13204445oij.129.1582557794120; Mon, 24 Feb 2020 07:23:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582557794; cv=none; d=google.com; s=arc-20160816; b=tgSgZQgCFRPGuepPsnWJHgE7kwSPpHR0jfJYQiHN/2eko8JqcaJ0aZzHUkSBaYKlLj 5ymiX+9HShXLICF3EzRlcBYGBwuCLIi8LCKFp1Z1GO6aX3xxYzhtoMUsNGh7XWK1wigG da/zr3y77nypIFp8aY/CYc9I7uL+BPhMkuQkUjIJIPBD9SfjjBwx+RYJKk4CrOYyp9u8 eEZeVL4TmY5VzOX8v6k4pTHbqA5v/7ithXS1638A1DIZLYbcy1udRGL0vsJCV7MHRD69 2MgeQE25xiHOxDN6ryBiBPnMWIVW6XBHX2L1KNJVc+iYKN229ZvWpBEgEhSFBHEs/wQP wYNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=tku21Yx/AT2mXiqH2kU7a7leS1wSZz2z7kSMQeoZYKA=; b=GIPa1khvlFBDlQpR/L0cA07fT974mf7FsRopH3rmTePRIQRHHL33KDIFK5dUmMy8ry 7l6Tt6nE0XhyRdnZtvB02COclOxM44KidoqRkVKaqM2kmV/lHap/yhJuXnp5WOOYxhN2 tHePZbyyOMoY84REuG+QDsNzVkqEUopZ6s3EOta+d0MR+DXKVWZ1p+gR1HWtk43CBfEX 0hYfmuFq2JBfBQ5TNLWRqLiiaEPAc45DE7qMJ11HbCHvgeotBf/SKTpcsHlGDsvmGSoD MyQjrfw27COrviPzr3vSPGmjsPb7f7qW8ouD0Zme8CERkLVovBcLiJwuOM00YfI4gx7s dmhQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x197si5152181oix.174.2020.02.24.07.23.01; Mon, 24 Feb 2020 07:23:14 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728209AbgBXPVV (ORCPT + 99 others); Mon, 24 Feb 2020 10:21:21 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:50379 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727474AbgBXPVI (ORCPT ); Mon, 24 Feb 2020 10:21:08 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j6FX5-0005q9-Qq; Mon, 24 Feb 2020 16:20:31 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 75EC61C213D; Mon, 24 Feb 2020 16:20:31 +0100 (CET) Date: Mon, 24 Feb 2020 15:20:31 -0000 From: "tip-bot2 for Vincent Guittot" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Take into account runnable_avg to classify group Cc: Vincent Guittot , Mel Gorman , Ingo Molnar , "Dietmar Eggemann" , Peter Zijlstra , Juri Lelli , Steven Rostedt , Valentin Schneider , Phil Auld , Hillf Danton , x86 , LKML In-Reply-To: <20200224095223.13361-10-mgorman@techsingularity.net> References: <20200224095223.13361-10-mgorman@techsingularity.net> MIME-Version: 1.0 Message-ID: <158255763115.28353.13296779966078754559.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 070f5e860ee2bf588c99ef7b4c202451faa48236 Gitweb: https://git.kernel.org/tip/070f5e860ee2bf588c99ef7b4c202451faa48236 Author: Vincent Guittot AuthorDate: Mon, 24 Feb 2020 09:52:19 Committer: Ingo Molnar CommitterDate: Mon, 24 Feb 2020 11:36:37 +01:00 sched/fair: Take into account runnable_avg to classify group Take into account the new runnable_avg signal to classify a group and to mitigate the volatility of util_avg in face of intensive migration or new task with random utilization. Signed-off-by: Vincent Guittot Signed-off-by: Mel Gorman Signed-off-by: Ingo Molnar Reviewed-by: "Dietmar Eggemann " Acked-by: Peter Zijlstra Cc: Juri Lelli Cc: Steven Rostedt Cc: Valentin Schneider Cc: Phil Auld Cc: Hillf Danton Link: https://lore.kernel.org/r/20200224095223.13361-10-mgorman@techsingularity.net --- kernel/sched/fair.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 49b36d6..87521ac 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5469,6 +5469,24 @@ static unsigned long cpu_runnable(struct rq *rq) return cfs_rq_runnable_avg(&rq->cfs); } +static unsigned long cpu_runnable_without(struct rq *rq, struct task_struct *p) +{ + struct cfs_rq *cfs_rq; + unsigned int runnable; + + /* Task has no contribution or is new */ + if (cpu_of(rq) != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) + return cpu_runnable(rq); + + cfs_rq = &rq->cfs; + runnable = READ_ONCE(cfs_rq->avg.runnable_avg); + + /* Discount task's runnable from CPU's runnable */ + lsub_positive(&runnable, p->se.avg.runnable_avg); + + return runnable; +} + static unsigned long capacity_of(int cpu) { return cpu_rq(cpu)->cpu_capacity; @@ -7752,7 +7770,8 @@ struct sg_lb_stats { unsigned long avg_load; /*Avg load across the CPUs of the group */ unsigned long group_load; /* Total load over the CPUs of the group */ unsigned long group_capacity; - unsigned long group_util; /* Total utilization of the group */ + unsigned long group_util; /* Total utilization over the CPUs of the group */ + unsigned long group_runnable; /* Total runnable time over the CPUs of the group */ unsigned int sum_nr_running; /* Nr of tasks running in the group */ unsigned int sum_h_nr_running; /* Nr of CFS tasks running in the group */ unsigned int idle_cpus; @@ -7973,6 +7992,10 @@ group_has_capacity(unsigned int imbalance_pct, struct sg_lb_stats *sgs) if (sgs->sum_nr_running < sgs->group_weight) return true; + if ((sgs->group_capacity * imbalance_pct) < + (sgs->group_runnable * 100)) + return false; + if ((sgs->group_capacity * 100) > (sgs->group_util * imbalance_pct)) return true; @@ -7998,6 +8021,10 @@ group_is_overloaded(unsigned int imbalance_pct, struct sg_lb_stats *sgs) (sgs->group_util * imbalance_pct)) return true; + if ((sgs->group_capacity * imbalance_pct) < + (sgs->group_runnable * 100)) + return true; + return false; } @@ -8092,6 +8119,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, sgs->group_load += cpu_load(rq); sgs->group_util += cpu_util(i); + sgs->group_runnable += cpu_runnable(rq); sgs->sum_h_nr_running += rq->cfs.h_nr_running; nr_running = rq->nr_running; @@ -8367,6 +8395,7 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd, sgs->group_load += cpu_load_without(rq, p); sgs->group_util += cpu_util_without(i, p); + sgs->group_runnable += cpu_runnable_without(rq, p); local = task_running_on_cpu(i, p); sgs->sum_h_nr_running += rq->cfs.h_nr_running - local;