From patchwork Fri Oct 18 13:26:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 176835 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp861589ill; Fri, 18 Oct 2019 06:27:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/hPN0ZttGPsnrThbm7y1K5LVUMMahd0jE90gZLuYcrDYhwhoeZ5ArpEISGtp5qh6X9+Mg X-Received: by 2002:a17:906:309b:: with SMTP id 27mr8630279ejv.243.1571405226901; Fri, 18 Oct 2019 06:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571405226; cv=none; d=google.com; s=arc-20160816; b=FRCyAFPYGfjYdTUThWIXfwb1wL3dH7y0658UrR4yFr76aRWzWWnV1NgWNk6YoCRVuE LuioBxBE+RUYv1qP6ml3UTiw9s2rQYBVF4Zg+CnJ3KQ5RUkkModa2eWHCRUaOnM9K+j1 ITDSMct9Cq9bhgdJlGJFFpWR8VrIhNqqKNelDjdhkRXLxApXJyLqwKewaYFAA693l92m agRjlUu+2+F1dXwKgwdnooWRtl0sEmvs7hkdh77BHCbBbA4NQsg/1LBTAmiRc0y1n6Ou jHP3lykJz6z9evwJAANNC15kYWyeY4gdi/tE9ikS+g+oEB0N9NXKxXn/SKTFn3azWEQr 0WnA== 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=U+L99VOS6caLFt+CoaTBRiqHtekpuXrbr4pGYmwWDiE=; b=xbr0blwi8h40Oniggl5JcYm5y6GEYRnaR1OtHmtf4UKMW516XLwlLJoZJtWDlVWwV9 ntih+6uE1WcIRqS4Dp0MYxuI0qaA3HPw/KKtJoI7ZWhwb4Lec4gyg6vo5heJYtFuaTcb uCQrcql8DkWGL1bRtbuegW4YRWGl6chhlKVB+2kNqmpgaYxzFKE5vKSGxC0IPdkTxz5z Zpp2IeoczsLqN1kjUTl0YW9+q6SHX5BZA6EHrSE0BV58o2SXG4YOhKKp1h1Sug3ccp5l zLGlr9lhi65qweqTvIpPF6k8/mcfkk5UDCiLVz24+T6kmO6FLZUlcdRc1+flH0fx8XyI 2+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YexuFZ4f; 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 o32si3789756edc.306.2019.10.18.06.27.06; Fri, 18 Oct 2019 06:27:06 -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=YexuFZ4f; 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 S2410335AbfJRN1B (ORCPT + 26 others); Fri, 18 Oct 2019 09:27:01 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:56134 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410292AbfJRN1A (ORCPT ); Fri, 18 Oct 2019 09:27:00 -0400 Received: by mail-wm1-f66.google.com with SMTP id a6so6169546wma.5 for ; Fri, 18 Oct 2019 06:26:57 -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=U+L99VOS6caLFt+CoaTBRiqHtekpuXrbr4pGYmwWDiE=; b=YexuFZ4fjlY6AevXkLYwKDu06ECkTRx8vSIFlXx6hDq+1v+NVL84yLK2F9YZbhhFxG FXfR5Ko8czlD+FeLKLYoY9Ve/rxWNtsqruSpX0mZBJMXp9pe1oiSc8KPR6wy2SJCuJCH wQxXCJh4t7J5njM9BWDMVuGFItJGfZd7xOiUmzwaRnnw9UqkPPJJw8lqPBXbLmzoAlZw AQvBqx+pW3YfnOkARBIxpcZCNQfSq6co36YadtT5BFN09zMaMkqojXMIQRX+Lboka8Fw mfBRYyX6DfVIUqkxTx/bmo/08rM/gz1lGdpa9xv2YPg0j1ANnF0zUAWThZIhrYkXklhH UIcw== 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=U+L99VOS6caLFt+CoaTBRiqHtekpuXrbr4pGYmwWDiE=; b=JDt6yMQ0j4UONOwZqL384Ghcm3lD+Pqk80jn315ymPy5ZyWBo1laG2IEhJ5f7BqL73 I9oXSNlrujML96/dJEZxBOOU3DmvnWY9vWOdpF5e3heMeSYXSZw7hcwTGYP6cDMjdNBs AP3OEyRCD5b7MpyxVoXHHFEaYZsA4quzSVHClNKe4d4B//uktrKAwJ8AWVhW08Pxkimz yIIvdo996axB0ljEtl1R8fVGQ6W0zwZmhA4YuRCYDumOTSaAn203lDcCsnPWWZUr1/M/ 7h9Oz49wFEb4DgO2qoPu0NrXz0LrcxmPRWTkCks+Mb5PkFIZ1w3hHCo5BWTnlKrPhUqR M6fQ== X-Gm-Message-State: APjAAAWwHni/5VdNRGm07BZPxZd6fCrHrTvHNfzT8bTIws4eDKD3S3QG 18vrHSyePVD1r0wmEu6MmrI30j9W+Dk= X-Received: by 2002:a05:600c:23cc:: with SMTP id p12mr3592277wmb.163.1571405216635; Fri, 18 Oct 2019 06:26:56 -0700 (PDT) Received: from localhost.localdomain (91-160-61-128.subs.proxad.net. [91.160.61.128]) by smtp.gmail.com with ESMTPSA id p15sm5870123wrs.94.2019.10.18.06.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Oct 2019 06:26:55 -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, parth@linux.ibm.com, riel@surriel.com, Vincent Guittot Subject: [PATCH v4 07/11] sched/fair: evenly spread tasks when not overloaded Date: Fri, 18 Oct 2019 15:26:34 +0200 Message-Id: <1571405198-27570-8-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571405198-27570-1-git-send-email-vincent.guittot@linaro.org> References: <1571405198-27570-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 9ac2264..9b8e20d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8601,18 +8601,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 */