From: Wyes Karny <wyes.karny@amd.com>
To: Stephane Eranian <eranian@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
hpa@zytor.com, x86@kernel.org, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, gautham.shenoy@amd.com,
ananth.narayan@amd.com
Subject: Re: [PATCH] perf/x86/rapl: Enable Core RAPL for AMD
Date: Tue, 21 Feb 2023 04:53:34 +0000 [thread overview]
Message-ID: <Y/ROTsCSCFtrwwTK@beas> (raw)
In-Reply-To: <CABPqkBTU_gnTr9ayvg220T4pO5NAguvu_UJAkZO2RUATWuMJ3A@mail.gmail.com>
On 20 Feb 13:29, Stephane Eranian wrote:
> On Mon, Feb 20, 2023 at 3:45 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Fri, Feb 17, 2023 at 04:13:54PM +0000, Wyes Karny wrote:
> > > AMD processors support per-package and per-core energy monitoring
> > > through RAPL counters which can be accessed by users running in
> > > supervisor mode.
> > >
> > > Core RAPL counters gives power consumption information per core. For
> > > AMD processors the package level RAPL counter are already exposed to
> > > perf. Expose the core level RAPL counters also.
> > >
> > > sudo perf stat -a --per-core -C 0-127 -e power/energy-cores/
> > >
> > > Output:
> > > S0-D0-C0 2 8.73 Joules power/energy-cores/
> > > S0-D0-C1 2 8.73 Joules power/energy-cores/
> > > S0-D0-C2 2 8.73 Joules power/energy-cores/
> > > S0-D0-C3 2 8.73 Joules power/energy-cores/
> > > S0-D0-C4 2 8.73 Joules power/energy-cores/
> > >
> > > Signed-off-by: Wyes Karny <wyes.karny@amd.com>
> > > ---
> > > arch/x86/events/rapl.c | 5 +++--
> > > 1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
> > > index 52e6e7ed4f78..d301bbbc3b93 100644
> > > --- a/arch/x86/events/rapl.c
> > > +++ b/arch/x86/events/rapl.c
> > > @@ -537,7 +537,7 @@ static struct perf_msr intel_rapl_spr_msrs[] = {
> > > * - want to use same event codes across both architectures
> > > */
> > > static struct perf_msr amd_rapl_msrs[] = {
> > > - [PERF_RAPL_PP0] = { 0, &rapl_events_cores_group, 0, false, 0 },
> > > + [PERF_RAPL_PP0] = { MSR_AMD_CORE_ENERGY_STATUS, &rapl_events_cores_group, test_msr, false, RAPL_MSR_MASK },
> >
> > Stephane, this was an oversight?
> >
> I think it may depend on the CPU model. I remember it returning either
> 0 or bogus values on my systems. They may have improved that.
> The commit msg does not show which CPU model this is run on.
I've tested this on Zen 2, 3 and 4 server systems.
Thanks,
Wyes
>
> >
> > > [PERF_RAPL_PKG] = { MSR_AMD_PKG_ENERGY_STATUS, &rapl_events_pkg_group, test_msr, false, RAPL_MSR_MASK },
> > > [PERF_RAPL_RAM] = { 0, &rapl_events_ram_group, 0, false, 0 },
> > > [PERF_RAPL_PP1] = { 0, &rapl_events_gpu_group, 0, false, 0 },
> > > @@ -764,7 +764,8 @@ static struct rapl_model model_spr = {
> > > };
> > >
> > > static struct rapl_model model_amd_hygon = {
> > > - .events = BIT(PERF_RAPL_PKG),
> > > + .events = BIT(PERF_RAPL_PP0) |
> > > + BIT(PERF_RAPL_PKG),
> > > .msr_power_unit = MSR_AMD_RAPL_POWER_UNIT,
> > > .rapl_msrs = amd_rapl_msrs,
> > > };
> > > --
> > > 2.34.1
> > >
next prev parent reply other threads:[~2023-02-21 4:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 16:13 [PATCH] perf/x86/rapl: Enable Core RAPL for AMD Wyes Karny
2023-02-19 11:52 ` Oleksandr Natalenko
2023-03-01 18:32 ` Wyes Karny
2023-02-20 11:45 ` Peter Zijlstra
2023-02-20 21:29 ` Stephane Eranian
2023-02-21 4:53 ` Wyes Karny [this message]
2023-02-21 8:50 ` Stephane Eranian
2023-02-28 14:20 ` Muhammad Usama Anjum
2023-02-28 15:55 ` Wyes Karny
2023-03-01 18:27 ` Wyes Karny
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=Y/ROTsCSCFtrwwTK@beas \
--to=wyes.karny@amd.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=ananth.narayan@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=gautham.shenoy@amd.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.