From patchwork Fri Feb 11 01:42:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Hart X-Patchwork-Id: 12742660 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 7ABDEC433EF for ; Fri, 11 Feb 2022 01:45:15 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wurrLmTJSuEtKWAIppe/vY65rf19nA9ZxFrvCRHOahk=; b=o6mjTqMZhUttHS IielU6UTz8rCnAyH++GYr4sPL7RRBML44mgE3pRytEBHs1I9IKZt+WW/DnX2JFIsgBef2i20kpAc/ SxYqZK8BG986VgEcUycP+YYlJsEWnom//dpgxNbE5DAeLm/iyPTdhOL8FsUoOOR/yQgCGueW+sYTM 2Yfdh2HimyKHTtNlIh5dik5IinOvoQtZeyZfqBXGEnmTIMgLG5Xee9seNeLl/8ebaxeZ+lxVcIlwP 17gvqebbfvrlWI4PnNm22mDvq97K3JuUiuKuaXmJcT2NwQpvyUfqBx28yLolaq/KMY+ZBEfMhWecB 8qIYN0gAfWLwvvPk9OQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIKyU-005RJN-PL; Fri, 11 Feb 2022 01:43:51 +0000 Received: from mail-dm6nam12on2070c.outbound.protection.outlook.com ([2a01:111:f400:fe59::70c] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIKyR-005RHa-Cv for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 01:43:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFfDBRrTxz5F0y5KZDpA6waEPb1Gus6jEX6WiKbRIftfIgAiyM4y1+9gY2q74ikhB1FraaCY6KzsFguCBXOySL+ZVse3bj51Ws0y/VhtxtSd+IGtb0Bny2z7NJj9+CLZwFPc+ePV5sEay8hLsPlXckiqIQAyJFCs1X8PQERNcwtZUYzL3BttRQzVgqMMrbb1N0163qvrFekVCfzk1+N1oLxTZsBkAVYGyajurE+A+WS44Muz5NYmB4egoVmFFZ/Nu6p3kJzsluGZiwa5kc3QJP5Mlt8rfNIDI2TZtbtUWtzflDdO2Ci7yEuvWx4cLqx3ni12LzgVLeMCusGILNcFvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lkF0w2sbmEJ+/ZgywEQYcBcmTzLUhcmf4ILE6Zaz3+Y=; b=bHd3VKoRb+srmkyqJJuqKAn1f9yGtxXvLgS+Mg9eOcK2+zM1q3Z5ZRZu4kPb5Q4e0/vb2yn+UauhzHQcEENrbhrWaitkcVyLkefvRPZ/22GGBN/XrvnKiFU6c+wRshCIOVe30JG+8Qkl4nBe+kKGHWtczHQjhUciBr/uJD9kAZmJtdoK37//eZXMlXL5j5RW0c/mJ+WC1cXt2aV15vKr0LA8EOXQdTJ0Qwethxp3flJvGGfTmX8MQhnY1iuZZ+ry8zzzEBQKB7znC47U0sRM6qbVELB7SaJ7fTDjznVGe8smkFpi7hKIo6FaW3yQl/qKmFoa7I6HVc+0UJMFbp5Yqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lkF0w2sbmEJ+/ZgywEQYcBcmTzLUhcmf4ILE6Zaz3+Y=; b=OhOKiaBbwCE47Ccq5lCJO+mV6s6FeOjGu2rINPgpsmN7TR8CZyAFttJfjGmjSbXzGcT7TQISE2NBXWmOhHIBy+Z5xbpIeml1c+oRvaIo2aUMIDO8AjNUxR8khGnClWcw7qcDEiVBf4q4mhTrK2xfu+2i1nwvK8h3jpNMpK4Xi0Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SA0PR01MB6329.prod.exchangelabs.com (2603:10b6:806:ee::12) by SN6PR01MB4640.prod.exchangelabs.com (2603:10b6:805:d3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Fri, 11 Feb 2022 01:43:38 +0000 Received: from SA0PR01MB6329.prod.exchangelabs.com ([fe80::7cd6:6594:ce3c:6941]) by SA0PR01MB6329.prod.exchangelabs.com ([fe80::7cd6:6594:ce3c:6941%9]) with mapi id 15.20.4951.019; Fri, 11 Feb 2022 01:43:38 +0000 From: Darren Hart To: LKML , Linux Arm Cc: Catalin Marinas , Will Deacon , Peter Zijlstra , Vincent Guittot , 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 Date: Thu, 10 Feb 2022 17:42:46 -0800 Message-Id: <8c4a69eca4d0591f30c112df59c5098c24923bd3.1644543449.git.darren@os.amperecomputing.com> X-Mailer: git-send-email 2.31.1 X-ClientProxiedBy: CH2PR15CA0021.namprd15.prod.outlook.com (2603:10b6:610:51::31) To SA0PR01MB6329.prod.exchangelabs.com (2603:10b6:806:ee::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43a592cd-70b6-4ea0-65d7-08d9ecffeccc X-MS-TrafficTypeDiagnostic: SN6PR01MB4640:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jpiMyMgtYffuITPCqA55JWRA2DUVBd8vmZ50F2FhnZsRKB13nMOn6k/42ltwA8xYw0QobrIyr5C4cjk3XOlG+wQnwgPlqnlHUsUq8sftpkGXYpUBe1A5cIArztMz312KnjWDaEk3kMzjaJdQs5JmGB+GRzH3/DTT2oWciQZgu1zjbGOTDEM7SfkWNEmeZ2YYjFnj3uK65Ehdx2qEThzWHx8Z4OZSGLIbgPzithLRMfUyJhb6PkeAovdka79ew9/Muz2OdmFUoRANi42s8ytkNwFdN/tuoh1w4sRGa4h2W3DlzWxKZEUROWjl9NUCLiQBCwTiD11r/qeYTaJfYd241sgzyFqib+rBOHixeUR3DPhAq8J/WotHqkSwnWldzTovGAZ+bAC27zYpUTnSY235igJ5ATiZD6uOkdBYeNPZQ/EJKL2SOP8BzFkYymnW1n34Ge94qj+GXoafCBWZmCuLSDcW7qHgOgGMgxAqQUG8ce/6Sx5mwXGzWSDzVtOs0KQ/l51/rXoyTD5+B9SXp/dl/r1viCFIc8t8eTBTGh7tREdHcz6bwW2idllqM31cgig5cLv3eiJk3AKC8TQM8ygPGRca8SGot0cC5lGl9lkXkJNeyZO3fadbA0lApdqk8HU2IslE+8TtB9WoHe9iXK31b30TVwIpYPngSQkE7HOpKsnf9VDgEOWk9caseE+udDhYfM0apKb1KzqhbmA8x4HcSg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA0PR01MB6329.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230001)(6029001)(4636009)(366004)(110136005)(4326008)(6666004)(8676002)(6506007)(6512007)(5660300002)(508600001)(38350700002)(6486002)(86362001)(52116002)(316002)(83380400001)(8936002)(54906003)(186003)(2616005)(38100700002)(26005)(66946007)(66556008)(66476007)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QmAAyHNwK1nXUcU7V8znqC7mzooBLEO8BrOzxmln3/dyVNvHsogxTpj8RiBrDY8aha6kvUgvDEW+xO7O4INYOa5QmQACBCGOiGRC4XRs/E8ruhwgZW4TJs3NBrWywiJU0EHhI0dSrtR9NyubtLnB5ePFjcsslAZKNBuB2P83pp4RM9qWRQ85jiTQ3pM1UO6/CWhGEijkRNnFY7XDvfHxkBeIoJZ4ZePW4UVTK6OE1lsSbHUuDDs+hI/qR/rYMLS0lyvVn1GZhWQaluCSlLk2/GVBXhHxjiH/40TO8pQnezFoBAhXqwSlD9SsEa+bYRgQtTBnAalZa6YEvVrqN7kbqZxyYC8M9h7553Sa7Ba6PzCksbOpTi32Uc7AOz2681N5OkwMy6PqjehLqCUsHRlKCYNBDwgf/6yofR8Sqx6jcStTPvVCVcPdH3lGP3jDaeJtDwQaCXWxD3vMkV6APmKzjSbAAdV/uwqJA6P+ZyzzH4iGinTmwC4KkFzzXE6R3xKAbWDPlOYfZTqM2gxIXtchLvUQfgpUs8t+XNktf+Hgu/0abqYX7BzBXWheoNKgbBlSTsnAsE0uGbokyuDgC9yULQee2XQ1UwxOQnY43328L7b+XgkKzx/wajAVpYGMQR5rDy+fU0F4UtRyyfbSpDdPHfz6c5ow+RaBR4i3oPT1/KsaRiB5vBnUd92j1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ginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43a592cd-70b6-4ea0-65d7-08d9ecffeccc X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6329.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 01:43:38.5300 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wjHvNDjHJXU6h/5wU/YvGCmEqesr0/+uMdmALHLWK+D+5+RY/hihkkUvWPCRjBcfuCMVvxiaIcGFwZwzpI1f4STlknhY6dzCk7g+1LnsSWhMbbt+gi8sJW8KUkeXEIXD X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR01MB4640 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_174347_448778_0D1D3BB2 X-CRM114-Status: GOOD ( 15.06 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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; + } + + /* + * SoCs with no shared processor-side cache will have cpu_coregroup_mask + * weights=1. If they also define clusters with cpu_clustergroup_mask + * weights > 1, build_sched_domain() will trigger a BUG as the CLS + * cpu_mask will not be a subset of MC. It will extend the MC cpu_mask + * to match CLS, and later discard the MC level. Avoid the bug by using + * a topology without the MC if the cpu_coregroup_mask weights=1. + */ + if (use_no_mc_topology) { + pr_info("cpu_coregroup_mask weights=1, skipping MC topology level"); + set_sched_topology(arm64_no_mc_topology); } }