lkml.org 
[lkml]   [2022]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] topology/sysfs: Hide PPIN on systems that do not support it.
On Wed,  6 Apr 2022 15:01:50 -0700 Tony Luck <tony.luck@intel.com> wrote:

> Systems that do not support a Protected Processor Identification Number
> currently report:
>
> # cat /sys/devices/system/cpu/cpu0/topology/ppin
> 0x0
>
> which is confusing/wrong.
>
> Add a ".is_visible" function to suppress inclusion of the ppin file.
>
> --- a/drivers/base/topology.c
> +++ b/drivers/base/topology.c
> @@ -152,9 +152,21 @@ static struct attribute *default_attrs[] = {
> NULL
> };
>
> +static umode_t topology_is_visible(struct kobject *kobj,
> + struct attribute *attr, int unused)
> +{
> + struct device *dev = kobj_to_dev(kobj);
> +
> + if (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id))
> + return 0;
> +
> + return attr->mode;
> +}
> +
> static const struct attribute_group topology_attr_group = {
> .attrs = default_attrs,
> .bin_attrs = bin_attrs,
> + .is_visible = topology_is_visible,
> .name = "topology"
> };

x86_64 allnoconfig:

drivers/base/topology.c: In function 'topology_is_visible':
drivers/base/topology.c:158:24: warning: unused variable 'dev' [-Wunused-variable]
158 | struct device *dev = kobj_to_dev(kobj);
| ^~~

I suggest this be fixed in the topology_ppin() stub implementation. Do
it as a nice inlined C function which avoids such problems. Rather
than as a crappy macro which causes them...

\
 
 \ /
  Last update: 2022-04-26 00:48    [W:1.470 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site