Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1113871pxb; Wed, 6 Apr 2022 09:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqg0VQQTe/WwsBXUzIO/lm2ipkQiUdHCoQqWs2rXhGQse1I1G0NzjTTpzS9Sot+XBaZ6Hs X-Received: by 2002:a65:6e0e:0:b0:399:26d7:a224 with SMTP id bd14-20020a656e0e000000b0039926d7a224mr7608311pgb.437.1649260995280; Wed, 06 Apr 2022 09:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260995; cv=none; d=google.com; s=arc-20160816; b=Jc97GAkqdIT81Ng39o/D6pA5SX0M1LVbLFgyDiDoXsPTJ4Y+CKqS8ZC3mK2gLtTjhS OjM3+0MQV5X2OzJSrvacfTu2DmpyHe5awiUn3vzNw6UaIAVTDFaE9IYRuY5jSVLVqbir 6YNdupP6vlCuf2beg7DlziIct3VtPCF3CoPLIj9YA2FNZub9s8Pra3iuGEm+iXigDcJo PqQJSsYpSbeUaSrAAcoHn8RvG+ByXYrVukpRlN7tk68aX8QLnu1+xvIF9cXdRkdJ+P7e Z1ocvG83x5oCBbJDlO5PsF7ZwGtgVL7gIZsWaG07zfiVhDW/uqvq/eD7Z8KGKqjGKNNW UfcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from:dkim-signature; bh=W1IYkjMUQdZYCUET1UeGta4MM9L17ipJdw8Dgmfkpyw=; b=rMAWpnMFFG58dDtueiqWajixB5n69bG7gm4//CQHLPSb3y4HqezWKI+GkxWQEZosjr M7aO/UIDHf3BK0VAsr3RAXCsbPjeeJg/JysPRgtoEqIH6hw4/amk9kp/39ho0efnpAl4 TtcbfmO5uJRkwFNGfaFAs7NRIc4rMxvaiUB+R8FhHxh9KJl2am3ostPl9COeg2rN3+rV stm8U8Idesu2StKZbIEXCoSXS0SABPgFotnMHnLpWa/tCYVt+VtyLafH0X2C40SXPUxN IQa9KEXvtySXxeXEniPiP/We1/DAH6ULvEet3OqKF09Uipuxe1nJms9Y1tWKcS2t1BJH 99UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Et4N7xK4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b13-20020a65668d000000b003816043f136si15775808pgw.811.2022.04.06.09.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:03:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Et4N7xK4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A22646E601; Wed, 6 Apr 2022 07:49:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235319AbiDFOun (ORCPT + 99 others); Wed, 6 Apr 2022 10:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235248AbiDFOuV (ORCPT ); Wed, 6 Apr 2022 10:50:21 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715265E9857 for ; Wed, 6 Apr 2022 04:23:29 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d15so1657580pll.10 for ; Wed, 06 Apr 2022 04:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id; bh=W1IYkjMUQdZYCUET1UeGta4MM9L17ipJdw8Dgmfkpyw=; b=Et4N7xK4bHak89+cPHZp1nSEK+bpG+KgCEzg6jNz3ydXqMPk31aYkVJ2Z28lRccDbw 8YAJXY/4iN480SVqbhRUocuamQS1/sv6t+BhkWCzaffILyCbRZfPB+Ubay6WatQLuXyB LwnWHjkir59o+yNSyApQFwhrcAZb8IxmRTA37HmResrVPB+WCAZ85gm46qLN63bBMIUY tembVvxxfAV8CGOorTYEt9Iz+VmI3hv14Rs7FYLeMvVPbxzYei6t0z4Wya3RcdnZ/Okw yCJCGdjdWpCk42AnObeo0gHcqJGpJ2sMySYg8rnVMq43yFBhoS6PlIgICUwNmquEfBsA 6Qjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id; bh=W1IYkjMUQdZYCUET1UeGta4MM9L17ipJdw8Dgmfkpyw=; b=q96vA1pFe71iToxnBk8+akw0hNU18zyaGD+Q2LkLFBKvR8Q0jHB7UtxESK+sTM1n7o XdUMXpSbyRg2uqjzjTh4wxKMjacFgJAmEGL4zWBEe9gB15Hbi4y2Cl9Cys7sIQS7RI/V GR7N3BIjAa2R0VTkHkX6GmGqp+mhS2hjavIN4zQ+We5fT2C/IXtUqegqLbmX4jNwnC12 neWQkaNcOKFCD3O3bbmW10j4WDEgr8utz0avLM4FHtYfS9BUACH29I/TM6ShErFAne7G Mxzsa2J7g+gsJzgAkT2JgdHKBpw0gKUS3+cxKkvbulR2mAFNSa0mxIeKZpU8BW6kh9NP Xu2g== X-Gm-Message-State: AOAM532/qzUib3dJ8U0Gh4CQfqbqaMcLueppgP2jng0dIZr0twKD6cip XpFA+xTsJnLDWuPKn4NGYZc= X-Received: by 2002:a17:902:da8c:b0:156:c7a0:10f8 with SMTP id j12-20020a170902da8c00b00156c7a010f8mr8017518plx.71.1649244208555; Wed, 06 Apr 2022 04:23:28 -0700 (PDT) Received: from localhost.localdomain ([150.109.127.35]) by smtp.gmail.com with ESMTPSA id z5-20020a056a00240500b004e15d39f15fsm19209287pfh.83.2022.04.06.04.23.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2022 04:23:28 -0700 (PDT) From: zgpeng X-Google-Original-From: zgpeng To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] sched/fair: Return the busiest group only if imbalance is meaningful Date: Wed, 6 Apr 2022 19:23:24 +0800 Message-Id: <1649244204-23471-1-git-send-email-zgpeng@tencent.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When calculate_imbalance function calculate the imbalance, it may actually get a negative number. In this case, it is meaningless to return the so-called busiest group and continue to search for the busiest cpu later. Therefore, only when the imbalance is greater than 0 should return the busiest group, otherwise return NULL. Signed-off-by: zgpeng Reviewed-by: Samuel Liao --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 601f8bd..9f75303 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9639,7 +9639,7 @@ static struct sched_group *find_busiest_group(struct lb_env *env) force_balance: /* Looks like there is an imbalance. Compute it */ calculate_imbalance(env, &sds); - return env->imbalance ? sds.busiest : NULL; + return env->imbalance > 0 ? sds.busiest : NULL; out_balanced: env->imbalance = 0; -- 2.9.5