linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix energy-pkg event for AMD CPUs
@ 2024-05-02  9:51 Dhananjay Ugwekar
  2024-05-02  9:51 ` [PATCH 1/2] perf/x86/rapl: Rename maxdie to nr_rapl_pmu and dieid to rapl_pmu_idx Dhananjay Ugwekar
  2024-05-02  9:51 ` [PATCH 2/2] perf/x86/rapl: Fix the energy-pkg event for AMD CPUs Dhananjay Ugwekar
  0 siblings, 2 replies; 7+ messages in thread
From: Dhananjay Ugwekar @ 2024-05-02  9:51 UTC (permalink / raw)
  To: tglx, bp, dave.hansen, x86
  Cc: peterz, mingo, ananth.narayan, gautham.shenoy, linux-perf-users,
	linux-hardening, linux-kernel, sandipan.das, alexander.shishkin,
	irogers, gustavoars, kprateek.nayak, ravi.bangoria,
	Dhananjay Ugwekar

After commit 63edbaa48a57 ("x86/cpu/topology: Add support for the AMD 0x80000026 leaf"), 
on AMD processors that support extended CPUID leaf 0x80000026, the 
topology_die_cpumask() and topology_logical_die_id(), no longer return 
the package cpumask and package id, instead they return the CCD (Core 
Complex Die) mask and CCD id respectively. This leads to the energy-pkg 
event scope to be modified to CCD instead of package.

This is functionally incorrect as the AMD energy-pkg is a package scope 
event.

On a 12 CCD 1 Package AMD Zen4 Genoa machine:

$ cat /sys/devices/power/cpumask
0,8,16,24,32,40,48,56,64,72,80,88.

Expected cpumask for 1 Package AMD CPUs energy-pkg event is supposed to 
be just "0".

This in turn leads to incorrect values of package energy consumption.

$ perf stat -C 100 -e power/energy-pkg/ sleep 1

 Performance counter stats for 'CPU(s) 100':

             36.60 Joules power/energy-pkg/

       1.005821050 seconds time elapsed

$ perf stat -a -e power/energy-pkg/ sleep 1

 Performance counter stats for 'system wide':

            414.03 Joules power/energy-pkg/

       1.005252132 seconds time elapsed

In both cases the energy consumption values should have been the same,
but instead, due to the incorrect cpumask, the values are being
aggregated at a CCD level in the second case.

Replacing the die macros with the package macros(for AMD CPUs) fixes 
this issue. 

This patch cleanly applies on top of tip/master after
commit acf68d98cae8 ("perf/x86/rapl: Add support for Intel Lunar Lake"),
but not on Linus' tree.

Dhananjay Ugwekar (2):
  perf/x86/rapl: Rename maxdie to nr_rapl_pmu and dieid to rapl_pmu_idx
  perf/x86/rapl: Fix the energy-pkg event for AMD CPUs

 arch/x86/events/rapl.c | 44 +++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-27  6:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-02  9:51 [PATCH 0/2] Fix energy-pkg event for AMD CPUs Dhananjay Ugwekar
2024-05-02  9:51 ` [PATCH 1/2] perf/x86/rapl: Rename maxdie to nr_rapl_pmu and dieid to rapl_pmu_idx Dhananjay Ugwekar
2024-05-02  9:51 ` [PATCH 2/2] perf/x86/rapl: Fix the energy-pkg event for AMD CPUs Dhananjay Ugwekar
2024-05-03  9:54   ` Ingo Molnar
2024-05-03 10:07     ` Dhananjay Ugwekar
2024-05-04  4:09     ` [PATCH v2 " Dhananjay Ugwekar
2024-05-27  6:27       ` Dhananjay Ugwekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).