All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Rui" <rui.zhang@intel.com>
To: "alexander.shishkin@linux.intel.com"
	<alexander.shishkin@linux.intel.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"Dhananjay.Ugwekar@amd.com" <Dhananjay.Ugwekar@amd.com>,
	"acme@kernel.org" <acme@kernel.org>,
	"namhyung@kernel.org" <namhyung@kernel.org>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"kan.liang@linux.intel.com" <kan.liang@linux.intel.com>,
	"irogers@google.com" <irogers@google.com>,
	"Hunter, Adrian" <adrian.hunter@intel.com>,
	"x86@kernel.org" <x86@kernel.org>
Cc: "ravi.bangoria@amd.com" <ravi.bangoria@amd.com>,
	"kprateek.nayak@amd.com" <kprateek.nayak@amd.com>,
	"gautham.shenoy@amd.com" <gautham.shenoy@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"Larabel, Michael" <michael@michaellarabel.com>,
	"sandipan.das@amd.com" <sandipan.das@amd.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"ananth.narayan@amd.com" <ananth.narayan@amd.com>
Subject: Re: [PATCH 2/2] powercap/intel_rapl: Fix the energy-pkg event for AMD CPUs
Date: Sun, 21 Jul 2024 14:17:42 +0000	[thread overview]
Message-ID: <2a81f438306b82620bb4db9065d2cbf3e4c2d56c.camel@intel.com> (raw)
In-Reply-To: <20240719092545.50441-3-Dhananjay.Ugwekar@amd.com>

