Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2248627ybv; Mon, 24 Feb 2020 01:55:43 -0800 (PST) X-Google-Smtp-Source: APXvYqx5TJ1IAKEfIABz8CicbLb2IjPnfSO/WNT8whIoyLh7yQSxl0VSL2O3I0AhehIr4049R7wy X-Received: by 2002:aca:ba55:: with SMTP id k82mr11542168oif.94.1582538143355; Mon, 24 Feb 2020 01:55:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582538143; cv=none; d=google.com; s=arc-20160816; b=ZqhA3GrAOpaIgDerOV3gWryY5uXIaDY3cwS46rA10CWkCFfHOm3+zgRhRwyR2hJC+8 JboA3kGWrbxa/yISdfiPPoLIfRM4UqSV+i7z4yvjej0Fb1rQ28ooGrVnn9PhAyXwmqSy 9nokakmostNXps+HAkpa5r/fMEQQefjQjmZOn5oTsEJjNWKDR1ajUj4n07TfYYe0yxXH LryaO5nERBjRA6cz+0018MDj5VYu9AyLIeisskBQk8Xkthwiq2o/HYf4tRMStzx/SOi/ 8MGZL4a2rW8gmnBc71KJoU/yqgQqQO1vxfYCDEJvIRYwY7WA7wgoX0P1QPgN3JWpPYua oBtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=sJmHQWyqe730kYbPs2Jq09OVmZUITqUu3Gp9J4HqdUI=; b=cWBSCVQXAETKgQE3YUGVIF9EfoMy0JDrTbGTh7yR9hNdGBr5IMfvn2tBQPhBVJUDu7 hiZbsZsENpfBq4w1+keXsiBune0YUgFp9+LI/m3dekB/Z/x3OnthqhmtQF0RfVPTvhl9 eFjg8fW6IcXx6PiBNWInyzHXePGbC0ko6D04m+iKQV0PiOGYsQNvngSs7y2lRh11lTEt B7wIa8OwlFRlUde0WBxBXBU98FiOoNjYjG65aKstLCV03FxeeQ+8CTijVg0qVqnawBt3 MIfcVGeo4Wkt7OkZAPLIboRx6HyZj9qGHyhq6UUT0e4AFgSSZ7TatWbOlFp/Z+OSxh7/ fcSQ== 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 j2si5426019otr.255.2020.02.24.01.55.31; Mon, 24 Feb 2020 01:55:43 -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 S1727673AbgBXJyJ (ORCPT + 99 others); Mon, 24 Feb 2020 04:54:09 -0500 Received: from outbound-smtp08.blacknight.com ([46.22.139.13]:54279 "EHLO outbound-smtp08.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbgBXJyJ (ORCPT ); Mon, 24 Feb 2020 04:54:09 -0500 Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp08.blacknight.com (Postfix) with ESMTPS id 73A9C1C359D for ; Mon, 24 Feb 2020 09:54:07 +0000 (GMT) Received: (qmail 25002 invoked from network); 24 Feb 2020 09:54:07 -0000 Received: from unknown (HELO stampy.112glenside.lan) (mgorman@techsingularity.net@[84.203.18.57]) by 81.17.254.9 with ESMTPA; 24 Feb 2020 09:54:07 -0000 From: Mel Gorman To: Peter Zijlstra Cc: Ingo Molnar , Vincent Guittot , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Valentin Schneider , Phil Auld , Hillf Danton , LKML , Mel Gorman Subject: [PATCH 09/13] sched/fair: Take into account runnable_avg to classify group Date: Mon, 24 Feb 2020 09:52:19 +0000 Message-Id: <20200224095223.13361-10-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200224095223.13361-1-mgorman@techsingularity.net> References: <20200224095223.13361-1-mgorman@techsingularity.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Guittot 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 Reviewed-by: "Dietmar Eggemann " Signed-off-by: Mel Gorman --- 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 24fbbb588df2..8ce9a04e7efb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5470,6 +5470,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; @@ -7753,7 +7771,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; @@ -7974,6 +7993,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; @@ -7999,6 +8022,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; } @@ -8093,6 +8120,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; @@ -8368,6 +8396,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; -- 2.16.4