Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1990460rdb; Tue, 20 Feb 2024 13:24:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWH8kVhdtCcE+5xzt9yv6QMLHrGrrCSU3SZpnz5j7Cndsypp5Jb1ktp6bxyXjzFdGe3C1+YiA9BQiXU/Ovz34exTTP4YfC60ox11BIGNw== X-Google-Smtp-Source: AGHT+IGc6rqWRROaHrpErnhX5uD8MnSXNJrjLMByYB2ZPrMO9uRx5BO/jhn3wNAaRmRcSOM40Z0l X-Received: by 2002:a05:6a21:3a85:b0:19e:a9c2:e0cb with SMTP id zv5-20020a056a213a8500b0019ea9c2e0cbmr24186998pzb.25.1708464257441; Tue, 20 Feb 2024 13:24:17 -0800 (PST) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fb16-20020a056a002d9000b006e45bb6803bsi4718292pfb.81.2024.02.20.13.24.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 13:24:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73723-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=R3q8U5+Z; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-73723-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73723-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E8A46B2234C for ; Tue, 20 Feb 2024 21:24:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF2F1151CF6; Tue, 20 Feb 2024 21:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="R3q8U5+Z" Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2068.outbound.protection.outlook.com [40.107.96.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE3FB151CD6; Tue, 20 Feb 2024 21:24:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.68 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708464247; cv=fail; b=E/+IlCDGQalgreKWt0B1p+PvK9eGznXVKFSrlF/EeZjwBiFSq0PeWgXpTEa3tDV53OGhXV8SJZJrmflfv4sUkb7H64XJBpEIxNnIQqeCeBnf7LxwwMfc9vwzaenHpqZAjHT5SkCXYqkP0zbntyI0CQPAWgurnh4AmLKVuKLybDw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708464247; c=relaxed/simple; bh=c78WLIhi26KuXf0+aMSfy0T+FDwgQ1xo0R8kf/6Bjyw=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=FEkWI3K0Wr7FUgk5SzB9bd/uZ7KrkaGx5L3YLxl9+ov6L5OUefm7GVJOEbV3Fjgc+B1CqDntJwkjuFA3/d1Cfx/Wxd+h03TAxh1N3+6ETGjS34bTB64WUZUvpVJFlJVK554NiP+txtXekV0ILwPJygjaoS7Cy+RklH98CkcMXWg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=R3q8U5+Z; arc=fail smtp.client-ip=40.107.96.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a6o2sO8iFJxAlnxskbqWWALJlSeXU1pEcgH8pKHsNQ0P7/pC1uXJRHqwwE76sa4tgvf4nLErVspZjl082Z1Rt7Xa1KEFoLD/3zmYue+QDD/kAt+0JzNsb5uR9JFSGkgRHB8zadst8CxE88xwtXTElyHstnQVQ44JI7XLvc7OhKyw6zMbbQCIapJ9kNkYUhWsbbQ7U6N4iBD2yCbybwH+lc8J1tQXIBReJLN1A4Ms30/Na8PUrtjwOwNRzsgyZaoFrN7MV1Zvapl2AaOeuzRvdwkzCyEg0aXvsXcm94UjBNx/maafMXo+b3vesDVGjot3PHBK7PnuHf8D2pgXEQA94Q== 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=z/WwrtRXVYok7ijd2MPeT0QDJTe4J+ubp9Zrv9S5zW4=; b=BVhySqHj9dz/P+JlVx76uXD2lB6b77aKOQvCy80CVgTog8p9Ts6Bge1e+751pwgHJ0de8UT1ukVSzOKm/uQ/+kzylGZPRP7FlWJPKIwZgDgkL9652oo4sVE6+4Wh+tOHfppGRDHFKOT7diij29lAlc8/1kZrSFOruOxlZhKYEjeXXfUlBS9igX0k+hRZUvDo+UTGjC61ggKUPoB6Q+7SXAFCcYp/btj+qIWzmF/gd2SLqUAaogqnKJplQkmNueZP+mvNCEvPP+Ocqt6ZiQJg2dEkxb+AAuxm2c2BVq8Cd8uwac/Z/G3PVw9W99oHF1Tbb4jCVyQvc7FO+8oXdH02tw== 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=z/WwrtRXVYok7ijd2MPeT0QDJTe4J+ubp9Zrv9S5zW4=; b=R3q8U5+Zw49bGt2Zmxei+ApKW19cXioJ+CxH2o3mjIFU+iVdBaKpR+4jcgTcGd6ZJsnhbiS/WtOygXBDXQSzm5RyBhOTtQDQMrMlanM5wxEo9kydfD/T7jWQWuqmAFQfe96sD2dySY8Clq0yWsTtEo2WFJD70TwM2HhfJkQVsDM= 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 CH3PR12MB7524.namprd12.prod.outlook.com (2603:10b6:610:146::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.19; Tue, 20 Feb 2024 21:24:03 +0000 Received: from MW3PR12MB4553.namprd12.prod.outlook.com ([fe80::ee3b:5116:72be:be7a]) by MW3PR12MB4553.namprd12.prod.outlook.com ([fe80::ee3b:5116:72be:be7a%4]) with mapi id 15.20.7316.018; Tue, 20 Feb 2024 21:24:03 +0000 Message-ID: Date: Tue, 20 Feb 2024 15:23:59 -0600 User-Agent: Mozilla Thunderbird Reply-To: babu.moger@amd.com Subject: Re: [PATCH v2 06/17] x86/resctrl: Introduce interface to display number of ABMC counters Content-Language: en-US To: James Morse , corbet@lwn.net, fenghua.yu@intel.com, reinette.chatre@intel.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, paulmck@kernel.org, rdunlap@infradead.org, tj@kernel.org, peterz@infradead.org, yanjiewtw@gmail.com, kim.phillips@amd.com, lukas.bulwahn@gmail.com, seanjc@google.com, jmattson@google.com, leitao@debian.org, jpoimboe@kernel.org, rick.p.edgecombe@intel.com, kirill.shutemov@linux.intel.com, jithu.joseph@intel.com, kai.huang@intel.com, kan.liang@linux.intel.com, daniel.sneddon@linux.intel.com, pbonzini@redhat.com, sandipan.das@amd.com, ilpo.jarvinen@linux.intel.com, peternewman@google.com, maciej.wieczor-retman@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, eranian@google.com References: <20231201005720.235639-1-babu.moger@amd.com> <5ad6f627-45c6-4c2b-b761-c74f0fe85f6c@arm.com> From: "Moger, Babu" In-Reply-To: <5ad6f627-45c6-4c2b-b761-c74f0fe85f6c@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN1PR12CA0089.namprd12.prod.outlook.com (2603:10b6:802:21::24) To MW3PR12MB4553.namprd12.prod.outlook.com (2603:10b6:303:2c::19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR12MB4553:EE_|CH3PR12MB7524:EE_ X-MS-Office365-Filtering-Correlation-Id: 6934ffe4-d3ae-4338-8cd7-08dc325a42dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mgDGBG1ngkVKzlOHz3Mf2BdFcKIahfNBS91PaRljHPmwwAJnnrmIARFCaE8G56NRfWoZSprd7SV0XTuEh7+a1a6QYPxtV944bgfc4VSEIQSDMBhx1Tb+SDnTX055TBTsczp+L8CqkdO98ZoNCRKycVo0XYefzI0pSPb8jnRruZZdM6aAdFh57jdmBJvWMbl5Xw3ISHv8uP0Rx7GIzivCcFU+sgeUH5RhFo+ce2dIKfX+8TesauOqxmrZXnQVdR/hMRO7r054SJLGhqeRuURLWPbFRINZWLc0UOaxYYLeqYmuZU0EzM600XXFhXoWSOyOuCiezufDI6a4swb/V9XVuwHx4RFFnBdjaDh3P7u0go9VD1ANcT4llk6MCtNcaGaanaBiJKJurEKWAripp/swYq+2PEap9cEsEo1MGWz+x7PwzXdoO6z/f+Iu1Z9GAY5ocPfqPYVvp8QApQjwtAxYJbHMWVOoTmVOVZLOGwgv/jc+FbTxCvUffAjrl+hbCxZPthVRBixqFiRD3cDKeHJsOpU4T9sLDmAiko8N7RJTyxs= 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);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aHZjYTZlbm5aWUdsU2l4NEFacVJyRTdYV2FmVHp1YjU0VlNrSEVKN2doaC9r?= =?utf-8?B?cm5vTHVNbkdWaWJsdGk2dG94NTI1S1FLREpMZmJoTmZzMUxTejhYQkVsVUc3?= =?utf-8?B?dDZ1cStjSHVKS0c4WWFXQ3BkN2FsV3ZtZmFFR2pIYzFCZkhpMklPNnptdW5x?= =?utf-8?B?dXJFb1ZEc2E1aGV2VG9FalAzaStPdE1XeXlnUVM1eTVRSXBIdGdLWEM1L2tU?= =?utf-8?B?emhxM1UwOFVXQm92R21YQ2dJaHJyVlhzUTFEc0NiZU5WT2E3blJsaWozR3BS?= =?utf-8?B?Q0RFMEhYWTNVeTFRcE9BV203a3JLVFBYSFZOc1VETDdKb1BDcjUrc09MenJS?= =?utf-8?B?YzVWWDNFU2FTbXZzTGQ4UnRENDdZTEJpWkU3OVhOQ1Boa2lGRWVCM1RlTFE3?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ange-CrossTenant-AuthSource: MW3PR12MB4553.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2024 21:24:03.1387 (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: SWZYdlX+UYpi0kkTr6FWGZiJeEk3J34dM6hh0QHfWo/tTFMABSlTx3YWmemRz98+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7524 Hi James, On 2/20/24 12:14, James Morse wrote: > Hi Babu, > > On 19/01/2024 18:22, Babu Moger wrote: >> The ABMC feature provides an option to the user to pin (or assign) the >> RMID to the hardware counter and monitor the bandwidth for a longer >> duration. There are only a limited number of hardware counters. >> >> Provide the interface to display the number of ABMC counters supported. > > >> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c >> index a6c336b6de61..fa492ea820f0 100644 >> --- a/arch/x86/kernel/cpu/resctrl/monitor.c >> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c >> @@ -823,6 +823,10 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) >> resctrl_file_fflags_init("mbm_local_bytes_config", >> RFTYPE_MON_INFO | RFTYPE_RES_CACHE); >> } >> + > >> + if (rdt_cpu_has(X86_FEATURE_ABMC)) > > Please put this in a header and calling it something like > resctrl_arch_has_assignable_counters(). These X86 feature definition macros aren't > available on other architectures! Sure. Will do. > > >> + resctrl_file_fflags_init("mbm_assignable_counters", >> + RFTYPE_MON_INFO); >> } >> >> l3_mon_evt_init(r); >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index 3e233251e7ed..53be5cd1c28e 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -811,6 +811,17 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of, >> return ret; >> } >> >> +static int rdtgroup_mbm_assignable_counters_show(struct kernfs_open_file *of, >> + struct seq_file *s, void *v) >> +{ >> + struct rdt_resource *r = of->kn->parent->priv; > >> + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); > > (After the move out to /fs/ the resctrl_to_arch_res() macro is private to the arch code. > Needing to do this when providing a value to user-space is the indication that the value > should be in struct rdt_resource instead!) Ok. Sure. Will > > >> + seq_printf(s, "%d\n", hw_res->mbm_assignable_counters); >> + >> + return 0; >> +} >> + >> #ifdef CONFIG_PROC_CPU_RESCTRL >> >> /* > > > Thanks, > > James -- Thanks Babu Moger