Messages in this thread | | | Date | Mon, 25 Apr 2022 15:46:16 -0700 | From | Andrew Morton <> | Subject | Re: [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...
| |