Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp565023pxb; Tue, 15 Feb 2022 22:14:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyweWLrRWtHu+Y3DgdkAIYLyOVlbrjq6zs/zDMUZUzFPHholfU397jZ+cS6aUwUIBVFf9vj X-Received: by 2002:a63:31ce:0:b0:34e:4052:1bce with SMTP id x197-20020a6331ce000000b0034e40521bcemr1012376pgx.459.1644992055280; Tue, 15 Feb 2022 22:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992055; cv=none; d=google.com; s=arc-20160816; b=JF0IidsAwUhGY3j1LIBeAULHE46waq/+QG1GjTR87t4Cb8I6xozV/r+x9aj4omxUeo yXcmNyEti0WOaqEfOo8GdFDqYnIDhxP15fJtjbUdB9GQ8+qvuzREX8oTW0jA2++nMWx1 3Z9z4OO9ZTgFOD4WWpuUeXp00dc4CDDXt+zGu2BDnj77KrqSwOq/HrhWg9YIWNmZritu 3IM+pjkBTj5z6jzNEi1x3W/NRZKNlgPDbNybQ5o5XON41qh7bVWa/RmHWVxA6sXUeX4j NQ84ynW/yZK6dLLPC9QqOSjcCXmst+W36JzrzjBozQ0N1neyucz4YD0c5bE7eMkUtV/r kFeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=VMOmqXD7bGUGwNEK+y5ntxfUWp3QOBAz1fSQwkMkvtw=; b=scrG16IFzepI1+Jt5Q0MdWkvfFuobmMCjEZ7BEu1m4p1avi1yf7FLYPB8rd0IBDNKv owBIf9G34Cqbtf7mNFNaGbSc3I3uu+a+PzicnoCSUd7Lgs3QlI0B35SFyv0s4oc85gUC KBR0GUEmH6TbShsK6O4HwUQ9u+n0qtsMd3huFGXEQzYAf8ymfIBj8bL6e8IXIFPQyMce Aj5kyopyiKoTL3kHEfNd6K9Dcir72BeLp1nO7FeRVO9w8jQmosGCjyqiWfp66S6xVl1f I6Tw8Y87vhAzs9H+i9UgZAbaO5Mnf8kv1seOz8BCgMcoWElMvhiEKcRn2+sndc0B1lCy LSpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k8a8aqJ8; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id gm13si16432620pjb.116.2022.02.15.22.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:14:15 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=k8a8aqJ8; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6678E143467; Tue, 15 Feb 2022 22:12:43 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241783AbiBOQq7 (ORCPT + 99 others); Tue, 15 Feb 2022 11:46:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiBOQq4 (ORCPT ); Tue, 15 Feb 2022 11:46:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2BA5B12CB; Tue, 15 Feb 2022 08:46:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8E74460C70; Tue, 15 Feb 2022 16:46:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECB04C340EB; Tue, 15 Feb 2022 16:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644943605; bh=3lDax48feHbZdBFrbcRVKRR9+nvIBFtl6786B5m45rA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k8a8aqJ8g9FYm26EcplxtWYed5+OLBBM4+kqcXEee3dTDFfrPj8lLhS2fbeszQ1lV 537pdmJw3Kh3D2vtg/t2aZvEeBOTUeRXTlZXHUa5+E8KBme4c4Jer9ifa47AqFgToF OkNxwVv5UAaIxIr+IrcDN146mkwpUUoAti+3Iwb7ytGEop5UnrDwenbV6fvCdNhOjG b4/uTg4Z9riB18RBAiQBZvMwPGUzAo9H7bd6MTgQMxnPYJv/3jOizQqIrzhiVyGhCt gDjyl+ZWUDX7RFn6L7pPycmyfEdfB8+tWjTaGNdrmVI5dB6yVqpM/HRjbR2NpBVgVf +hCCKg++d1g8A== Date: Tue, 15 Feb 2022 16:46:39 +0000 From: Will Deacon To: Darren Hart Cc: "Song Bao Hua (Barry Song)" , LKML , Linux Arm , Catalin Marinas , Peter Zijlstra , Vincent Guittot , Valentin Schneider , "D . Scott Phillips" , Ilkka Koskinen , "stable@vger.kernel.org" Subject: Re: [PATCH] arm64: smp: Skip MC domain for SoCs without shared cache Message-ID: <20220215164639.GC8458@willie-the-truck> References: <8c4a69eca4d0591f30c112df59c5098c24923bd3.1644543449.git.darren@os.amperecomputing.com> <20220215163858.GA8458@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Tue, Feb 15, 2022 at 08:44:23AM -0800, Darren Hart wrote: > On Tue, Feb 15, 2022 at 04:38:59PM +0000, Will Decon wrote: > > On Fri, Feb 11, 2022 at 03:20:51AM +0000, Song Bao Hua (Barry Song) wrote: > > > > > > > > > > -----Original Message----- > > > > From: Darren Hart [mailto:darren@os.amperecomputing.com] > > > > Sent: Friday, February 11, 2022 2:43 PM > > > > To: LKML ; Linux Arm > > > > > > > > Cc: Catalin Marinas ; Will Deacon ; > > > > Peter Zijlstra ; Vincent Guittot > > > > ; Song Bao Hua (Barry Song) > > > > ; Valentin Schneider > > > > ; D . Scott Phillips > > > > ; Ilkka Koskinen > > > > ; stable@vger.kernel.org > > > > Subject: [PATCH] arm64: smp: Skip MC domain for SoCs without shared cache > > > > > > > > SoCs such as the Ampere Altra define clusters but have no shared > > > > processor-side cache. As of v5.16 with CONFIG_SCHED_CLUSTER and > > > > CONFIG_SCHED_MC, build_sched_domain() will BUG() with: > > > > > > > > BUG: arch topology borken > > > > the CLS domain not a subset of the MC domain > > > > > > > > for each CPU (160 times for a 2 socket 80 core Altra system). The MC > > > > level cpu mask is then extended to that of the CLS child, and is later > > > > removed entirely as redundant. > > > > > > > > This change detects when all cpu_coregroup_mask weights=1 and uses an > > > > alternative sched_domain_topology equivalent to the default if > > > > CONFIG_SCHED_MC were disabled. > > > > > > > > The final resulting sched domain topology is unchanged with or without > > > > CONFIG_SCHED_CLUSTER, and the BUG is avoided: > > > > > > > > For CPU0: > > > > > > > > With CLS: > > > > CLS [0-1] > > > > DIE [0-79] > > > > NUMA [0-159] > > > > > > > > Without CLS: > > > > DIE [0-79] > > > > NUMA [0-159] > > > > > > > > Cc: Catalin Marinas > > > > Cc: Will Deacon > > > > Cc: Peter Zijlstra > > > > Cc: Vincent Guittot > > > > Cc: Barry Song > > > > Cc: Valentin Schneider > > > > Cc: D. Scott Phillips > > > > Cc: Ilkka Koskinen > > > > Cc: # 5.16.x > > > > Signed-off-by: Darren Hart > > > > > > Hi Darrent, > > > What kind of resources are clusters sharing on Ampere Altra? > > > So on Altra, cpus are not sharing LLC? Each LLC is separate > > > for each cpu? > > > > > > > --- > > > > arch/arm64/kernel/smp.c | 32 ++++++++++++++++++++++++++++++++ > > > > 1 file changed, 32 insertions(+) > > > > > > > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > > > > index 27df5c1e6baa..0a78ac5c8830 100644 > > > > --- a/arch/arm64/kernel/smp.c > > > > +++ b/arch/arm64/kernel/smp.c > > > > @@ -715,9 +715,22 @@ void __init smp_init_cpus(void) > > > > } > > > > } > > > > > > > > +static struct sched_domain_topology_level arm64_no_mc_topology[] = { > > > > +#ifdef CONFIG_SCHED_SMT > > > > + { cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) }, > > > > +#endif > > > > + > > > > +#ifdef CONFIG_SCHED_CLUSTER > > > > + { cpu_clustergroup_mask, cpu_cluster_flags, SD_INIT_NAME(CLS) }, > > > > +#endif > > > > + { cpu_cpu_mask, SD_INIT_NAME(DIE) }, > > > > + { NULL, }, > > > > +}; > > > > + > > > > void __init smp_prepare_cpus(unsigned int max_cpus) > > > > { > > > > const struct cpu_operations *ops; > > > > + bool use_no_mc_topology = true; > > > > int err; > > > > unsigned int cpu; > > > > unsigned int this_cpu; > > > > @@ -758,6 +771,25 @@ void __init smp_prepare_cpus(unsigned int max_cpus) > > > > > > > > set_cpu_present(cpu, true); > > > > numa_store_cpu_info(cpu); > > > > + > > > > + /* > > > > + * Only use no_mc topology if all cpu_coregroup_mask weights=1 > > > > + */ > > > > + if (cpumask_weight(cpu_coregroup_mask(cpu)) > 1) > > > > + use_no_mc_topology = false; > > > > > > This seems to be wrong? If you have 5 cpus, > > > Cpu0 has cpu_coregroup_mask(cpu)== 1, cpu1-4 > > > has cpu_coregroup_mask(cpu)== 4, for cpu0, you still > > > need to remove MC, but for cpu1-4, you will need > > > CLS and MC both? > > > > What is the *current* behaviour on such a system? > > > > As I understand it, any system that uses the default topology which has > a cpus_coregroup weight of 1 and a child (cluster, smt, ...) weight > 1 > will behave as described above by printing the following for each CPU > matching this criteria: > > BUG: arch topology borken > the [CLS,SMT,...] domain not a subset of the MC domain > > And then extend the MC domain cpumask to match that of the child and continue > on. > > That would still be the behavior for this type of system after this > patch is applied. That's what I thought, but in that case applying your patch is a net improvement: systems either get current or better behaviour. Barry -- why shouldn't we take this as-is? Will