From patchwork Mon Apr 11 20:53:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Hart X-Patchwork-Id: 12809648 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 9BBF4C433F5 for ; Mon, 11 Apr 2022 20:56:53 +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=XldcgY4Lo96Lj6IhPr+amo+8Py9hPB/t+vjBC5Zedk4=; b=zhzDPqCUCVeVON qp+p4jw/YQDIVfmDGepJDPRBW6cYoPqiy4zfWp3mHTebabW97WcudYLjksIyoBhubW/pUWjs9/d2P d0huOqdLxCXtpjC8uen+i06AJZ2fgcRJp+li81a4F58ytgMIPUUxzmwpkMo0oA5OauhaQp+EiV0eP XWZ/164Rp5cSLy/bXOxG9hyU1le+xK3XNQSGtQBZ+RLFaZ5/x7AufXoLbvpsHtsAQwRWGL94x9KBX 6R5Z1dcmzIwKf5XG99N/kuIlZQzASMhwBV65Vrw6mCXmO6AjbCrKnJl0gP8/8skXYtneycww8GoQB MaMhLkfnaBch496gWXZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ne143-00AUe7-EQ; Mon, 11 Apr 2022 20:55:11 +0000 Received: from mail-bn7nam10on2072a.outbound.protection.outlook.com ([2a01:111:f400:7e8a::72a] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ne13z-00AUdK-Ny for linux-arm-kernel@lists.infradead.org; Mon, 11 Apr 2022 20:55:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xqcim/ykw5bx2ANAOSdOAoNyHzKbLJ0EdawVz3QvzIG844qdDEoxnK6sF2nOK1NjJAUAAhxV2GapCv+Q6LXVk//wfTUU6BB0uOOFXMXfHu1QH2dE00UgSPMao7y/KrC+NgU4MzNfax9rOl2g9J7y1TM1X9U6ccyWyvr2ly0ZBwTBsN9kfXiNWQSaIYkZu7uZscPPlvvTR35G2/ln5KI+qkCgnBftkm67WWccrn1mVYGolXGS1iYoYbzILyivPkLs5sKHQriLiRmUfwULn7cR7UGvz0T76I6sj16Ya3wRIijO6Dq3VF+Uh8gQd2Ek7/+8W3Kw/SS3z+EQg2Ya0tIlzQ== 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=bc8PV9O9L+/wC33GQaqp79nsc1aLwyBNnRXSs3WmEw0=; b=NHpoLqkEMcFJeUJJim1sqb+YaePPwj8Np5tN7/A6zonpCj0IzXVRUP+pqpwUmgbvJt12dm8SzYPvDUIlSge/S+OrEL2ZlSMa1McP0vZTVcSsQdpmu7glc3MTq7JYp2X47GkauwBYPJQrOJUqsCVhPh1OI/rpMUguut2X/OLqmPHxf0R3tITjqQxXtEzaws8BzlYHv/IdWpb2cH2KkwpYJq/9KOzbBOV0sOFJK6SNyLc15Wkb5M2/etdRlM0Ak9AR7TvGICHkBhtRrkgOmB+xSScDcxCZ9lGK3AP7l+i8uC8xDXs265MP0kOP+5jlxuSR4T3RKDyK5in/DhesyujRHA== 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=bc8PV9O9L+/wC33GQaqp79nsc1aLwyBNnRXSs3WmEw0=; b=Toa+h36efGPJZfrmSDX+aQfNkDBZ3MespwQjopSk2Z4/nqs/Nw2Qi8zeE//drPbDpZGMaX2oi1iM2rvx97fbSw6wIwSl001e2lVLpdo8IYg+zn6C/ol47pK0ebd0qSj9v8ZU6zzmsf+9Neqvyt36x9kvNbGsn8dkSyvjUJcM2ec= 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 DM6PR01MB4572.prod.exchangelabs.com (2603:10b6:5:7e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.19; Mon, 11 Apr 2022 20:55:01 +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.5144.029; Mon, 11 Apr 2022 20:55:00 +0000 From: Darren Hart To: LKML , Linux Arm , Greg Kroah-Hartman Cc: Barry Song , Sudeep Holla , Dietmar Eggemann , "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Peter Zijlstra , Vincent Guittot , "D . Scott Phillips" , Ilkka Koskinen , stable@vger.kernel.org Subject: [PATCH v5] topology: make core_mask include at least cluster_siblings Date: Mon, 11 Apr 2022 13:53:34 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: CH2PR05CA0027.namprd05.prod.outlook.com (2603:10b6:610::40) To SA0PR01MB6329.prod.exchangelabs.com (2603:10b6:806:ee::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 646868d8-519d-448c-9bcf-08da1bfd8aa2 X-MS-TrafficTypeDiagnostic: DM6PR01MB4572: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: UayfwGS4eGV8Jayek6Fxho2ej3zpto+pklEBy8KG5j3PO2w7f+oajGLow5X+N4HWbs4Rg+TYFVVBQXY9GoBugnVDtx1UJsWjSLobYrX0ZIHnAqDSJ9nQDz4Z5hr1wv61RZOi5jyqLfwBaNtooAuZYzfCAraaimQhqFAyf79tYdubr0ZW12ePZJ8CjIcLok7BaRwbf9U51qEzQaQiscNze/G5YYF5gNnvO8jv/Ji0zJwc8RDTyTIylpj6H8gHsuuWQhxJ9+Nzyf6+5DMcNCWLwXNZ/yJOwtzBz7CppcxSR9JQHIgsJaJ2van+rhRJXsfA3LMU5i39hB07Fs96U/AhJalQvKUF4Ay9Ma2PFhaHEUpsr/bWNh5n/nVMe5j+Y/1cnSSMscCunNqJw9zPGHI6qAYD1DM+FxOoLWR2SMxdKsHrNK/v8ZBMb3tCL613E0RWC5h2W7c7WqpvoN38wTcmi9iS4TlDav+966ZbZHRr6vQkpxgMRvM5I8WDztsB+SSCt5/h5Xk+o6pt8kwN8GNRVmvqk/OpojwM9X6K0w7nt5r7vMQUN/P4N2hPy+wQ4jowk8geBDpRaldF8zsHlYrAtooLNA6k0okbCFNtSFTU5hmcwaMKkliLhUsZ9AX5XPfQydqtPrDt4iPIOjJP+tVUFfuVs66t/qkvBvIyhdy2CAS7jdoIVk/F/i6tFKonbx6yuEuTiHpNvxmjt9AkvBkZZA== 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)(316002)(6666004)(54906003)(110136005)(7416002)(26005)(186003)(6506007)(2616005)(6512007)(6486002)(52116002)(2906002)(83380400001)(508600001)(5660300002)(8936002)(4326008)(86362001)(8676002)(38100700002)(38350700002)(66556008)(66476007)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CLOWP5RelJOYGkALVgoZeoy9DA/A+WYeP6DMGFHD5BWr8w4Rxo4l1XQStyRkHUiWdmmw5dgdxbXSZxHo6ZK+TfqWoH7heNcB/XS5XIw+vVl8T95IuwYgYsUggAquXyXPEQIzwOacCeQwDKg/aA5P165htj6o8b9wDo3CwycqljrfJAgr1VjDnkWPpwYtWsT2Mv3byevM1qhxa40MummhH8pnbtAmuzeA62xo+IyAxjzRhUHfxM19EeibG3lhkrXabGfw1iWUt0UfWQqrBsyiEFpaSSR7izCZr3/GE1oFbQPbOxWTn4H5vMMv7PwFLM8r8B8+dwGbEf/le25azOnFQr8E/k/XX2h+83UoOp9sD8m+Y9BR9+a/xQXlDDtt5X6T4c+jFHNewq7S+UtHs3EIdLqxmgiQasdD67VFFbbqVHtNBYLWH/MSOSs513uFv/obDWdUs11kOIuQUWP8+LhEccUhi08fNB9b/wmar/EB8LLATdujbEF+zEzHo1fxmoHVtOGNScaWzDM+H9HLpjgZ9CbdF7N3J3D/DQXyLSawzUUYU3su1MsUARgZ8ZDmjkOexw/XiCHRqX3RY0hGfMcpNoNZlQAHUiTgbCRKSKqPQI3Bs7+pexqzS55uz9VveTNlkFSGLaw8qitdnWskfmwJ7LA/WGp83iK9YTspSJBz/sw45HjNV4C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DX0x/ X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 646868d8-519d-448c-9bcf-08da1bfd8aa2 X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6329.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2022 20:55:00.7002 (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: uLTWypPNCFNj7KWsqj0tFq7S63aTlGl1p4VdOf70HV8cf02obDbVcj+tVbr9ih/Kk6L/kUu0OCHVI+EBh8s2SvMlsyGykM2dyMO336Kuk0CEt/wncFwlSnMzYF+iore6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4572 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220411_135508_012368_6F341383 X-CRM114-Status: GOOD ( 13.72 ) 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] 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; }