From mboxrd@z Thu Jan 1 00:00:00 1970 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 515D3ECAAD3 for ; Thu, 15 Sep 2022 12:02:34 +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:Date: Message-ID:From:References:To:Subject:CC:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qEM3VyNWLsKRthdBoYOXiaCJJqZBAjA9McNrTWfgP7E=; b=ZPOG09MmsaBKkS0hK8DrNpjpmv D+viTSS/la8AklOTb7WgsG5/kWk1lQiBnJ8uaSHow+tWmd/dGjr/g5kJK5ugRXqHw4LJuu0O40c9k HIkZQ03Cc5rDmSJRbmRu+3H/hHgkPm/N/Q2Nmm7cCpJx9xsNGzUPZDqBQ8FT+8v27K2i35Ulfbtsb 0aS15U3Wo9dhz5y5BslEDrpgyVrtUSdgRITQitPMghgNYJWkWGIc24t2En3x6LN7NvmsZs6qb+qda EbxzbvVKkoKdUSqWALAC2kZpP9g1wCXBRDCKk2TDbDsA25kly6wEgkdfMNil/X9Yc6ooLn2ICWgug iwxiW4zA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYnYi-0088Bj-N9; Thu, 15 Sep 2022 12:01:32 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYnYe-0087yp-NS for linux-arm-kernel@lists.infradead.org; Thu, 15 Sep 2022 12:01:31 +0000 Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MSwg41bvgz14QPM; Thu, 15 Sep 2022 19:57:20 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 15 Sep 2022 20:01:18 +0800 CC: , Sudeep Holla , Dietmar Eggemann , "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Peter Zijlstra , Vincent Guittot , Greg Kroah-Hartman , "D . Scott Phillips" , Ilkka Koskinen , , LKML , Linux Arm , Ionela Voinescu , Barry Song <21cnbao@gmail.com>, Jonathan Cameron Subject: Re: [PATCH v5] topology: make core_mask include at least cluster_siblings To: Darren Hart References: From: Yicong Yang Message-ID: Date: Thu, 15 Sep 2022 20:01:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220915_050129_167743_BC861692 X-CRM114-Status: GOOD ( 28.87 ) 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 Hi Darren, On 2022/4/12 4:53, Darren Hart wrote: > Ampere Altra defines CPU clusters in the ACPI PPTT. They share a Snoop > Control Unit, but have no shared CPU-side last level cache. > > cpu_coregroup_mask() will return a cpumask with weight 1, while > cpu_clustergroup_mask() will return a cpumask with weight 2. > > As a result, build_sched_domain() will BUG() once per CPU with: > > BUG: arch topology borken > the CLS domain not a subset of the MC domain > > The MC level cpumask is then extended to that of the CLS child, and is > later removed entirely as redundant. This sched domain topology is an > improvement over previous topologies, or those built without > SCHED_CLUSTER, particularly for certain latency sensitive workloads. > With the current scheduler model and heuristics, this is a desirable > default topology for Ampere Altra and Altra Max system. > > Rather than create a custom sched domains topology structure and > introduce new logic in arch/arm64 to detect these systems, update the > core_mask so coregroup is never a subset of clustergroup, extending it > to cluster_siblings if necessary. Only do this if CONFIG_SCHED_CLUSTER > is enabled to avoid also changing the topology (MC) when > CONFIG_SCHED_CLUSTER is disabled. > > This has the added benefit over a custom topology of working for both > symmetric and asymmetric topologies. It does not address systems where > the CLUSTER topology is above a populated MC topology, but these are not > considered today and can be addressed separately if and when they > appear. > > The final sched domain topology for a 2 socket Ampere Altra system is > unchanged with or without CONFIG_SCHED_CLUSTER, and the BUG is avoided: > > For CPU0: > > CONFIG_SCHED_CLUSTER=y > CLS [0-1] > DIE [0-79] > NUMA [0-159] > > CONFIG_SCHED_CLUSTER is not set > DIE [0-79] > NUMA [0-159] > > Signed-off-by: Darren Hart > Suggested-by: Barry Song > Reviewed-by: Barry Song > Acked-by: Sudeep Holla > Reviewed-by: Dietmar Eggemann > Cc: Greg Kroah-Hartman > Cc: "Rafael J. Wysocki" > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Vincent Guittot > Cc: D. Scott Phillips > Cc: Ilkka Koskinen > Cc: # 5.16.x > --- > v1: Drop MC level if coregroup weight == 1 > v2: New sd topo in arch/arm64/kernel/smp.c > v3: No new topo, extend core_mask to cluster_siblings > v4: Rebase on 5.18-rc1 for GregKH to pull. Add IS_ENABLED(CONFIG_SCHED_CLUSTER). > v5: Rebase on 5.18-rc2 for GregKH to pull. Add collected tags. No other changes. > > drivers/base/arch_topology.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 1d6636ebaac5..5497c5ab7318 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -667,6 +667,15 @@ const struct cpumask *cpu_coregroup_mask(int cpu) > core_mask = &cpu_topology[cpu].llc_sibling; > } > > + /* > + * For systems with no shared cpu-side LLC but with clusters defined, > + * extend core_mask to cluster_siblings. The sched domain builder will > + * then remove MC as redundant with CLS if SCHED_CLUSTER is enabled. > + */ > + if (IS_ENABLED(CONFIG_SCHED_CLUSTER) && > + cpumask_subset(core_mask, &cpu_topology[cpu].cluster_sibling)) > + core_mask = &cpu_topology[cpu].cluster_sibling; > + > return core_mask; > } > Is this patch still necessary for Ampere after Ionela's patch [1], which will limit the cluster's span within coregroup's span. I found an issue that the NUMA domains are not built on qemu with: qemu-system-aarch64 \ -kernel ${Image} \ -smp 8 \ -cpu cortex-a72 \ -m 32G \ -object memory-backend-ram,id=node0,size=8G \ -object memory-backend-ram,id=node1,size=8G \ -object memory-backend-ram,id=node2,size=8G \ -object memory-backend-ram,id=node3,size=8G \ -numa node,memdev=node0,cpus=0-1,nodeid=0 \ -numa node,memdev=node1,cpus=2-3,nodeid=1 \ -numa node,memdev=node2,cpus=4-5,nodeid=2 \ -numa node,memdev=node3,cpus=6-7,nodeid=3 \ -numa dist,src=0,dst=1,val=12 \ -numa dist,src=0,dst=2,val=20 \ -numa dist,src=0,dst=3,val=22 \ -numa dist,src=1,dst=2,val=22 \ -numa dist,src=1,dst=3,val=24 \ -numa dist,src=2,dst=3,val=12 \ -machine virt,iommu=smmuv3 \ -net none \ -initrd ${Rootfs} \ -nographic \ -bios QEMU_EFI.fd \ -append "rdinit=/init console=ttyAMA0 earlycon=pl011,0x9000000 sched_verbose loglevel=8" I can see the schedule domain build stops at MC level since we reach all the cpus in the system: [ 2.141316] CPU0 attaching sched-domain(s): [ 2.142558] domain-0: span=0-7 level=MC [ 2.145364] groups: 0:{ span=0 cap=964 }, 1:{ span=1 cap=914 }, 2:{ span=2 cap=921 }, 3:{ span=3 cap=964 }, 4:{ span=4 cap=925 }, 5:{ span=5 cap=964 }, 6:{ span=6 cap=967 }, 7:{ span=7 cap=967 } [ 2.158357] CPU1 attaching sched-domain(s): [ 2.158964] domain-0: span=0-7 level=MC [...] Without this the NUMA domains are built correctly: [ 2.008885] CPU0 attaching sched-domain(s): [ 2.009764] domain-0: span=0-1 level=MC [ 2.012654] groups: 0:{ span=0 cap=962 }, 1:{ span=1 cap=925 } [ 2.016532] domain-1: span=0-3 level=NUMA [ 2.017444] groups: 0:{ span=0-1 cap=1887 }, 2:{ span=2-3 cap=1871 } [ 2.019354] domain-2: span=0-5 level=NUMA [ 2.019983] groups: 0:{ span=0-3 cap=3758 }, 4:{ span=4-5 cap=1935 } [ 2.021527] domain-3: span=0-7 level=NUMA [ 2.022516] groups: 0:{ span=0-5 mask=0-1 cap=5693 }, 6:{ span=4-7 mask=6-7 cap=3978 } [...] Hope to see your comments since I have no Ampere machine and I don't know how to emulate its topology on qemu. [1] bfcc4397435d ("arch_topology: Limit span of cpu_clustergroup_mask()") Thanks, Yicong _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel