Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3038563rdb; Mon, 4 Dec 2023 15:06:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaMG4sHyzp967JUTTxKodHz15Z6QRhpV5XLj3lZOirI3NDVKWcGUIDzQtT1wQJtjvh8tPk X-Received: by 2002:a05:6a20:7da6:b0:18f:97c:975c with SMTP id v38-20020a056a207da600b0018f097c975cmr6558186pzj.68.1701731167794; Mon, 04 Dec 2023 15:06:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701731167; cv=pass; d=google.com; s=arc-20160816; b=caWf3oazY9hh87UL3JegyjXaJbMBR5AiKwA4CHiKMX9GvdcivyW1FVF5UHJgr8DNte Pj3b3JNtGlMXIpDYecPJEGrlEFHGziQjcFJHfAD25CvVcWY/ioclRS0HGyloUn3EgHIZ 1IXwDuc5xHuqPzappV2p5lM9CpLrMO3JoaX5aI/bC34Ed+gzD6J8UwN3faF9zcCHDIPm gVveLsXA7vqnqwH1utjMUI9WVXAk+GPSj1xcD3j96GjSndklnI5NuWgc44/jw1M8iXNI OV3gEs8jI7/vXau2YFqMk2CmJ0vgrRuc57+oa6o7+CFo56MKM2usUbQvmd8E0+o4LYhn 8gnw== 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 :in-reply-to:content-language:references:cc:to:reply-to:subject:from :user-agent:date:message-id:dkim-signature; bh=vad1flW6mOMHPWDPsXFvcRYuUO1FZO6ziugCEN7E/6c=; fh=5hICm3ioPY8YsReQvrJID1CvhoYkOpa7QVuCVOnryP8=; b=kscG9oUOfvJBZtSdKzlMmc7rzzYf1oXGTAnH0t9Obw9Aw2/0+H5blNJkAJNMoGzyrA jEFtJ4NsBE4sjm78GNgvtxqUYOC1PJqSwkDH0oYLu7MerijIELP/aM0/yGNbDlTPilen wS67PNzoGTda8LtqdfFp1e+/esI8mvdsMlO6bcvbUlYM+d8YRfQMtMyM+jQ/wrulthaM lOYO63gf6ahesxsDO8kJ/l+Fb0gdBNoI5u56jC7K0k8cFsT/Sc0GjH/Jr5yVsWRCRUui rM1yy9XSHzV43ZQ2gQkGH8Fq2jq0RkDvluffFKAO4cj0dzFNH2rqGkpxNZzzCwWks3lZ Ce/g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="5lq/duY0"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j3-20020a63cf03000000b005be00224982si8688679pgg.381.2023.12.04.15.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 15:06:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="5lq/duY0"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B564880A533A; Mon, 4 Dec 2023 15:05:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234828AbjLDXFN (ORCPT + 99 others); Mon, 4 Dec 2023 18:05:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbjLDXFA (ORCPT ); Mon, 4 Dec 2023 18:05:00 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A955BD3; Mon, 4 Dec 2023 15:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tvhgh7HzehBAkePqNhhSB8t4EhnmJj3WUDA3xIQjmrCsF7Y6Hm6HV7RmkZli4ugBhitH7D9YG9yEZlvADnZQ7m3jxNZahdaqqEVQCBdTgIdTX9mcacqzELT+Hi6AmL7ln5EjW6wVyBkJpCFv154rmirsEO8nqdElrRbIfJlO/jEo44KBK7yeisMOkuKkC1MTaMvvywz9m8FBYDkduOKCP4nAhtM06sI9p96t6397ovbOsBUJ4AC65cDOMtkdIrEvzmsDenUIqY1r4r6QM5ZMyHkzsYzW+fW0v8Lh8rtW7yN4Jufsa0I0TqZxBZ37orNbae+FV12nrEtTW2FDPE8ifg== 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=vad1flW6mOMHPWDPsXFvcRYuUO1FZO6ziugCEN7E/6c=; b=eE8AooQzhkAxxsTkib/7svlyjRK7b6SErMlAApvJlxuU334nCkEpHAkKoQkmlgkOHf64VhIhQYwY9oUaBjJbkNb6B61A4Z7uglrw8fGLjC2d7AxK7eohtnDP51mfVbJNM5eEJOIeiT9hEHP/G4Nzu8aoG9sZDnHVp6qi3Jxmwa9As4tbHBuXk11ppVkGwPcrPB2Xc0ffbR+PGBJeTavaJ/bsx1t9I8oZtYSC48MiXA+0wnDex1W8t5+TvmXyiM+1QReiYP1Tw0Qcze6iXJUBt9RPpXePNswNo77dTEzVlFaoM6yQiZo7MMUfEeBChj5/cLpUBKWvwP9xfAUbx8kKcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vad1flW6mOMHPWDPsXFvcRYuUO1FZO6ziugCEN7E/6c=; b=5lq/duY0zat1DM+M5XKK5S3fajF8wN4RDg5FNCUTGZLRU4ZoKwVPRy3DhqcBOiV+v6HSY03axHVy1OvJT47vQgMDx/wus106CvXG4L3HZ+F8KjhCtkM07QwQ+SW7wOa3puLtHfi1i8V90v1iUu11g3P4K+U/LObxExdvZH6Md3U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from MW3PR12MB4553.namprd12.prod.outlook.com (2603:10b6:303:2c::19) by DS7PR12MB8348.namprd12.prod.outlook.com (2603:10b6:8:e5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Mon, 4 Dec 2023 23:04:22 +0000 Received: from MW3PR12MB4553.namprd12.prod.outlook.com ([fe80::1549:8c93:8585:ca1b]) by MW3PR12MB4553.namprd12.prod.outlook.com ([fe80::1549:8c93:8585:ca1b%5]) with mapi id 15.20.7046.033; Mon, 4 Dec 2023 23:04:22 +0000 Message-ID: <41632a26-a9cc-de41-de40-ea428cff16e5@amd.com> Date: Mon, 4 Dec 2023 17:04:18 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 From: "Moger, Babu" Subject: Re: [PATCH v13 6/8] x86/resctrl: Introduce snc_nodes_per_l3_cache Reply-To: babu.moger@amd.com To: Tony Luck , Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , Randy Dunlap , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Shaopeng Tan References: <20231130003418.89964-1-tony.luck@intel.com> <20231204185357.120501-1-tony.luck@intel.com> <20231204185357.120501-7-tony.luck@intel.com> Content-Language: en-US In-Reply-To: <20231204185357.120501-7-tony.luck@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SJ0PR05CA0174.namprd05.prod.outlook.com (2603:10b6:a03:339::29) To MW3PR12MB4553.namprd12.prod.outlook.com (2603:10b6:303:2c::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR12MB4553:EE_|DS7PR12MB8348:EE_ X-MS-Office365-Filtering-Correlation-Id: 79230c75-7eda-4351-8460-08dbf51d5a3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tOKoRSxO12UhW4TOKR3flm8yVoTojHNWju9+lTJXvLRI9oEsqbulZj9C2m6h2QSPteSvZp/qQkhq7XWypti3keKlXi46bbXgxwoQUAZT4PU4Ik+3UMyh6oQ1PuVx642jw8h+oEn19vnJp1t3K2vm/wfdTwZ+smys589Voq6XMA3c9zRug5OzVTFkf/1C29sEJbTyBLKArNAeWIop58X6CbCvm2LaL8j1WBye/SbrIqjLCWK98jmsPoHFLrX9jxcn9c7lDfby15cECpf1wwxgrumI/78TGxo4ERowEQD2QlbZXYqXwCkDSq9wiT8QVzxQG7RW780AM+mev7K4oT3kqoRxfBQ6nWGb8XqpjaF1sFg0eyss8awW9gnBW2uAhG/JLgKEbvPJ2v7UY7qm+WLlTacjQkDxLc0XFV7fs82iwviGtmyGgzAePXuY7p7GCRH+Cw4x4dmdEJqOy4hvJQKUkwgLvLQ0k8rsqNyuC2F4vYXwD2e8zwVIIiFE67jSdOLnyijmcYqXRTw00NMMD/KJ3RuI+OUBqPq8915Err7udb3jup1jeCf5v6y1f5/Eyc/6mRg3NMd0V6fqMIzBlNMRjISe8Fwe5XTjYb8Vt17+m4g4yrjp2usWIKPxFtF/P3GF1V6PYb0eS8shKGnWzsTGfQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR12MB4553.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(366004)(376002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(41300700001)(38100700002)(36756003)(31696002)(2906002)(83380400001)(5660300002)(7416002)(26005)(2616005)(31686004)(53546011)(6512007)(478600001)(6486002)(6666004)(6506007)(4326008)(8936002)(66556008)(66476007)(110136005)(8676002)(316002)(66946007)(54906003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z0lnRDJZaXgvQk9EMHNxTE1OcVU5cEY1NFZFUmVjWWlNTkxsZlJJS290WTVv?= =?utf-8?B?YTh1Y2xRWnh1VmxHc0s3SEgxdWhrVXNFU1ZscG5FdUdOVW9sRGlZZ3NCS0Uw?= =?utf-8?B?RDE0b3A5bVFNUEhLSG50YnJCcUs3NjRxU0VXSWVtZXRDTm5YcGpVYXJHeTNP?= =?utf-8?B?OTg5TzZsR0FQbTVWNXdEd3JxUFN0bHRXalJDaFJBdkNVUndkUVZ6SFpGTWo5?= =?utf-8?B?N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SmhBRXV0M0VyeHBZUWxIMk9GYUlaa0Vw?= =?utf-8?B?UWd6K2RaUzg3UzBMcXIrOGFUaVZpL1NZdEdmbUFJQU9ueTQ5RG05TUt6MXFF?= =?utf-8?Q?6LTNrlV8BpfWs3Q85Vr4gIyP6?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79230c75-7eda-4351-8460-08dbf51d5a3c X-MS-Exchange-CrossTenant-AuthSource: MW3PR12MB4553.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2023 23:04:22.0789 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0y0b1njRkLKb9Pt1sonSWiEcNhbPlaOx35v58AF98bVnOYGQMknTV/TQ5AQ7rQdv X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8348 X-Spam-Status: No, score=-5.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 15:05:37 -0800 (PST) On 12/4/2023 12:53 PM, Tony Luck wrote: > Intel Sub-NUMA Cluster (SNC) is a feature that subdivides the CPU cores > and memory controllers on a socket into two or more groups. These are > presented to the operating system as NUMA nodes. > > This may enable some workloads to have slightly lower latency to memory > as the memory controller(s) in an SNC node are electrically closer to the > CPU cores on that SNC node. This cost may be offset by lower bandwidth > since the memory accesses for each core can only be interleaved between > the memory controllers on the same SNC node. > > Resctrl monitoring on an Intel system depends upon attaching RMIDs to tasks > to track L3 cache occupancy and memory bandwidth. There is an MSR that > controls how the RMIDs are shared between SNC nodes. > > The default mode divides them numerically. E.g. when there are two SNC > nodes on a socket the lower number half of the RMIDs are given to the > first node, the remainder to the second node. This would be difficult > to use with the Linux resctrl interface as specific RMID values assigned > to resctrl groups are not visible to users. > > The other mode divides the RMIDs and renumbers the ones on the second > SNC node to start from zero. > > Even with this renumbering SNC mode requires several changes in resctrl > behavior for correct operation. > > Add a global integer "snc_nodes_per_l3_cache" that shows how many > SNC nodes share each L3 cache. When "snc_nodes_per_l3_cache" is "1", > SNC mode is either not implemented, or not enabled. > > Update all places to take appropriate action when SNC mode is enabled: > 1) The number of logical RMIDs per L3 cache available for use is the > number of physical RMIDs divided by the number of SNC nodes. > 2) Likewise the "mon_scale" value must be divided by the number of SNC > nodes. > 3) The RMID renumbering operates when using the value from the > IA32_PQR_ASSOC MSR to count accesses by a task. When reading an RMID > counter, adjust from the logical RMID to the physical > RMID value for the SNC node that it wishes to read and load the > adjusted value into the IA32_QM_EVTSEL MSR. > 4) Divide the L3 cache between the SNC nodes. Divide the value > reported in the resctrl "size" file by the number of SNC > nodes because the effective amount of cache that can be allocated > is reduced by that factor. > 5) Disable the "-o mba_MBps" mount option in SNC mode > because the monitoring is being done per SNC node, while the > bandwidth allocation is still done at the L3 cache scope. > Trying to use this feedback loop might result in contradictory > changes to the throttling level coming from each of the SNC > node bandwidth measurements. > > Signed-off-by: Tony Luck > Tested-by: Shaopeng Tan > Reviewed-by: Peter Newman > Reviewed-by: Reinette Chatre > Reviewed-by: Shaopeng Tan Reviewed-by: Babu Moger > --- > arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ > arch/x86/kernel/cpu/resctrl/core.c | 6 ++++++ > arch/x86/kernel/cpu/resctrl/monitor.c | 16 +++++++++++++--- > arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 +++-- > 4 files changed, 24 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h > index ce3a70657842..e7a75a439c16 100644 > --- a/arch/x86/kernel/cpu/resctrl/internal.h > +++ b/arch/x86/kernel/cpu/resctrl/internal.h > @@ -446,6 +446,8 @@ DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); > > extern struct dentry *debugfs_resctrl; > > +extern unsigned int snc_nodes_per_l3_cache; > + > enum resctrl_res_level { > RDT_RESOURCE_L3, > RDT_RESOURCE_L2, > diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c > index c9315ce8f7bd..cf5aba8a74bf 100644 > --- a/arch/x86/kernel/cpu/resctrl/core.c > +++ b/arch/x86/kernel/cpu/resctrl/core.c > @@ -48,6 +48,12 @@ int max_name_width, max_data_width; > */ > bool rdt_alloc_capable; > > +/* > + * Number of SNC nodes that share each L3 cache. Default is 1 for > + * systems that do not support SNC, or have SNC disabled. > + */ > +unsigned int snc_nodes_per_l3_cache = 1; > + > static void > mba_wrmsr_intel(struct rdt_ctrl_domain *d, struct msr_param *m, > struct rdt_resource *r); > diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c > index 4e145f5620b0..30b7c3b9b517 100644 > --- a/arch/x86/kernel/cpu/resctrl/monitor.c > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c > @@ -148,8 +148,18 @@ static inline struct rmid_entry *__rmid_entry(u32 rmid) > > static int __rmid_read(u32 rmid, enum resctrl_event_id eventid, u64 *val) > { > + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; > + int cpu = smp_processor_id(); > + int rmid_offset = 0; > u64 msr_val; > > + /* > + * When SNC mode is on, need to compute the offset to read the > + * physical RMID counter for the node to which this CPU belongs. > + */ > + if (snc_nodes_per_l3_cache > 1) > + rmid_offset = (cpu_to_node(cpu) % snc_nodes_per_l3_cache) * r->num_rmid; > + > /* > * As per the SDM, when IA32_QM_EVTSEL.EvtID (bits 7:0) is configured > * with a valid event code for supported resource type and the bits > @@ -158,7 +168,7 @@ static int __rmid_read(u32 rmid, enum resctrl_event_id eventid, u64 *val) > * IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62) > * are error bits. > */ > - wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid); > + wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid + rmid_offset); > rdmsrl(MSR_IA32_QM_CTR, msr_val); > > if (msr_val & RMID_VAL_ERROR) > @@ -783,8 +793,8 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) > int ret; > > resctrl_rmid_realloc_limit = boot_cpu_data.x86_cache_size * 1024; > - hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale; > - r->num_rmid = boot_cpu_data.x86_cache_max_rmid + 1; > + hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale / snc_nodes_per_l3_cache; > + r->num_rmid = (boot_cpu_data.x86_cache_max_rmid + 1) / snc_nodes_per_l3_cache; > hw_res->mbm_width = MBM_CNTR_WIDTH_BASE; > > if (mbm_offset > 0 && mbm_offset <= MBM_CNTR_WIDTH_OFFSET_MAX) > diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c > index 21bbd832f3f2..79d57dade568 100644 > --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c > +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c > @@ -1425,7 +1425,7 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, > } > } > > - return size; > + return size / snc_nodes_per_l3_cache; > } > > /* > @@ -2298,7 +2298,8 @@ static bool supports_mba_mbps(void) > struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; > > return (is_mbm_local_enabled() && > - r->alloc_capable && is_mba_linear()); > + r->alloc_capable && is_mba_linear() && > + snc_nodes_per_l3_cache == 1); > } > > /*