From patchwork Thu Aug 1 14:40:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 170382 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5538612ile; Thu, 1 Aug 2019 07:40:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzN3xduv9h8PFozKDDNbUprmQpOdmV26VDr9xwan6nI/bB8rSJaRukFAq77ekkZY1ZEZqSH X-Received: by 2002:a17:90a:cb12:: with SMTP id z18mr8705989pjt.82.1564670446037; Thu, 01 Aug 2019 07:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564670446; cv=none; d=google.com; s=arc-20160816; b=lcmvBiLoYVGvOKFi2K6+B+09ZAMtvT7RyTfLgwt8P7zPZVp++0i1BZxoJgJw1rzoV6 SvGKlZs/amqC9bXVgJ+VsJiHS4YhR211DqdjwXqUI+sfnTMXp0vmjXGLJF0HZxsNu25U ZPuM/6D/H7A/Z1XMOW0JUqTTBY+dtxJdPqvfUPV0ZLq7zZtIlhylwrmmzj2ii2b9aCmB W2EHZJRMcCg8IzytrFlldtEIghP1y5JFzC2RM4mLp0W8JjcRAZ1yTsGT/dHEylfFHTz4 5ch9mdzG/Oj8LL6RZ/40qbpi4YKRbdLwz2ANBBeXe0lGB8nKq2vq3YWY889DKiAi4SpJ OvRg== 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=M2NFLK/zY34Il3CN9ocOI5d4GwkmGixwcSg2zvyFkdU=; b=Qt8dtM7pi2Kd/EbaVlFYhkmF/SQ0UGgaZsI++Tvu9X2L2KKkIJ3Yv47zLTqqD7sx02 UBSJel6Ox9RlE5vBLwgjS4T3+uJ0sTzMQObXk2Edy4+NNAJts7u5INAvtAjXtnpgXFMZ l30kvPmRBmxGEHl5lzlVddr/6P4OaT/znSDuvo1++YE2/8T+ECZNxrwR2GbpvkBHHUDx WDnA9HpyOvneWL7D4Ud1Z6cR5ErtXTC01juqKrf5ZVTztpFVZ8BdmQmkLiP66l0ZOTq6 QSqR7QVFU10Rdv6pDcBatWMw7DxYoueeX46LbIEzHJqJ310ksAUSv6HfRI2cBTRdxupV pgCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AZLgdaUg; 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 a19si39063386pgw.234.2019.08.01.07.40.45; Thu, 01 Aug 2019 07:40:46 -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=AZLgdaUg; 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 S1732229AbfHAOko (ORCPT + 29 others); Thu, 1 Aug 2019 10:40:44 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35868 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731741AbfHAOkk (ORCPT ); Thu, 1 Aug 2019 10:40:40 -0400 Received: by mail-wm1-f66.google.com with SMTP id g67so59336669wme.1 for ; Thu, 01 Aug 2019 07:40:38 -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=M2NFLK/zY34Il3CN9ocOI5d4GwkmGixwcSg2zvyFkdU=; b=AZLgdaUgvzf281Lh9Me9GLJ9HM7ksZx0exWcc3M06YCjvkJgxQRL0eNp8iIJt3CFPg S5lnCeMYzoTmQgu/M5iH0Op2fF5cGGbwjRVWRNO97eSbNfsIM8GtoqBsIA4rpn5TIU+K RpLbzpKHuFN9Su18XVPbbnIfrEBdIdYtxWZuivhFIEDq7R+CX7DmWtuhgIEGCa9P8+sR rYSTPPgOHupwuISVf/+DW5sByd2gxlrwIK30r6pEkaVdwT25cADrM4jhTbOBMZEtA0ld QntChvNFNwHb4wG5xR0osfqq0iPdfvFpgm02ozjN/pOwLVAZeIfTfXkKrx1DVbUS6JgR ntnw== 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=M2NFLK/zY34Il3CN9ocOI5d4GwkmGixwcSg2zvyFkdU=; b=lHjarZNUgHUeFKf/6/dKqu+BotkTh26v3VqcFRpiQolOIzueMDSVdjIA9a7uKAKFer gwvQitFlQYspvpMX7pJ8/t2B7RbqLSHJuOkOU4Y6f4GsCOkEdE/GtijYBqiyjj7T1QEw NCpwy6ulEYodL4JWISJ20Iq3mnThCaJIVkHLWBdFHdtgowEth8MBqyXy8LKOaOZ9a0v0 lf2WYcBSDGTgoeC61pTJ0R4IWIFjGFJYYYrNM5gxui1bh28Uhrqwu/NMYKcUWKAPdAMS qMY5UzyV+/4XiO1sE1UNO5sG7JwHtzD8yCrsCRaQrSmRtulVtWnuzQ/xey0btlYpgnQP r7jA== X-Gm-Message-State: APjAAAVV9oC7OHi1Tfyr1RSvye4JyafP+gy4f5kZQqgZH+OMMGxtHkF+ 11V0v1vkHqhM6ozIAqmDBE/bzdzz4N0= X-Received: by 2002:a7b:c398:: with SMTP id s24mr118537283wmj.53.1564670437791; Thu, 01 Aug 2019 07:40:37 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:f:6020:9865:5ad1:5ff3:80c]) by smtp.gmail.com with ESMTPSA id y10sm58768873wmj.2.2019.08.01.07.40.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Aug 2019 07:40:37 -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, Vincent Guittot Subject: [PATCH v2 7/8] sched/fair: evenly spread tasks when not overloaded Date: Thu, 1 Aug 2019 16:40:23 +0200 Message-Id: <1564670424-26023-8-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564670424-26023-1-git-send-email-vincent.guittot@linaro.org> References: <1564670424-26023-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 dfaf0b8..53e64a7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8654,18 +8654,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 */