Linux-perf-users Archive mirror
 help / color / mirror / Atom feed
From: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
To: <tglx@linutronix.de>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <x86@kernel.org>
Cc: <peterz@infradead.org>, <mingo@redhat.com>,
	<ananth.narayan@amd.com>, <gautham.shenoy@amd.com>,
	<linux-perf-users@vger.kernel.org>,
	<linux-hardening@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<sandipan.das@amd.com>, <alexander.shishkin@linux.intel.com>,
	<irogers@google.com>, <gustavoars@kernel.org>,
	<kprateek.nayak@amd.com>, <ravi.bangoria@amd.com>,
	Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Subject: [PATCH 0/2] Fix energy-pkg event for AMD CPUs
Date: Thu, 2 May 2024 15:21:13 +0530	[thread overview]
Message-ID: <20240502095115.177713-1-Dhananjay.Ugwekar@amd.com> (raw)

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


             reply	other threads:[~2024-05-02  9:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02  9:51 Dhananjay Ugwekar [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240502095115.177713-1-Dhananjay.Ugwekar@amd.com \
    --to=dhananjay.ugwekar@amd.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=ananth.narayan@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gautham.shenoy@amd.com \
    --cc=gustavoars@kernel.org \
    --cc=irogers@google.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=sandipan.das@amd.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).