[1/2] powercap/intel_rapl: Use topology interface in rapl_add_package()
diff mbox series

Message ID 20210123100608.2349629-1-yeyunfeng@huawei.com
State Accepted
Commit 88ffce95764603e13eda4be003ec919e124ec365
Headers show
Series
  • [1/2] powercap/intel_rapl: Use topology interface in rapl_add_package()
Related show

Commit Message

Yunfeng Ye Jan. 23, 2021, 10:06 a.m. UTC
It's not a good way to access phys_proc_id and cpu_die_id directly.
So using topology_physical_package_id(cpu) and topology_die_id(cpu)
instead.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
 drivers/powercap/intel_rapl_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Rafael J. Wysocki Feb. 5, 2021, 12:45 p.m. UTC | #1
On Sat, Jan 23, 2021 at 11:07 AM Yunfeng Ye <yeyunfeng@huawei.com> wrote:
>
> It's not a good way to access phys_proc_id and cpu_die_id directly.
> So using topology_physical_package_id(cpu) and topology_die_id(cpu)
> instead.
>
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>

Srinivas, Rui, any concerns?

> ---
>  drivers/powercap/intel_rapl_common.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
> index c9e57237d778..5f3d39b8212a 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -1309,7 +1309,6 @@ struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
>  {
>         int id = topology_logical_die_id(cpu);
>         struct rapl_package *rp;
> -       struct cpuinfo_x86 *c = &cpu_data(cpu);
>         int ret;
>
>         if (!rapl_defaults)
> @@ -1326,10 +1325,11 @@ struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
>
>         if (topology_max_die_per_package() > 1)
>                 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH,
> -                        "package-%d-die-%d", c->phys_proc_id, c->cpu_die_id);
> +                        "package-%d-die-%d",
> +                        topology_physical_package_id(cpu), topology_die_id(cpu));
>         else
>                 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH, "package-%d",
> -                        c->phys_proc_id);
> +                        topology_physical_package_id(cpu));
>
>         /* check if the package contains valid domains */
>         if (rapl_detect_domains(rp, cpu) || rapl_defaults->check_unit(rp, cpu)) {
> --
> 2.27.0
>
Srinivas Pandruvada Feb. 5, 2021, 5:07 p.m. UTC | #2
On Fri, 2021-02-05 at 13:45 +0100, Rafael J. Wysocki wrote:
> On Sat, Jan 23, 2021 at 11:07 AM Yunfeng Ye <yeyunfeng@huawei.com>
> wrote:
> > It's not a good way to access phys_proc_id and cpu_die_id directly.
> > So using topology_physical_package_id(cpu) and topology_die_id(cpu)
> > instead.
> > 
> > Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> 
> Srinivas, Rui, any concerns?
Looks good.

Thanks,
Srinivas

> 
> > ---
> >  drivers/powercap/intel_rapl_common.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/powercap/intel_rapl_common.c
> > b/drivers/powercap/intel_rapl_common.c
> > index c9e57237d778..5f3d39b8212a 100644
> > --- a/drivers/powercap/intel_rapl_common.c
> > +++ b/drivers/powercap/intel_rapl_common.c
> > @@ -1309,7 +1309,6 @@ struct rapl_package *rapl_add_package(int
> > cpu, struct rapl_if_priv *priv)
> >  {
> >         int id = topology_logical_die_id(cpu);
> >         struct rapl_package *rp;
> > -       struct cpuinfo_x86 *c = &cpu_data(cpu);
> >         int ret;
> > 
> >         if (!rapl_defaults)
> > @@ -1326,10 +1325,11 @@ struct rapl_package *rapl_add_package(int
> > cpu, struct rapl_if_priv *priv)
> > 
> >         if (topology_max_die_per_package() > 1)
> >                 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH,
> > -                        "package-%d-die-%d", c->phys_proc_id, c-
> > >cpu_die_id);
> > +                        "package-%d-die-%d",
> > +                        topology_physical_package_id(cpu),
> > topology_die_id(cpu));
> >         else
> >                 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH,
> > "package-%d",
> > -                        c->phys_proc_id);
> > +                        topology_physical_package_id(cpu));
> > 
> >         /* check if the package contains valid domains */
> >         if (rapl_detect_domains(rp, cpu) || rapl_defaults-
> > >check_unit(rp, cpu)) {
> > --
> > 2.27.0
> >
Rafael J. Wysocki Feb. 12, 2021, 3:54 p.m. UTC | #3
On Sat, Jan 23, 2021 at 11:07 AM Yunfeng Ye <yeyunfeng@huawei.com> wrote:
>
> It's not a good way to access phys_proc_id and cpu_die_id directly.
> So using topology_physical_package_id(cpu) and topology_die_id(cpu)
> instead.
>
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> ---
>  drivers/powercap/intel_rapl_common.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
> index c9e57237d778..5f3d39b8212a 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -1309,7 +1309,6 @@ struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
>  {
>         int id = topology_logical_die_id(cpu);
>         struct rapl_package *rp;
> -       struct cpuinfo_x86 *c = &cpu_data(cpu);
>         int ret;
>
>         if (!rapl_defaults)
> @@ -1326,10 +1325,11 @@ struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
>
>         if (topology_max_die_per_package() > 1)
>                 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH,
> -                        "package-%d-die-%d", c->phys_proc_id, c->cpu_die_id);
> +                        "package-%d-die-%d",
> +                        topology_physical_package_id(cpu), topology_die_id(cpu));
>         else
>                 snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH, "package-%d",
> -                        c->phys_proc_id);
> +                        topology_physical_package_id(cpu));
>
>         /* check if the package contains valid domains */
>         if (rapl_detect_domains(rp, cpu) || rapl_defaults->check_unit(rp, cpu)) {
> --

Applied along with the [2/2] with some minor changelog edits as 5.12 material.

Thanks!

Patch
diff mbox series

diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index c9e57237d778..5f3d39b8212a 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -1309,7 +1309,6 @@  struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
 {
 	int id = topology_logical_die_id(cpu);
 	struct rapl_package *rp;
-	struct cpuinfo_x86 *c = &cpu_data(cpu);
 	int ret;
 
 	if (!rapl_defaults)
@@ -1326,10 +1325,11 @@  struct rapl_package *rapl_add_package(int cpu, struct rapl_if_priv *priv)
 
 	if (topology_max_die_per_package() > 1)
 		snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH,
-			 "package-%d-die-%d", c->phys_proc_id, c->cpu_die_id);
+			 "package-%d-die-%d",
+			 topology_physical_package_id(cpu), topology_die_id(cpu));
 	else
 		snprintf(rp->name, PACKAGE_DOMAIN_NAME_LENGTH, "package-%d",
-			 c->phys_proc_id);
+			 topology_physical_package_id(cpu));
 
 	/* check if the package contains valid domains */
 	if (rapl_detect_domains(rp, cpu) || rapl_defaults->check_unit(rp, cpu)) {