From patchwork Thu Sep 19 07:33:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 174042 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp664220ill; Thu, 19 Sep 2019 00:34:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzSNYfEd7MzkiNabch03+gDYmT95Cr+d95xAmen9BCW3j+0349PDzQaa2hBc56msh9DEnU X-Received: by 2002:a17:907:20eb:: with SMTP id rh11mr12706897ejb.25.1568878457225; Thu, 19 Sep 2019 00:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568878457; cv=none; d=google.com; s=arc-20160816; b=b2TbBIm/t/9SHSEmm98GcQPwJM8r+Zs9TmJjOMNpAB+R3aWCK/6UlGsxAtILVTf4A0 kp2hkGpWOPCK5S5QXrI+WKYbWDtCEt/yDgshgfDKR2VLsuo9PVDyOcck7S3muC+VoC70 J5rmo/NKuQy1dAjUUjgKOTY8txWX6PM+HX4yOZqsRJv8p86zBXRYlRf5W1VRXvS/4ZPO H5iYe1eP2lzGF5NRSJOJ9zB0OQvPQFL4SV9uaD84vT9o0RMfqv2hwm88qyk3nnBsxVas Kv9aqBVDf9Aam2YZYJCZJGNTzVpz2SqRew7xfwi+ipGdovfFUt3r4Bm/Fntgc5yEFw4/ /DGg== 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:dkim-signature; bh=EBLUOB2EXDZsxDF6E6gn9L3xHCrHxfXfVGa48LIRlDY=; b=n7exypyg6wMeTIWeqdY+xz4e1AKvhcKPXufnoOrgO5isrznx0ZhxDSZcczXE+LRpI9 uwkB3PJJV//vAgPh4PmEplx2S6BZuwsYJSmSXvcBxy8IYNop4iScBUxwluL9U2reP+rk ePA95mcoSGPUT100YkrXuZYq3OPG+arI8nzNN+IDmLrsmUsSbXrDztC8tThN1821/l4M beijJ5AVLO1XF26z1toeU3SKazOt9riso//B7zaVI+QfKZqKwBytfQYZneDoEsvskNr0 MPN4Q6onLCz23c/03rgi8gIckoTtq/+pNcFiVb/RboLJvMN4y8pqpOCxKl1nCNsjJloh swbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kWLPydG7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x25si311420edd.350.2019.09.19.00.34.17; Thu, 19 Sep 2019 00:34:17 -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 header.s=google header.b=kWLPydG7; 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 S2388677AbfISHeN (ORCPT + 26 others); Thu, 19 Sep 2019 03:34:13 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55679 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388657AbfISHeL (ORCPT ); Thu, 19 Sep 2019 03:34:11 -0400 Received: by mail-wm1-f65.google.com with SMTP id a6so3048409wma.5 for ; Thu, 19 Sep 2019 00:34:10 -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=EBLUOB2EXDZsxDF6E6gn9L3xHCrHxfXfVGa48LIRlDY=; b=kWLPydG7rKDJilBY5fR43MCB50iZ6fjHCaPSf8iG4jbYCpmgwNMIRGSn1rhTb8MJUV HkGHdW4R/uzQo5p9Ru6uWh63KeB0DI3eYbrB+qbp0DBfKVUmzshM23iSPiG5hluIM6VS z7ch/Puy6hYlu/tDbjFMhpEgQWLx6Drx3qST/mlredIsROxcFxe3wHZobKujOFiyUhtH i9PZOZBLlq1dJyWrlcqAEOL5XTFH0uA56Qm69s0Na8/mxqBTVoFnCf3SJ3QjU2BS2gDd n/iu9EDM4ZiB+pjlrQjk6QECQVjbM4dayHr90rriQQmXHw+KeZY8nwXf2rdstTD+viKQ DCRg== 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=EBLUOB2EXDZsxDF6E6gn9L3xHCrHxfXfVGa48LIRlDY=; b=hWvsz3olBeC5HwJ5FmB45ceai2jEzLBJwNy/WNqcOzSbLGRSBnLV6aVHLMhvrlB4Ey +ZDv7Bhpqq/eVmeK7lRQxpmD2nHlI84s4LSYhXaxVdHsNcdMWGmfP5d5FbKb5eWUVMt3 IzxxxhOjXOv5VhUuo1nrKfGG579Lka0PnjZkBdfbAfRKWa8vaJ366HyovVfpg1Snuq01 uAagrE2bRsQZecDQQ4suhgj7RAPDflxYomayfJlvhWB6OtRm/6nCwTTFUOm5Vh7w/Xdh BpOLNLhqm9NjjrfwgzeNOqe5SnfkWpg5bdP+e41/jxZMcyTbw0fCh0tD/QblM9AiNDH4 ADuA== X-Gm-Message-State: APjAAAUTaaA29t0YTsJeqW/WF7X4AoQ79KmwEPNPJMvtgsiD+0irMdBt hDOlS5jqXf+7tnMxK7yIXMdyV+5NV20= X-Received: by 2002:a7b:c84f:: with SMTP id c15mr1577723wml.52.1568878449259; Thu, 19 Sep 2019 00:34:09 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:d555:8fca:a19c:222c]) by smtp.gmail.com with ESMTPSA id s12sm13300250wra.82.2019.09.19.00.34.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Sep 2019 00:34:06 -0700 (PDT) From: Vincent Guittot To: linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org Cc: pauld@redhat.com, valentin.schneider@arm.com, srikar@linux.vnet.ibm.com, quentin.perret@arm.com, dietmar.eggemann@arm.com, Morten.Rasmussen@arm.com, hdanton@sina.com, Vincent Guittot Subject: [PATCH v3 07/10] sched/fair: evenly spread tasks when not overloaded Date: Thu, 19 Sep 2019 09:33:38 +0200 Message-Id: <1568878421-12301-8-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568878421-12301-1-git-send-email-vincent.guittot@linaro.org> References: <1568878421-12301-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 When there is only 1 cpu per group, using the idle cpus to evenly spread tasks doesn't make sense and nr_running is a better metrics. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 15ec38c..a7c8ee6 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8596,18 +8596,34 @@ static struct sched_group *find_busiest_group(struct lb_env *env) busiest->sum_nr_running > local->sum_nr_running + 1) goto force_balance; - if (busiest->group_type != group_overloaded && - (env->idle == CPU_NOT_IDLE || - local->idle_cpus <= (busiest->idle_cpus + 1))) - /* - * If the busiest group is not overloaded - * and there is no imbalance between this and busiest group - * wrt idle CPUs, it is balanced. The imbalance - * becomes significant if the diff is greater than 1 otherwise - * we might end up to just move the imbalance on another - * group. - */ - goto out_balanced; + if (busiest->group_type != group_overloaded) { + if (env->idle == CPU_NOT_IDLE) + /* + * If the busiest group is not overloaded (and as a + * result the local one too) but this cpu is already + * busy, let another idle cpu try to pull task. + */ + goto out_balanced; + + if (busiest->group_weight > 1 && + local->idle_cpus <= (busiest->idle_cpus + 1)) + /* + * If the busiest group is not overloaded + * and there is no imbalance between this and busiest + * group wrt idle CPUs, it is balanced. The imbalance + * becomes significant if the diff is greater than 1 + * otherwise we might end up to just move the imbalance + * on another group. Of course this applies only if + * there is more than 1 CPU per group. + */ + goto out_balanced; + + if (busiest->sum_h_nr_running == 1) + /* + * busiest doesn't have any tasks waiting to run + */ + goto out_balanced; + } force_balance: /* Looks like there is an imbalance. Compute it */