Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1103688pxb; Wed, 6 Apr 2022 08:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1tNMLHO861W3KWDMQAT8mIISfjLe1w9LueM+2Yg3PrsnUPFk2S0k8EQ9PxN/nBWMZvCtY X-Received: by 2002:a65:45c1:0:b0:382:2edd:fcc4 with SMTP id m1-20020a6545c1000000b003822eddfcc4mr7692666pgr.559.1649260133833; Wed, 06 Apr 2022 08:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260133; cv=none; d=google.com; s=arc-20160816; b=psctJByWaxJRcTPRPP6Y9Eiab9FPOiNvci5tkQysNpRz9bS88p9uxJFGcSV3QzvRlJ je6k2OdQ6IVePbs3J4jEz3JimqTHLBtz4paWgitCDWdOINmHUEI7WdHqJoYpXMlVPyH8 rDUf+W8/H2wu0V+qyYU9wmioN/PTFug8mKGevzXEjz3tuAgZFLyzMHNF6dESx01LiLLM MH4mKpdAGY93gehyJdBv3alKOXDoCw2Tu1EW/bWslcL5dyO1njbAYCMlbZHLJM70m42u 5aB4DJg17BybLve+/eT5zNfpebnGMKs0IiLg5uQcRoR9rwI3K2x3scA4wox4nUVhG2C7 r1pg== 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=3qKR+9UnHfH7y3GmZazKtwO1JgDzyIRfNNCTfPUQzPQ=; b=UIXvHbcAnrVzsAxBuG7Bst4Xr4d6tKZ6aJ0mtxA8X+NKkEHkkj7+vQsKAQphZrXoWo KFeB9PfhV3jP1r09Dmxnk+osIZhkbMh+frcdFmUDms5ozb5gFflvcYcBHxVl5PW5BwV+ lWX7nkfGZnwz+1pTxypqENG1m5NbOJkQZG+fA4lmEXJJn9L7q6QFxkOnE8qKQxnrtZ8f Erg557sQWBhRXtGB6YAB9iTZe/TX/JqdUJr370wOdF3I2rX13Ej0pjMdQCqi/ybtTs9N Wc9h/VjtMTkfWdfaFLNpHWm0o7Qe9KbXfL5dJHXyPrRmzNqBOAIR28UnmfofdfaCi5ES rASg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=T3HnXpLM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id l10-20020a17090270ca00b00153b2d16565si14969571plt.365.2022.04.06.08.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:48:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=T3HnXpLM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 38745427D5F; Wed, 6 Apr 2022 07:08:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234482AbiDFOJw (ORCPT + 99 others); Wed, 6 Apr 2022 10:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234987AbiDFOIT (ORCPT ); Wed, 6 Apr 2022 10:08:19 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A1E49E435 for ; Wed, 6 Apr 2022 02:57:09 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id ch16-20020a17090af41000b001ca867ef52bso3976396pjb.0 for ; Wed, 06 Apr 2022 02:57:09 -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=3qKR+9UnHfH7y3GmZazKtwO1JgDzyIRfNNCTfPUQzPQ=; b=T3HnXpLMVHF84AhdAnlosPkOaV9Jf1AjBveZ6piPcw9aDZW1oz4WzNV2VhuUNw/R2C J+zpHigYJ7kSTbrfi/JOJd/Ye1VvqmGmrrnv4r4BlvLI7X2At5ameEPt54Wou+JUQxrp ibuMUAdTv4PeAIClj6apPHezgvlvgWZzZv7mAA4vnm9EEeqx1QyTxrTI5RVOSI1jz65E a12ad43olBO8boyJ+XDOVKvfUeGq+qikcUCOeNeKotPR7Cdw1PGt5rTIZYF8LbiXXJxD jqV5SdO3xpqL9bxSS2rvIZUbIISbhzGKCFeogBLA4+pz90zogiw7/xDsQwBhe4kX5ZFQ cZgQ== 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=3qKR+9UnHfH7y3GmZazKtwO1JgDzyIRfNNCTfPUQzPQ=; b=2OeQ46q7paymPBXfyy5kM9DD6bmjiTaYZQp4GiOs+e53eSQpFR6Cct8D/Dupc+Yms7 /+kJeSzADnRnk1zFQPgXjYW5GZhwOyVQ+gcdEJJr1qzOpHYjuIyI9v7WUre64wSL4FOh 7B0U2sQ1fxz1KsYd7uCmdu58QIbHfK4/auNgvPR49uY92Qp+Td9JfXq2PD4ziCCTpLrg 0DnsLdM9t8lR5nCbUv5FU7M4yNq2kJUEzTsRStnPav9gtXcszq2RHuHwSSlUKaahubJg fR26tDo+BEKXYDbgdmppEefAF+eznb6sLsmG5vRhnyiG5bINBDGil8OKBNJEjASAPmes 9o6A== X-Gm-Message-State: AOAM532Y+/aTVIRaxmneBCl44Cgdd0yGGMJUogGTPU5ROz5smypTt5/5 mnDPhb+SKnY2xovPGffg8Do= X-Received: by 2002:a17:902:a588:b0:156:599c:6278 with SMTP id az8-20020a170902a58800b00156599c6278mr7641266plb.109.1649239029282; Wed, 06 Apr 2022 02:57:09 -0700 (PDT) Received: from localhost.localdomain ([150.109.127.35]) by smtp.gmail.com with ESMTPSA id lp4-20020a17090b4a8400b001c9ada2f28fsm5581497pjb.8.2022.04.06.02.57.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2022 02:57:08 -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: Move calculate of avg_load to a better location Date: Wed, 6 Apr 2022 17:57:05 +0800 Message-Id: <1649239025-10010-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 In calculate_imbalance function, when the value of local->avg_load is greater than or equal to busiest->avg_load, the calculated sds->avg_load is not used. So this calculation can be placed in a more appropriate position. Signed-off-by: zgpeng Reviewed-by: Samuel Liao --- kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d4bd299..601f8bd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9460,8 +9460,6 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s local->avg_load = (local->group_load * SCHED_CAPACITY_SCALE) / local->group_capacity; - sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) / - sds->total_capacity; /* * If the local group is more loaded than the selected * busiest group don't try to pull any tasks. @@ -9470,6 +9468,9 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s env->imbalance = 0; return; } + + sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) / + sds->total_capacity; } /* -- 2.9.5