From patchwork Mon Apr 4 23:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Hart X-Patchwork-Id: 12800946 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 2AC85C433EF for ; Mon, 4 Apr 2022 23:43: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: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=80a06nYSZbUHrsIl7GtrUXOfUxD8SU+l102Lf/3OuzY=; b=CWPWR0j+Jdrzvv jUgu7aYlm7NC3Hm1biBfgk2M7aRMl3QRH0HWYQYygTc+YJ0IbggOkjrOf0io1EkKmRNSTGyzoavqo 5c6jocgv1WCO5NK/GYDGoZBZjVbTSBkILo3dvl0I7LFnmsnIYOXZd5kI0iWKIjvbvichzhFgzNVbw l9XwqfkF7L/SM5Y3hfeQgfp3Tog7yLCZrxwXu5MDUPnZO9c0Gl8V3wuKmZx8OsOEv3gbP5/ogisyC oFwUoHCb3FmGGIlX75kWMRk1/V8u1Eid3aV7A0rxtD/TFqqqTFOA1AZvpz/36aGHTYTERH2IIzKj7 BDa5Ny7FeWEEHQCdSdag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbWKz-00GhhN-Gc; Mon, 04 Apr 2022 23:42:21 +0000 Received: from mail-dm6nam12on2071d.outbound.protection.outlook.com ([2a01:111:f400:fe59::71d] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbWKv-00GhdL-UO for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2022 23:42:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f5ce0ZmtwjqeiK0dTFOlX60Jg2MOtJER2RQGvcSW8ekYBV7P+ZVhqG9YHLGKDNug+ZRpiHueXle0NQvhhKRs9fVumbGYs6wdT6R44vJ6VU1Zb1lZc6Gs0Y8xtmmqceAVO+mnfG13tb6CgEdbLJbs0JKhzPYXn1oH/NK7xeUsAbT7FQogNTwaJe6oY377o3aMWZL9m6t2Ihccn55B7/vl6j3jEZE1h8lukZxx2HDJ5sijWn4BOLN29Hn7OnQwG6lxFmVOLSUutqmH7CjUYvFV+HGj1bbLguEloQVa07RY8v5UCE3RDb1ljz+3q1k8Hm2cmrgvX5sEsnFHZMr//Hm8Kg== 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=qah2VP26lCPgl7TStyEOv0eJ1Wooz3QrsG8GA1UEhWk=; b=GcUTA2OQI+IVOAQDZ78HRGni/LjsOTJv8yz8iGt27QRj3P4+aE7c5Id5H9u+nacAkTTvOFAL/OMEEA9+qn2tpgtiQOwQjJdRDH+OsiwalBZRqmHeU5n8ln4FZ/tD9EMrlLCmzYURzSjYs+7zamY5YxG1YLFdbI+HXOE+1akdl8K9f6yrgEPYOj6iDxBj8ixkyELj1jxppJwfvhRchZV2hyllIh3wUFOnj5Ao54aXKV2ohC3LAP6RaZtKEb5TosyWlKWz6OzqKt6KGmvJbDGyERd6G12yj5opZwkvdPjbsJ9Wgje2t7xNbAVTx3ZigfMXXgk/2hsnKvkEar5SXcIA5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; 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=qah2VP26lCPgl7TStyEOv0eJ1Wooz3QrsG8GA1UEhWk=; b=CfkheW32b02gieNOHfbkHTcM9Vn98e4tR0z9SRvzwmrr9BgzTZoIR61+t/k3i8Kq+8P6Vb+VhF1MDrkJfBjImNsatk7d/VjkJxnBrnaoeUkC01JFXD5uDgjv1Dt8KCsHlKaalTy86MjXkwR7w9Fr9Py/Ej+BLmNlIKWFHFax/R4= 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 DM6PR01MB4924.prod.exchangelabs.com (2603:10b6:5:5e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.25; Mon, 4 Apr 2022 23:42:10 +0000 Received: from SA0PR01MB6329.prod.exchangelabs.com ([fe80::f56a:e18f:b6c4:ddb5]) by SA0PR01MB6329.prod.exchangelabs.com ([fe80::f56a:e18f:b6c4:ddb5%9]) with mapi id 15.20.5123.031; Mon, 4 Apr 2022 23:42:09 +0000 From: Darren Hart To: LKML , Linux Arm , Greg Kroah-Hartman Cc: Sudeep Holla , "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Peter Zijlstra , Vincent Guittot , Barry Song , Valentin Schneider , "D . Scott Phillips" , Ilkka Koskinen , Carl Worth , stable@vger.kernel.org Subject: [PATCH v4] topology: make core_mask include at least cluster_siblings Date: Mon, 4 Apr 2022 16:40:37 -0700 Message-Id: <3d58dc946a4fa1cc696d05baad1cf05ae686a86d.1649115057.git.darren@os.amperecomputing.com> X-Mailer: git-send-email 2.31.1 X-ClientProxiedBy: BL0PR0102CA0058.prod.exchangelabs.com (2603:10b6:208:25::35) To SA0PR01MB6329.prod.exchangelabs.com (2603:10b6:806:ee::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7dd126a3-40c3-48b6-203f-08da1694bc28 X-MS-TrafficTypeDiagnostic: DM6PR01MB4924:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1RWxmMY+3t0l7cnd4efZqtkUZhcJF8Py97HiMpvwzO+Vqlt3tKwN18BiWStgJfmAAgnS/1uyTYiLFEgMf3tJOW4Bnr1PO9dP7QP6y62WkHcP8LyeFa4yBTOkvrhiMtZ+RGBw0JZzMKMYLig4bK54/jTSRxfLx0j7fg8Dj8h0970rpjrMLxEHLpkO5jdSy4RpiJcZyKbXSBMyksonwX+8Nbs5IRC2+A70qDDQX+4rWz4wm+8OX+Bny123waJnvSgqCZ+uOR+yFVb1Ca1uJVm8F+5ITraYEwOgDUS84dILPy2etqXYxBLQMnwcuJVW9GuJWF5ug8HZ/zRWvOkKKMxae+k+S/ZLav/BIOVisItCJbzy+qmxrgOGMS6jcP1jXp9PSnUCdMy3qJjDwyTG5ktVwQ2XBPvihE8YCveG48JZOBzE9KyNH7LgWnhOZS24gMVPtcuMzLuimFNPnwaSZvJ1Ddkbu1DShuAbopIofHE2EOFpmHjl+V0gvA1hPydmvTvzsAdHMtWs0Hx2sjGSPoQtJPGM+HLRgs6+DuCYbOkhLt58yH4AoAqJIiQgsrKUUt7YS1juroKe+ohE85ZFFh5x09ER9jcoYQyO46N4FmwRtvAg5/9gBx1tBXnZw2Sc/fgGyUunN18lhuYxvOoJIvDRAS9Jc9brp38lOW3DVXTYFXAJ0HHq6IqKkJsrls9tPG98kZ7zIV7Kpreq+Hl1uRsYgg== 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)(4636009)(366004)(38350700002)(38100700002)(316002)(508600001)(52116002)(6512007)(6506007)(6666004)(110136005)(54906003)(4326008)(8676002)(66946007)(66476007)(7416002)(2616005)(2906002)(83380400001)(186003)(26005)(8936002)(86362001)(66556008)(5660300002)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u9FYvcF4OVivJMCF6SdXqoGC4B8LzKlrAXrqy53m5pHe4VjjGUORJ96ywqp092NtH/SezYFjXHhQfmFsobtTOAdaxxxSZ7fjB9Yukc8c0hw/wm4w6ZtZeOlJKE4p19kUyv0Vb0E8UZqxNGtEkfLFQkQYv89zEhOBHrFIuf4E1gb0JsWsk123FrhU/mu8Nfm562I+0YYku7+quZEkL+yJ88E1sCJWWvH6ME9ca0vX0i8QuQy5Wu2OVw5f7baTuIKFvgrsse7gJW9ph6nt7KOnjyoOKPrdiUn0VZPYu9Ew2GS8tdp5HnOsC+a0TbNlS+KkZL3+nPAu38Y4RiRqtpqdLU2wgRPeIpgqhyUhHu1bG5jO6v/Sb+g6euYRY0kj86ydFaUq8glztiE7ujZx6W0vLT7RUZg9E+kyuptv6qr3kg1mDcek3hjartWLRTKS8i2+4m1auU86i86+6gs8o9TgGhim2VyHGH6AA7/Ph1RAoVDspCJ+xh4If1xCo+VInyvjycV9gzq7jH0kScWKKYBQvFlgEhwqMVDSTOlbjTSO7zdUaD92+At7seSWjxdpv7u12LoZVDxOpRwRmm43as7mGIRdR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fPmvs14sdSGOhVaWmVdTjtoEXTBOuGnYXt7EDkSOWjDv9/elOP/cOIdwIshD3LU7ukgdEKoP4VO2DRBOSR19qg1o7F4WqY X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7dd126a3-40c3-48b6-203f-08da1694bc28 X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6329.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2022 23:42:09.7031 (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: IHSxCvSOAKReUhC9CghMureSWfof0gidUUF2ZMV4JwLYK3Uj6vKlcMZJE9XTf8gtDOcYGSLNFDLs3pko+z0sCZt/PcVGYVOYIQ3UooY99B9Ja8d0Wufm+vEbiuOsudOI X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4924 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220404_164218_196667_5E96F915 X-CRM114-Status: GOOD ( 14.03 ) 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 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] Cc: Greg Kroah-Hartman Cc: Sudeep Holla Cc: "Rafael J. Wysocki" 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: Carl Worth Cc: # 5.16.x Suggested-by: Barry Song Signed-off-by: Darren Hart Reviewed-by: Dietmar Eggemann Reviewed-by: Dietmar Eggemann Acked-by: Sudeep Holla --- 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). 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; }