Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1548042rwn; Thu, 8 Sep 2022 23:22:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR6YU4kRzqG7JEK4U9EYoV8p6BYIPORO5MX273HKXfMjKtt9uj89tdwhrH5XGWkXM7Zc8IYN X-Received: by 2002:a05:6512:3a96:b0:494:71e2:6d86 with SMTP id q22-20020a0565123a9600b0049471e26d86mr4184675lfu.274.1662704542964; Thu, 08 Sep 2022 23:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662704542; cv=none; d=google.com; s=arc-20160816; b=x0ZcNLQjvTRT2xp18fRo45kq+Pn+RXTkPm0WFpN69+mK6gPYaL8baoMjVywogp4SLr pEp3qaddPHURJGuRqGXKyW3s6QrAThqqZ9U4QixFDbPks9eDRbG4Ed3o8PtVR/bcTSzE czsDdE2MRHKJUviMpny0SnFomB+XGw0RuESofEHIB3XI0frwM1gCUG/43H2sAj7+FEQJ +zvmh55K60fY7k0Bsu03vWWN8mnmmjaK/u3alFrSTjOsIOMV1VziynZ8tPSw5PW9mM8r M3s6AjT01FUwc7x0MEC+OFi/rHSDQWR14ltWv7q/smsa2LOhlKoTn/y5qQSAERnJ8SLw fh0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fNnn9wLK8Hw5NIwUy4nGEsew1EpO470MKUS9ViwkYPA=; b=LhXyo8bpHAHGT+sE5Et5jA6dgcERdyUIe2ZdamDLLm13RSORTcZ4BH+hj0mKgZyH5Q JFt7SzkMakBo8oGMyjDyYjCtXPhInykRRFiYMM14xEw/RrzdbbRKXk4mJ+rlfVPJGeOO dRc4/OmcBB4M9p+m9dpsDU47sL9jHg6nMm3MafvTwpncuhxiZQjeOhB22XPc73DP4VV9 1/uNSAAlZO2BQgEIYgqot6p83KoqFAIB9qGEjArQBYogOt+5kb9iu5IMfPb2Txg8QSGp qPlBbfjc1dneXlKOu+bR/vFzQlNdP+CPhjXhN02zxMxxQj6vhuNlEsf/ZJk/Ler8YP5F kK/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=N0iuRf8T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq11-20020a056512150b00b00498ff59dde5si32435lfb.96.2022.09.08.23.21.53; Thu, 08 Sep 2022 23:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=N0iuRf8T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbiIIFxr (ORCPT + 99 others); Fri, 9 Sep 2022 01:53:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbiIIFxe (ORCPT ); Fri, 9 Sep 2022 01:53:34 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF3DC00E3 for ; Thu, 8 Sep 2022 22:53:31 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id pj10so570918pjb.2 for ; Thu, 08 Sep 2022 22:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=fNnn9wLK8Hw5NIwUy4nGEsew1EpO470MKUS9ViwkYPA=; b=N0iuRf8Tjp2U1euObd/YNC0SPejhZ0Idhojtv157DwpOMO7zpKPXUeBwrzlh1YYcVU KOzGhtqbNMiAYfNjOADqG5MvRpyxpgydXN3dFerF3Mzf/PCUFNFM3cf0S/7nprAEOEgB 8Xewe9KluYQFn6HWd2kKf2g6AdaXag+myWQwTDSaaWNK1+XAl6rpGD1avmUFGtgBTztX bnFXCG5jKQck+bOkSAJesNmgrmY03Jlds4qI/R0gDgiGDYMeQZryiAIvsBn8RtN1wrzs 7kF/AQ8dk6DD601+Dib9J1QSWiRT/C1Zd/egX2bUohIJWYAQmm7xAcR8wUUxLsYYPHNt qC4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=fNnn9wLK8Hw5NIwUy4nGEsew1EpO470MKUS9ViwkYPA=; b=PSYv+Iokz05dY6GHES3GFvj2NI3urSHUStayUvfC48Po1R7LvIP6MdDB0UdcvMhim4 fG1mBStmVaeu3nWys4zOKhRG7g9/9wiSvQ2YO2ki5epFYRa5/oIGNa9pJ7+0hEWY/6aF kIuNcsLD7QVcQ7QDFNDdUMG083+9WR4Ff8AYqtWpnD4J9BnpLb3Jp/y9EnnB2A4job2a 3gIvaHDvktGZgfePfbrv/fnNXQlC8zdmrdHkMzvREhJ3k0IXyOJW7yZNumTbTjfea7R1 FGxB3M7eVULcuTd7Atrk+3IwepUcddJmX8Y8GGSLOpFxs5rO6ER23RxiLJtPFtuA9xlK o0VA== X-Gm-Message-State: ACgBeo0YGMI1mz673vEIOTIipjmb5MSC6YlaH6ObzH3K84HgfbHtab1Q 10rh1ac5OHk7MDLSKTaAqICqyQ== X-Received: by 2002:a17:902:ea0c:b0:176:75a2:625d with SMTP id s12-20020a170902ea0c00b0017675a2625dmr12288617plg.21.1662702810956; Thu, 08 Sep 2022 22:53:30 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id y66-20020a636445000000b00421841943dfsm464380pgb.12.2022.09.08.22.53.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Sep 2022 22:53:30 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , Tim Chen , K Prateek Nayak , "Gautham R . Shenoy" , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH v5 3/5] sched/fair: Skip core update if task pending Date: Fri, 9 Sep 2022 13:53:02 +0800 Message-Id: <20220909055304.25171-4-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220909055304.25171-1-wuyun.abel@bytedance.com> References: <20220909055304.25171-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 The function __update_idle_core() considers this cpu is idle so only checks its siblings to decide whether the resident core is idle or not and update has_idle_cores hint if necessary. But the problem is that this cpu might not be idle at that moment any more, resulting in the hint being misleading. It's not proper to make this check everywhere in the idle path, but checking just before core updating can make the has_idle_core hint more reliable with negligible cost. Signed-off-by: Abel Wu --- kernel/sched/fair.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7abe188a1533..fad289530e07 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6294,6 +6294,9 @@ void __update_idle_core(struct rq *rq) int core = cpu_of(rq); int cpu; + if (rq->ttwu_pending) + return; + rcu_read_lock(); if (test_idle_cores(core, true)) goto unlock; -- 2.37.3