On Fri, 2024-07-19 at 09:25 +0000, Dhananjay Ugwekar wrote:
> After commit ("x86/cpu/topology: Add support for the AMD 0x80000026
> leaf"),
> on AMD processors that support extended CPUID leaf 0x80000026, the
> topology_logical_die_id() macros, no longer returns package id,
> instead it
> returns the CCD (Core Complex Die) id. This leads to the energy-pkg
> event scope to be modified to CCD instead of package.
> 
> For more historical context, please refer to commit 32fb480e0a2c
> ("powercap/intel_rapl: Support multi-die/package"), which initially
> changed
> the RAPL scope from package to die for all systems, as Intel systems
> with Die enumeration have RAPL scope as die, and those without die
> enumeration are not affected. So, all systems(Intel, AMD, Hygon),
> worked
> correctly with topology_logical_die_id() until recently, but this
> changed
> after the "0x80000026 leaf" commit mentioned above.
> 
> Replacing topology_logical_die_id() with
> topology_physical_package_id()
> conditionally only for AMD and Hygon fixes the energy-pkg event.
> 
> On an AMD 2 socket 8 CCD Zen5 server:
> 
> Before:
> 
> linux$ ls /sys/class/powercap/
> intel-rapl      intel-rapl:1:0  intel-rapl:3:0  intel-rapl:5:0
> intel-rapl:7:0  intel-rapl:9:0  intel-rapl:b:0  intel-rapl:d:0
> intel-rapl:f:0  intel-rapl:0    intel-rapl:2    intel-rapl:4
> intel-rapl:6    intel-rapl:8    intel-rapl:a    intel-rapl:c
> intel-rapl:e    intel-rapl:0:0  intel-rapl:2:0  intel-rapl:4:0
> intel-rapl:6:0  intel-rapl:8:0  intel-rapl:a:0  intel-rapl:c:0
> intel-rapl:e:0  intel-rapl:1    intel-rapl:3    intel-rapl:5
> intel-rapl:7    intel-rapl:9    intel-rapl:b    intel-rapl:d
> intel-rapl:f
> 
> After:
> 
> linux$ ls /sys/class/powercap/
> intel-rapl  intel-rapl:0  intel-rapl:0:0  intel-rapl:1  intel-
> rapl:1:0
> 
> Only one sysfs entry per-event per-package is created after this
> change.
> 
> Fixes: 63edbaa48a57 ("x86/cpu/topology: Add support for the AMD
> 0x80000026 leaf")
> Reported-by: Michael Larabel <michael@michaellarabel.com>
> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>

For the future Intel multi-die system that I know, it still has
package-scope RAPL, but this is done with TPMI RAPL interface.

The TPMI RAPL driver invokes these APIs with "id == pkg_id" and
"id_is_cpu == false", so no need to make rapl_pmu_is_pkg_scope()
returns true for those Intel systems.

The patch LGTM.

Reviewed-by: Zhang Rui <rui.zhang@intel.com>

thanks,
rui
> ---
>  drivers/powercap/intel_rapl_common.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/powercap/intel_rapl_common.c
> b/drivers/powercap/intel_rapl_common.c
> index 3cffa6c79538..2f24ca764408 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -2128,6 +2128,18 @@ void rapl_remove_package(struct rapl_package
> *rp)
>  }
>  EXPORT_SYMBOL_GPL(rapl_remove_package);
>  
> +/*
> + * Intel systems that enumerate DIE domain have RAPL domains
> implemented
> + * per-die, however, the same is not true for AMD and Hygon
> processors
> + * where RAPL domains for PKG energy are in-fact per-PKG. Since
> + * logical_die_id is same as logical_package_id in absence of DIE
> + * enumeration, use topology_logical_die_id() on Intel systems and
> + * topology_logical_package_id() on AMD and Hygon systems.
> + */
> +#define rapl_pmu_is_pkg_scope()                                \
> +       (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||  \
> +        boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
> +
>  /* caller to ensure CPU hotplug lock is held */
>  struct rapl_package *rapl_find_package_domain_cpuslocked(int id,
> struct rapl_if_priv *priv,
>                                                          bool
> id_is_cpu)
> @@ -2136,7 +2148,8 @@ struct rapl_package
> *rapl_find_package_domain_cpuslocked(int id, struct rapl_if_
>         int uid;
>  
>         if (id_is_cpu)
> -               uid = topology_logical_die_id(id);
> +               uid = rapl_pmu_is_pkg_scope() ?
> +                     topology_physical_package_id(id) :
> topology_logical_die_id(id);
>         else
>                 uid = id;
>  
> @@ -2168,9 +2181,10 @@ struct rapl_package
> *rapl_add_package_cpuslocked(int id, struct rapl_if_priv *pr
>                 return ERR_PTR(-ENOMEM);
>  
>         if (id_is_cpu) {
> -               rp->id = topology_logical_die_id(id);
> +               rp->id = rapl_pmu_is_pkg_scope() ?
> +                        topology_physical_package_id(id) :
> topology_logical_die_id(id);
>                 rp->lead_cpu = id;
> -               if (topology_max_dies_per_package() > 1)
> +               if (!rapl_pmu_is_pkg_scope() &&
> topology_max_dies_per_package() > 1)
>                         snprintf(rp->name,
> PACKAGE_DOMAIN_NAME_LENGTH, "package-%d-die-%d",
>                                  topology_physical_package_id(id),
> topology_die_id(id));
>                 else


  reply	other threads:[~2024-07-21 14:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19  9:25 [PATCH 0/2] RAPL driver fixes for AMD CPUs Dhananjay Ugwekar
2024-07-19  9:25 ` [PATCH 1/2] perf/x86/rapl: Fix the energy-pkg event " Dhananjay Ugwekar
2024-07-19  9:25 ` [PATCH 2/2] powercap/intel_rapl: " Dhananjay Ugwekar
2024-07-21 14:17   ` Zhang, Rui [this message]
2024-07-22  8:24     ` Dhananjay Ugwekar
2024-07-22 13:52       ` Zhang, Rui
2024-07-22 14:01         ` Dhananjay Ugwekar
2024-07-22 15:21           ` Zhang, Rui
2024-07-23  4:12             ` 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=2a81f438306b82620bb4db9065d2cbf3e4c2d56c.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=Dhananjay.Ugwekar@amd.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.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=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=michael@michaellarabel.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --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 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.