[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240701125921.GG20127@noisy.programming.kicks-ass.net>
Date: Mon, 1 Jul 2024 14:59:21 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Dhananjay Ugwekar <Dhananjay.Ugwekar@....com>
Cc: mingo@...hat.com, acme@...nel.org, namhyung@...nel.org,
mark.rutland@....com, alexander.shishkin@...ux.intel.com,
jolsa@...nel.org, irogers@...gle.com, adrian.hunter@...el.com,
kan.liang@...ux.intel.com, tglx@...utronix.de, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, kees@...nel.org,
gustavoars@...nel.org, rui.zhang@...el.com,
oleksandr@...alenko.name, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org,
ananth.narayan@....com, gautham.shenoy@....com,
kprateek.nayak@....com, ravi.bangoria@....com, sandipan.das@....com,
linux-pm@...r.kernel.org
Subject: Re: [PATCH v3 02/10] perf/x86/rapl: Fix the energy-pkg event for AMD
CPUs
On Mon, Jun 24, 2024 at 05:58:59AM +0000, Dhananjay Ugwekar wrote:
> diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
> index b985ca79cf97..73be25e1f4b4 100644
> --- a/arch/x86/events/rapl.c
> +++ b/arch/x86/events/rapl.c
> @@ -103,6 +103,10 @@ static struct perf_pmu_events_attr event_attr_##v = { \
> .event_str = str, \
> };
>
> +#define rapl_pmu_is_pkg_scope() \
> + (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || \
> + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
> +
> struct rapl_pmu {
> raw_spinlock_t lock;
> int n_active;
> @@ -140,9 +144,21 @@ static unsigned int rapl_cntr_mask;
> static u64 rapl_timer_ms;
> static struct perf_msr *rapl_msrs;
>
> +static inline unsigned int get_rapl_pmu_idx(int cpu)
> +{
> + return rapl_pmu_is_pkg_scope() ? topology_logical_package_id(cpu) :
> + topology_logical_die_id(cpu);
> +}
> +
> +static inline const struct cpumask *get_rapl_pmu_cpumask(int cpu)
> +{
> + return rapl_pmu_is_pkg_scope() ? topology_core_cpumask(cpu) :
> + topology_die_cpumask(cpu);
> +}
This wants a comment. The next time someone looks at this we're going to
be confused.
> @@ -677,6 +696,9 @@ static int __init init_rapl_pmus(void)
> {
> int nr_rapl_pmu = topology_max_packages() * topology_max_dies_per_package();
>
> + if (rapl_pmu_is_pkg_scope())
> + nr_rapl_pmu = topology_max_packages();
> +
How about:
int nr_rapl_pmu = topology_max_packages();
if (!rapl_pmu_is_pkg_scope())
nr_rapl_pmu *= topology_max_dies_per_package();
hmm?
Powered by blists - more mailing lists