Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp200394lqq; Wed, 12 Jun 2024 23:40:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4mOou+QWSXpZ3Yq+PXeh5fQipYOQSbj82OdeVNUIkL6RYHtI6wX0pB3r7wW/gC48IWFAA7xcXiVle5VT/1zjR4GiZMg4x8r38/d9B1A== X-Google-Smtp-Source: AGHT+IF+hd0foQkYiNMjhYiJQ9OT4COK+4dKZc5DASnmXejIYtkNooS4tq+KIKjRcpYH9KM5RaWD X-Received: by 2002:a05:6a20:40a0:b0:1b6:1ed4:e91b with SMTP id adf61e73a8af0-1b8a9c3a5c4mr2786350637.39.1718260819217; Wed, 12 Jun 2024 23:40:19 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4c4706a4asi815089a91.88.2024.06.12.23.40.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 23:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212643-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=qyMj4Nuy; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-212643-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212643-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CE3E4282C5F for ; Thu, 13 Jun 2024 06:40:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18D8A137914; Thu, 13 Jun 2024 06:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qyMj4Nuy" Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) (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 89C8B13698D; Thu, 13 Jun 2024 06:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.59 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718260807; cv=fail; b=BNANpCmwhlE8JtGq/C900hQdZxDpIWrkDqRG7Wh+66or5oDC1GpV6ABRyaLylBwlQwqK7XqGdeTMSFpBlhM2A3PZuEWNeudsB9Ol6e1AJoNXoyavXjIXMI2UUaNow/3V3SAEB3faLGR5zgUnCd8F8jF9qXGvaw4hYwIwTfypWEs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718260807; c=relaxed/simple; bh=HhURp30FXA8tHyoSw+u2GmJrLNUS3WH7OfBieXxyrOA=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=PhnHPRBlnwai7Q/ada3Ny53q6HYmKOfhbM9QqnPznQg6o2NA7iMER1cjk390PKZSOoXRgCvz5e9qNb6InQCL5+uTrMi1CLBT455PSCEWN7y9JhwWyB4TjmAPPCTQr550OVgDHNmQ/bxLnL0fZZ0q02z+ViwXrWjQc9djz37m/Do= 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=qyMj4Nuy; arc=fail smtp.client-ip=40.107.92.59 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=nimQl0XoxVFekDNXhEAxX5jT803SyQdrlQ1S4X3ntkKPJKm6KnHAMNoIOs2MtTF1hqZM9ARf0adf4C6vxZ6FShu1l8V/VvYjy7PZo29CZHUoqSdkheIexIUMHm25o46bVB1kZyIrMXPHz3dajX8tBpPxqXozICxoxjV6Uu9Fmzlypdhsv8VD2F4aKHlH0zWedMzlHahrBcKmUFbI701v62pVEKOWvCFDEHa/yC23wu4/kJ+0OUOgPw4twZqP+4wtrR0RwsNb+EAZzzQe6WFFm0ztAzQ5s0bOqtjWC8LTMnsZtIFo2gZZ8VeSCP2LvvjJMqSQBL7x+E8OppGedN/w6g== 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=h+8V938IAtMeNqTq1/iIHSmATccvzkRqewCBReLfqYE=; b=MK5YvEQNcfw7GP5tOksezSDIQWFKrc3fVUEXWznlfjwJkGHQafwSXNZmLi0lNLymSLJiz55PD5QyqGFdPVViv11gsd2WxK7ftJ/IMOyC0LL9vBjXop67rtbCRRXmY+NuUURj1QRYFwlb1/wuCeGeWxpI+iBELdpanji+InfVTCHGWzoTkF1vincbhiTBs1mBeU+zXbWHZn6B2pQ1j/uJ+GEoriEWKvQFNZnapaUBMYQ5i9GNK0H88UMeN/CXWSIU08eOdR8SgE9nHgZeDGc6nVIckNouA8oQ1VWuLcKmQFrWGVSIEUdXirkYKpF8QKDWyfmKsgKjq1oN5sGxBqJi1w== 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=h+8V938IAtMeNqTq1/iIHSmATccvzkRqewCBReLfqYE=; b=qyMj4Nuy8RcK4+bGMIphKenC8UY1agy78yLUL+oKjPmarxfTVWq/tvFSW4b4swCaQAAkk9r67qvgdoVXsxUhLnX1EFRh8FpbBCaGQL+TJxs+ExeaUbzvO4s+w2iDqnm/rR963l6P51Is03utTu/INxTGZ82U11fSUL47U55rqKU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from LV8PR12MB9207.namprd12.prod.outlook.com (2603:10b6:408:187::15) by BY5PR12MB4131.namprd12.prod.outlook.com (2603:10b6:a03:212::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Thu, 13 Jun 2024 06:40:02 +0000 Received: from LV8PR12MB9207.namprd12.prod.outlook.com ([fe80::3a37:4bf4:a21:87d9]) by LV8PR12MB9207.namprd12.prod.outlook.com ([fe80::3a37:4bf4:a21:87d9%6]) with mapi id 15.20.7633.036; Thu, 13 Jun 2024 06:40:01 +0000 Message-ID: Date: Thu, 13 Jun 2024 12:09:47 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 6/6] perf/x86/rapl: Add per-core energy counter support for AMD CPUs To: "Zhang, Rui" , "alexander.shishkin@linux.intel.com" , "dave.hansen@linux.intel.com" , "Hunter, Adrian" , "mingo@redhat.com" , "irogers@google.com" , "tglx@linutronix.de" , "gustavoars@kernel.org" , "kan.liang@linux.intel.com" , "kees@kernel.org" , "mark.rutland@arm.com" , "peterz@infradead.org" , "bp@alien8.de" , "acme@kernel.org" , "jolsa@kernel.org" , "x86@kernel.org" , "namhyung@kernel.org" Cc: "ravi.bangoria@amd.com" , "kprateek.nayak@amd.com" , "gautham.shenoy@amd.com" , "linux-perf-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hardening@vger.kernel.org" , "sandipan.das@amd.com" , "ananth.narayan@amd.com" , "linux-pm@vger.kernel.org" References: <20240610100751.4855-1-Dhananjay.Ugwekar@amd.com> <20240610100751.4855-7-Dhananjay.Ugwekar@amd.com> Content-Language: en-US From: Dhananjay Ugwekar In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2P153CA0022.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::8) To LV8PR12MB9207.namprd12.prod.outlook.com (2603:10b6:408:187::15) 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: LV8PR12MB9207:EE_|BY5PR12MB4131:EE_ X-MS-Office365-Filtering-Correlation-Id: 585d2030-eed6-440f-0132-08dc8b73a694 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230034|376008|1800799018|366010|7416008|921014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MzAzcGU5ZDJ5V2FML085K2l0WlZRV3RSMklRblEwVm53NTF1ejhkeDZKejQ3?= =?utf-8?B?RFpmN2NzOTV2WWx4alUwZlBSVTNVVTlMYmdqYk1LV1lzcGdyUXVsalZTbFJP?= =?utf-8?B?RkhYSWxScm1GQSthYjZGZ1JLeWhKZGpOT0EyNTl1cUlic25RQm9jS0lMNGha?= =?utf-8?B?ZWM4dm9XZjZxQWdrK3dRQXYwMCtwak5meC9vQ1Vmb1RTY1JEdU9MeDh4d0Mw?= =?utf-8?B?STltN2w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0txdzlY?= =?utf-8?B?Q0NtdjFReVZlUXp6amdoZ2o5M1pFTXJqc0doSTh3dTYwMzVuS04xdXl4WFk2?= =?utf-8?B?RTN0RHdtdVd2YXp5cG5sQThGSitQWXNzWEdUNXV6YTRqbGV1Z2drWEM0VDFF?= =?utf-8?B?Z1pYN2dLQXdzMXhjbHRPV05vOGQ5ZVB1akYwaHVrZk82d0lZMWxPZG01cWtp?= =?utf-8?B?M0FzajFLSVBQam9NaFloajFMdUkvZDg5K2hBemJTcEQ4cjdKUm9hRWlkaEF4?= =?utf-8?B?QnV5OTY2MDNNbnV4aFhuZHpOWlE2ekIzMXNHMmlNSk1IYW5vZGMrLzRWc3Bz?= =?utf-8?B?eVNSWHU3R3M2K2FQTmUxMVRDeVpaY28rYWxtd2xTRmdSTjc1WFdWWW1ZRHYz?= =?utf-8?B?dHpaYjFyMFhQMHNVdDhrVlRFd01MYko2OERodTdQZHQ2cUdNQkY4V0x4UHp6?= =?utf-8?B?L2hEQUVkcndRUlU4SDVFVkhYUjlZK2tBbHdhK3BBdkJJT09IM3J0MnE2d2x2?= =?utf-8?B?eVlqOWxyc05iYzkyLzdpYjhrVzU2Z0FJU3d1dE00Y0RZL3grNDlkM1k1R2k1?= =?utf-8?B?UVBMaWFjT3UvTVpJcHVrdEZudkI3MVlKQ1QrRFBrdG1yUll1d05QcVRUZXUx?= =?utf-8?B?aGlVeXo5USt2OW1MYUxGTlltMWxKV3JuZ1Q3QU1zUzZEMjF3R29RWitYb2N5?= =?utf-8?Q?dG5qI69jFUQy6nm7F93CUY+2vN6M92UOYmYt0=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV8PR12MB9207.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230034)(376008)(1800799018)(366010)(7416008)(921014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-M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B?SWV2MytrT1l4NCtrMktJd0lha1B3dFQyNnZFSzhiKzVKUzJQcGlOamJucWhn?= =?utf-8?B?em1KTVluRHJYZkNFUTB5MU05ZEtiaUpqYTlGcEFGNGFIR1VWRDVhTXpaN2JX?= =?utf-8?B?V09KaTd3RXV0T3FCaytMSGV1TWE3Z3pjK2QrTHVEUnR1ZWd1TjFRcE5mT2ls?= =?utf-8?B?VDdmdGszRGN1TW8rd0ppa3krQzJINWpicXBVcmhaU3VIcFlQNW1WRTJyd2xR?= =?utf-8?B?L3JJdkNTSUt3ZlBqNXlFdnJ1Nm52V2toZUlXZmRIeHZTMGIyTVdYbmFRUW1k?= =?utf-8?B?M1k1V1RFMzFRYnFKdm5rcWtlQldDSVp3OC9QcEFqRDdPSlNwVEJhWjA4eTBN?= =?utf-8?Q?YsdjfX9QBTPsFBkG5Ng2d+Rgy?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 585d2030-eed6-440f-0132-08dc8b73a694 X-MS-Exchange-CrossTenant-AuthSource: LV8PR12MB9207.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 06:40:01.5262 (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: /oQgPxNVtQHnXxd2OR5qRD1d2gIOCVXjow9mz4VGct8crLM3lXsynulvQfMzWtGSOw3Jh091a+nlNOVHCuaIzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4131 Hi Rui, On 6/11/2024 2:00 PM, Zhang, Rui wrote: >> @@ -345,9 +353,14 @@ static int rapl_pmu_event_init(struct perf_event >> *event) >>         u64 cfg = event->attr.config & RAPL_EVENT_MASK; >>         int bit, ret = 0; >>         struct rapl_pmu *rapl_pmu; >> +       struct rapl_pmus *curr_rapl_pmus; >>   >>         /* only look at RAPL events */ >> -       if (event->attr.type != rapl_pmus->pmu.type) >> +       if (event->attr.type == rapl_pmus->pmu.type) >> +               curr_rapl_pmus = rapl_pmus; >> +       else if (rapl_pmus_per_core && event->attr.type == >> rapl_pmus_per_core->pmu.type) >> +               curr_rapl_pmus = rapl_pmus_per_core; >> +       else >>                 return -ENOENT; > > can we use container_of(event->pmu, struct rapl_pmus, pmu)? Yes! that would be cleaner, will add it in next version. > >>   >>         /* check only supported bits are set */ >> @@ -374,9 +387,14 @@ static int rapl_pmu_event_init(struct perf_event >> *event) >>                 return -EINVAL; >>   >>         /* must be done before validate_group */ >> -       rapl_pmu = cpu_to_rapl_pmu(event->cpu); >> +       if (curr_rapl_pmus == rapl_pmus_per_core) >> +               rapl_pmu = curr_rapl_pmus- >>> rapl_pmu[topology_core_id(event->cpu)]; >> +       else >> +               rapl_pmu = curr_rapl_pmus- >>> rapl_pmu[get_rapl_pmu_idx(event->cpu)]; >> + >>         if (!rapl_pmu) >>                 return -EINVAL; > > Current code has PERF_EV_CAP_READ_ACTIVE_PKG flag set. > Can you help me understand why it does not affect the new per-core pmu? Good question, I went back and looked thru the code, it turns out that we are not going thru the code path that checks this flag and decides whether to run on the local cpu(cpu on which perf is running) or the event->cpu. So, having or not having this flag doesnt make a difference here, I did a small experiment for this. On a single package system, any core should be able to read the energy-pkg RAPL MSR and return the value, so there would be no need for a smp call to the event->cpu, but if we look thru the ftrace below we can see that only core 0 executes the pmu event even though we launched the perf stat for core 1. -------------------------------------------------------------------------- root@shatadru:/sys/kernel/tracing# perf stat -C 1 -e power/energy-pkg/ -- dd if=/dev/zero of=/dev/null bs=1M count=100000 100000+0 records in 100000+0 records out 104857600000 bytes (105 GB, 98 GiB) copied, 2.03295 s, 51.6 GB/s Performance counter stats for 'CPU(s) 1': 231.59 Joules power/energy-pkg/ 2.033916467 seconds time elapsed root@shatadru:/sys/kernel/tracing# echo 0 > tracing_on root@shatadru:/sys/kernel/tracing# cat trace # tracer: function # # entries-in-buffer/entries-written: 12/12 #P:192 # # _-----=> irqs-off/BH-disabled # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / _-=> migrate-disable # |||| / delay # TASK-PID CPU# ||||| TIMESTAMP FUNCTION # | | | ||||| | | perf-3309 [096] ...1. 3422.558183: rapl_get_attr_cpumask <-dev_attr_show perf-3309 [001] ...1. 3422.559436: rapl_pmu_event_init <-perf_try_init_event perf-3309 [001] ...1. 3422.559441: rapl_pmu_event_init <-perf_try_init_event perf-3309 [001] ...1. 3422.559449: rapl_pmu_event_init <-perf_try_init_event perf-3309 [001] ...1. 3422.559537: smp_call_function_single <-event_function_call <-- smp call to the event owner cpu(i.e. CPU0) -0 [000] d.h3. 3422.559544: rapl_pmu_event_add <-event_sched_in <-- CPU# column changed to 0 -0 [000] d.h4. 3422.559545: __rapl_pmu_event_start <-rapl_pmu_event_add perf-3309 [001] ...1. 3424.593398: smp_call_function_single <-event_function_call <-- smp call to the event owner cpu(i.e. CPU0) -0 [000] d.h3. 3424.593403: rapl_pmu_event_del <-event_sched_out <-- CPU# column changed to 0 -0 [000] d.h3. 3424.593403: rapl_pmu_event_stop <-rapl_pmu_event_del -0 [000] d.h4. 3424.593404: rapl_event_update.isra.0 <-rapl_pmu_event_stop perf-3309 [001] ...1. 3424.593514: smp_call_function_single <-event_function_call -------------------------------------------------------------------------- So, as we always use the event->cpu to run the event, the per-core PMU is not being affected by this flag. Anyway in next version, I will only selectively enable this flag for package scope events. But we will need to look into fixing this ineffective flag. > >> + >>         event->cpu = rapl_pmu->cpu; >>         event->pmu_private = rapl_pmu; >>         event->hw.event_base = rapl_msrs[bit].msr; >> @@ -408,17 +426,38 @@ static struct attribute_group >> rapl_pmu_attr_group = { >>         .attrs = rapl_pmu_attrs, >>  }; >>   >> +static ssize_t rapl_get_attr_per_core_cpumask(struct device *dev, >> +                                            struct device_attribute >> *attr, char *buf) >> +{ >> +       return cpumap_print_to_pagebuf(true, buf, >> &rapl_pmus_per_core->cpumask); >> +} >> + >> +static struct device_attribute dev_attr_per_core_cpumask = >> __ATTR(cpumask, 0444, >> +                                                                >> rapl_get_attr_per_core_cpumask, >> +                                                                >> NULL); > > DEVICE_ATTR I was not able to use DEVICE_ATTR, because there is already a "device_attribute dev_attr_cpumask_name" created for package PMU cpumask using DEVICE_ATTR(). So I had to create a "device_attribute dev_attr_per_core_cpumask" manually to avoid variable name clash. > >> + >> +static struct attribute *rapl_pmu_per_core_attrs[] = { >> +       &dev_attr_per_core_cpumask.attr, >> +       NULL, >> +}; >> + >> +static struct attribute_group rapl_pmu_per_core_attr_group = { >> +       .attrs = rapl_pmu_per_core_attrs, >> +}; >> + >>  RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); >>  RAPL_EVENT_ATTR_STR(energy-pkg  ,   rapl_pkg, "event=0x02"); >>  RAPL_EVENT_ATTR_STR(energy-ram  ,   rapl_ram, "event=0x03"); >>  RAPL_EVENT_ATTR_STR(energy-gpu  ,   rapl_gpu, "event=0x04"); >>  RAPL_EVENT_ATTR_STR(energy-psys,   rapl_psys, "event=0x05"); >> +RAPL_EVENT_ATTR_STR(energy-per-core,   rapl_per_core, "event=0x06"); > > energy-per-core is for a separate pmu, so the event id does not need to > be 6. The same applies to PERF_RAPL_PERCORE. Correct, will fix in next version. > >>   >>  static struct rapl_model model_amd_hygon = { >> -       .events         = BIT(PERF_RAPL_PKG), >> +       .events         = BIT(PERF_RAPL_PKG) | >> +                         BIT(PERF_RAPL_PERCORE), >>         .msr_power_unit = MSR_AMD_RAPL_POWER_UNIT, >>         .rapl_msrs      = amd_rapl_msrs, >> +       .per_core = true, >>  }; > > can we use bit PERF_RAPL_PERCORE to check per_core pmu suppot? Makes sense, will modify. > > Just FYI, arch/x86/events/intel/cstate.c handles package/module/core > scope cstate pmus. It uses a different approach in the probing part, > which IMO is clearer. Yes, I went thru it, I see that separate variables are being used to mark the valid events for package and core scope and a wrapper fn around perf_msr_probe is created, will see if that will make sense here as well. Thanks for the review, Dhananjay > > thanks, > rui >