Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3353716pxm; Mon, 28 Feb 2022 18:15:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwljfxI7Lvq9HoMqUAwG095A/SVCAPnDinP06eTJKxHmR081x+/hRPpPxel0VID/hQE84Lf X-Received: by 2002:a05:6402:50cb:b0:412:ab6d:c807 with SMTP id h11-20020a05640250cb00b00412ab6dc807mr22121265edb.382.1646100946414; Mon, 28 Feb 2022 18:15:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646100946; cv=pass; d=google.com; s=arc-20160816; b=sN36P//bn+8oPdQa2zjX5yUA1vEGCByRYGYcXpk71ePfI90f60yt0tkJ+VMSSUlaSs Ozj02tgVc1RSfzRqqsFxfj2YqwM5wqHt2HbdXmftIiRhcrnbWfMjLaSl157z9Pba9abX xF9eDWDyWU4Ba4BW5mu9cM5gRAsmCCdVxodLHXgzsUyUx6SahmLp5G7UjWuVgwUrA6pW Qmgd4mmQoUqtCMXw1VzudqsP7AzyLLej+Il3sAN+VM19YfKUdnXSToVgi+yOc2Q/HUNd +NQgx+ccr92p3TtIfaQ/P4FMjVbaGi4mOeEd4FmemgHyo0gnuBKaJ0EKpCkKbrPwWKPp +o9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8EIylm2qdnYHk2YylpL+1jmqE6/GDlYz1S7OUI30k7s=; b=Y14w0A+QLMfPpm/wjPENr7DyRcCFMc7FAw/oHNBEnW1XJXWmlqwbfQPxUri2+ivEve ZE+pK+uvFzR+dGh8prJvmHpip2SgoRRS5cY6pnql0XWh7xpfnJZu4GBeLkJjqWm2Oe9/ vENifut4+pu2J1KB88TA5TL0ZKVGN9BVAmdbyVtyTLRrNrGqKgPirZHJPyHH+cD6c27U WIBfbTIDy0lnGJ7baOK4HnJ5Z2IQkPLCmEurGCocXSFhQyH4TYHzYcaz6eHLsy07Ge0i +xIwPJlYRFcFEJ2Xun77Y0NGZaO5TxI7KbbLY98CeZGHiuqqrSbvOzvbcgKp5A1EQMhT lK+w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=i6U3PMWh; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a50d9c5000000b00410fec0500csi8127376edj.273.2022.02.28.18.15.23; Mon, 28 Feb 2022 18:15:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=i6U3PMWh; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231857AbiCAAgZ (ORCPT + 99 others); Mon, 28 Feb 2022 19:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230384AbiCAAgW (ORCPT ); Mon, 28 Feb 2022 19:36:22 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C15660CE5; Mon, 28 Feb 2022 16:35:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XioZOmKz01YX2QKPkvn//p+5MptwiYycd1P4C+tfi/olrrpLiuO7F6yCoJ9/UrGOiMIQQ6Q9rDafBfxrB+e1PlBkgoGtIerU8pklh3ceZbdLAosIJCnf2cUzH31M9k+Rb0ZVryGCGS/M5XKrRYgfRIjyK470qP4wjeRW93IFP8C1TCVenpcyTEf0n0m83md1PI4PSsK+JFFHtZdZd+03AEGY1/snl7lpWrkv1iXvFkUHSDNM/vmaSTtkIb7V+WbwbPcPGoiQwiNydw51+KbRCh7Mnzsd6SkRbNAzSzHKLKWp+2/s7fagJnPTV9saLt/6rGt5ElhrH2KPcMsjmqOUhA== 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=8EIylm2qdnYHk2YylpL+1jmqE6/GDlYz1S7OUI30k7s=; b=E394tMLC6pq67BkvokjUctv3HwNJdXhplK04Y3DOOeV+6O2gNH8juuBvJe4N0jCsJuIIWKRWLUlx4Kzea4V/nIQj55zE+jqJVu+Q080os12iolbCYFqf5NMIbsQYT3jYX7aUMDa8MEwJ9eP8G0dDNQMg/pG6xCyVzXIYcSZku34mHvSDcvhdR7HjYS+HdwH8j1qZj/g0cNdyIi5/nM5bFN3gZwYfi9uYvflZk5FWn042aWezy8z+neXyKxW7US1tVHIfRfvobAWJSJx9IjXeHpRmFIix/SIUU4SJadZdhJ90yC8TTX5xZOq3ZEPanZiV3nB13kMKqgswpeKQIuUsWw== 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=8EIylm2qdnYHk2YylpL+1jmqE6/GDlYz1S7OUI30k7s=; b=i6U3PMWhPfkgu59lG803PZyUl17SYTMv3mOaQ/23+e0WsAcsBhVX5o08zavJsIFPvRoFfWyKphwPpBe66IGF71x8RVPQS4M7WBRz+0hnhNHLUt5fcjOpGhy7lGz88htJ7J0+rRSvMXMLu0iMD52or0g82WGFwC9H/TyZw3UuYqo= 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 BL0PR01MB5219.prod.exchangelabs.com (2603:10b6:208:33::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Tue, 1 Mar 2022 00:35:40 +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.5017.027; Tue, 1 Mar 2022 00:35:40 +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 1/1] arm64: smp: Skip MC sched domain on SoCs with no LLC Date: Mon, 28 Feb 2022 16:29:00 -0800 Message-Id: <84e7cb911936f032318b6b376cf88009c90d93d5.1646094455.git.darren@os.amperecomputing.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CH2PR05CA0066.namprd05.prod.outlook.com (2603:10b6:610:38::43) To SA0PR01MB6329.prod.exchangelabs.com (2603:10b6:806:ee::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6ae8d2e-a3e0-440b-8672-08d9fb1b6993 X-MS-TrafficTypeDiagnostic: BL0PR01MB5219: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: VvahVvEj7PK6U/JUv4KVMnESttjRn6tde03zC+sCRfC1so1PgnlFkGu4uvED6hUf4fRX2vhN04RybQPzkGr2paXFZ1koT/iXwX6gumTzJinkhEf47wjwHros1AinP+FUHZ+MbnYHi7sPQyaSn3QmEAVbmAChDabt682ciGy3ZNpX8ieKVN2SYNqgcyH4ZjHUkyoz9zrM7oj7VaZ9v8L238r76vunPqKl5MveAJfMHdtMEejZc8e9i9ZLdW71Kbr7G448oNRfatmI2jm+V502ckRY1sX98ROWsHPZAfhuK40xxCTsCeGLkajlEO17+Z7i57NXrBvkvA9LSqorAYsXKxxARhxwSSiopWalXyL7nmpHBSGaFW+9SYESMhaiXBrs5xqwlYNO5rwkLVDku5RE9jrjfLZ+MVUNxljB8vg6tsUEP3mGXfi8rMFx4Dj/yPp44Anj+ttdHnCtif5GfVELMa4MnaQ7ofAIv50/pYiUddg/tG6+YYrtP9N/f+CGQ2tXaR3fI+XxG0eqiQQhEE2lzEV0/uMcOHEMT8zblu2aDoh8h2+37LRJJqBB71Ls6WhS38jTS3npF/3fwLwqSbqEROlyCuT9tsJKXdNWyK9+1OJh1JFUukUY3CjpY6B23k0LNh1wXgMSl9nEle6lIFj+yKdidK1O3WGKse9+bHIVCkf9BXSxJK8K8zXHK2g04u+VBeDY0fIJ8R/keQyLSQ8X5g== 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)(26005)(186003)(6512007)(5660300002)(8936002)(2616005)(38350700002)(38100700002)(83380400001)(52116002)(508600001)(6486002)(6666004)(6506007)(110136005)(316002)(54906003)(4326008)(8676002)(86362001)(66476007)(66556008)(66946007)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?xiE9QeEe7HWvZz4Dl3v7xNWaDYGidvQihVCFAtPmiJwXJk3W4L+KN3Nmv4bk?= =?us-ascii?Q?n3ccl8ZzyXDHw7bz8NG1PWLAfcQItCHeGh2EfHAXJnfuvdUSkLvwherxHdWM?= =?us-ascii?Q?257+L9tdaxkH1kBHN9DJzK3CymptSuasmoGpzji9Vlcx3VCM50Vdfyo6I46T?= =?us-ascii?Q?b9gHhmHb3Bb6YE8AAFDO718jm2S8qrU56zl/dso89tIRATLJLtUkWWB9Yvsj?= =?us-ascii?Q?ySPlm/dqBDVYq1YbAO4tUAl2mJ3VMBqMqjjOQain5ckLfu+ix4nMtabmlEoK?= =?us-ascii?Q?lhQXW3OiU5qgxjWnQtMXIkoi6+q1lcKAPkYwT/revQ6auFh4FhcJ3cYgySc2?= =?us-ascii?Q?vzSIDLUiAytFGE7n9lJ8SqV2vx1oyf9Ja04DbP3KV/QrSBvKsFMWU4G+4pgt?= =?us-ascii?Q?qbZZ8EBheP6MGj32YfF1hOosviY3F+8z58OTeyg3moYB3nE9wgxTc13/ZYlh?= =?us-ascii?Q?ZxBletaq2VVE3xPouAZYyF1ZDpdWuKsdNNFuhiUJO4i/Wm8h17tdSF2yfR1d?= =?us-ascii?Q?/otW6NGT6rK9KIAChRwtBn96fPy94u4BhHgWwh1PUz+MC5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ii6rfKJfeXqjhHWe8ddjznpczDhILxnEvrbWHQv3xAwCCYNcAQoB?= =?us-ascii?Q?qIpt/rweOcqQaKRV10YOAq9xnKQRGCQnvTGHw5uCZPabfLbvPq3/stWksYZs?= =?us-ascii?Q?19JAk2PJtec6jF+ifBeICiVswJzAWCPi6fr+Hf5kWt0ZMMLKhSZqrNVoXDG6?= =?us-ascii?Q?eEpSPWVcnQUxnduGynKCguJEoLJYh2lYyXSjSZGlz7Xfn2ffjagTHIoVfsuz?= =?us-ascii?Q?sozEPJ5W0WEzPDo1MmXP+iq7tbjCN/g4QwjtCY1rmVt2dKIuP0zA85ZS1swU?= =?us-ascii?Q?u7HHAfJtFw=3D=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6ae8d2e-a3e0-440b-8672-08d9fb1b6993 X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6329.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2022 00:35:40.5317 (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: tNXSmz1BSwAbiVgb8C4QwE1n/HLA9pJuOlpBJFo0sNu84CGqR9S+UF3kAOEKGSj9YbUh2Q6fhHulfAJDqCdej+YGeEMzzZ2N2rh0BtgGkJKoyQkDZGHkKbKBVMYJ5GHd X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB5219 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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. Introduce an alternate sched domain topology for arm64 without the MC level and test for llc_sibling weight 1 across all CPUs to enable it. Do this in arch/arm64/kernel/smp.c (as opposed to arch/arm64/kernel/topology.c) as all the CPU sibling maps are now populated and we avoid needing to extend the drivers/acpi/pptt.c API to detect the cluster level being above the cpu llc level. This is consistent with other architectures and provides a readily extensible mechanism for other alternate topologies. 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: 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 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 27df5c1e6baa..3597e75645e1 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -433,6 +433,33 @@ static void __init hyp_mode_check(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, }, +}; + +static void __init update_sched_domain_topology(void) +{ + int cpu; + + for_each_possible_cpu(cpu) { + if (cpu_topology[cpu].llc_id != -1 && + cpumask_weight(&cpu_topology[cpu].llc_sibling) > 1) + return; + } + + pr_info("No LLC siblings, using No MC sched domains topology\n"); + set_sched_topology(arm64_no_mc_topology); +} + void __init smp_cpus_done(unsigned int max_cpus) { pr_info("SMP: Total of %d processors activated.\n", num_online_cpus()); @@ -440,6 +467,7 @@ void __init smp_cpus_done(unsigned int max_cpus) hyp_mode_check(); apply_alternatives_all(); mark_linear_text_alias_ro(); + update_sched_domain_topology(); } void __init smp_prepare_boot_cpu(void) -- 2.31.1