Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01B5FC7EE2C for ; Tue, 30 May 2023 11:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PIc7j6Fm+rOgYKr0f9reebaMpGTUGAUG8iSvOBJOHWk=; b=tJJu4QQ3d93Pbs 0C5FfUk3KGJ4uAEeLFo0ngX7Y2BRgzojArLfpXCm2WFeh3yRPAWlQtU9hGRNBATD1/EmDs6cNtKxo ct70kJL1Mw6B5Tg6+iLV/vHBj6JFjrGXiN3x5H3wmMnkxbfDW++nzoSsLzZ3FFCShiexA3LgpHn4x WSFuFIty6avaWT7m2l0NRZbGyBgyVG+f0vzSvdoyiWa0k5Ezc8V+l3RQPr9E4yF4eh7yz/9A2n0SO A1O1hEQfz2bt1PIXD6a9QAbaTiWs2xFPIrxYAuc/mushrwaM05Gv4an8pgd8ATAGUbJKu2GtT3vYq c4yoi35c45r97TC8fYRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3xwx-00Dk01-08; Tue, 30 May 2023 11:55:39 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3xww-00DjzX-0W for linux-arm-kernel@bombadil.infradead.org; Tue, 30 May 2023 11:55:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yPLDzEYFr7Uv0xJ6+5vuSMqjQXaHZO1SYK+pWm+AqYY=; b=Uftqarp6cOtJ46fr19yoy1AxXc zvvb8sstUUikefEW6Bx0HaG3iWfChkR/VI2/VW7rCGocAlWD/VRW3+L/fhrA+pGXgjaZDoxRzUh2m oupscK53EVNiE6NpJQj2LY/1PvVbllmHASyApBfbXSXRyft7G5NEPA3cPkeu/3lodpiayBAKkBodN 2G3XwdHdhz+UR88E9SKzYXAa2tzg81QorHUR+5UMv3Cm5scDBsq58Ih/+qzo+2ELIrNf2zixNSDJ9 2+wqLq3mopg6XxTCjh/vOHQl14QvFLaCZ1XWEFT2zd85leS0IIZQqOvSWYd6eFGBBSyBxnSr6x2aa BLu+e7xQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q3xwp-00DiLN-0t; Tue, 30 May 2023 11:55:31 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 88232300194; Tue, 30 May 2023 13:55:27 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6C796207AE7AC; Tue, 30 May 2023 13:55:27 +0200 (CEST) Date: Tue, 30 May 2023 13:55:27 +0200 From: Peter Zijlstra To: Yicong Yang Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, tim.c.chen@linux.intel.com, yu.c.chen@intel.com, gautham.shenoy@amd.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, prime.zeng@huawei.com, yangyicong@hisilicon.com, jonathan.cameron@huawei.com, ego@linux.vnet.ibm.com, srikar@linux.vnet.ibm.com, linuxarm@huawei.com, 21cnbao@gmail.com, kprateek.nayak@amd.com, wuyun.abel@bytedance.com, Barry Song Subject: Re: [PATCH v8 2/2] sched/fair: Scan cluster before scanning LLC in wake-up path Message-ID: <20230530115527.GC156198@hirez.programming.kicks-ass.net> References: <20230530070253.33306-1-yangyicong@huawei.com> <20230530070253.33306-3-yangyicong@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230530070253.33306-3-yangyicong@huawei.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, May 30, 2023 at 03:02:53PM +0800, Yicong Yang wrote: > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 373ff5f55884..b8c129ed8b47 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6994,6 +6994,30 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool > } > } > > + if (static_branch_unlikely(&sched_cluster_active)) { > + struct sched_domain *sdc = rcu_dereference(per_cpu(sd_cluster, target)); > + > + if (sdc) { > + for_each_cpu_wrap(cpu, sched_domain_span(sdc), target + 1) { > + if (!cpumask_test_cpu(cpu, cpus)) > + continue; > + > + if (has_idle_core) { > + i = select_idle_core(p, cpu, cpus, &idle_cpu); > + if ((unsigned int)i < nr_cpumask_bits) > + return i; > + } else { > + if (--nr <= 0) > + return -1; > + idle_cpu = __select_idle_cpu(cpu, p); > + if ((unsigned int)idle_cpu < nr_cpumask_bits) > + return idle_cpu; > + } > + } > + cpumask_andnot(cpus, cpus, sched_domain_span(sdc)); > + } > + } Would not this: --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6994,6 +6994,29 @@ static int select_idle_cpu(struct task_s } } + if (static_branch_unlikely(&sched_cluster_active)) { + struct sched_group *sg = sd->groups; + if (sg->flags & SD_CLUSTER) { + for_each_cpu_wrap(cpu, sched_group_span(sg), target+1) { + if (!cpumask_test_cpu(cpu, cpus)) + continue; + + if (has_idle_core) { + i = select_idle_core(p, cpu, cpus, &idle_cpu); + if ((unsigned)i < nr_cpumask_bits) + return 1; + } else { + if (--nr <= 0) + return -1; + idle_cpu = __select_idle_cpu(cpu, p); + if ((unsigned)idle_cpu < nr_cpumask_bits) + return idle_cpu; + } + } + cpumask_andnot(cpus, cpus, sched_group_span(sg)); + } + } + for_each_cpu_wrap(cpu, cpus, target + 1) { if (has_idle_core) { i = select_idle_core(p, cpu, cpus, &idle_cpu); also work? Then we can avoid the extra sd_cluster per-cpu variable. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel