[PATCH v2] topology/sysfs: Fix allnoconfig build breakage.

Luck, Tony posted 1 patch 4 years ago
drivers/base/topology.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Luck, Tony 4 years ago
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);

This is because the topology_ppin(dev->id) macro expands to:

	(cpu_data(dev->id).ppin)

and with CONFIG_SMP=n the cpu_data() macro expands to boot_cpu_data
(ignoring its argument) with the end result:

	boot_cpu_data.ppin

Fix by just checking whether the boot_cpu has a PPIN instead of whether
this specific CPU has one.

Fixes: c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Tony Luck <tony.luck@intel.com>

---
I don't believe it will ever be possible to have no PPIN on the boot CPU,
but somehow have PPINs on other CPUs (or vice versa)

 drivers/base/topology.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 706dbf8bf249..11a56a10188d 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -155,9 +155,7 @@ static struct attribute *default_attrs[] = {
 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))
+	if (attr == &dev_attr_ppin.attr && !boot_cpu_data.ppin)
 		return 0;
 
 	return attr->mode;
-- 
2.35.1
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Stephen Rothwell 4 years ago
Hi Tony,

On Thu, 21 Apr 2022 09:19:59 -0700 "Luck, Tony" <tony.luck@intel.com> wrote:
>
> Fixes: c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")

This is actually commit aa63a74d4535.

-- 
Cheers,
Stephen Rothwell
RE: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Luck, Tony 4 years ago
>> Fixes: c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")
>
> This is actually commit aa63a74d4535.

Doh! I looked in my tree, not in Greg's.

Doesn't matter much, Greg is going to revert as I haven't come up with a good[1]
way to fix this.

-Tony

[1] I found two bad ways. First one made Greg barf. This one breaks the build for over
50% of supported architectures :-(
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Stephen Rothwell 4 years ago
Hi Tony,

On Thu, 21 Apr 2022 23:38:28 +0000 "Luck, Tony" <tony.luck@intel.com> wrote:
>
> >> Fixes: c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")  
> >
> > This is actually commit aa63a74d4535.  
> 
> Doh! I looked in my tree, not in Greg's.
> 
> Doesn't matter much, Greg is going to revert as I haven't come up with a good[1]
> way to fix this.
> 
> -Tony
> 
> [1] I found two bad ways. First one made Greg barf. This one breaks the build for over
> 50% of supported architectures :-(

I assume that there is some good reason that topology_ppin() is not
implemented as a static inline function?

-- 
Cheers,
Stephen Rothwell
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Luck, Tony 4 years ago
On Fri, Apr 22, 2022 at 10:00:54AM +1000, Stephen Rothwell wrote:
> I assume that there is some good reason that topology_ppin() is not
> implemented as a static inline function?

I don't think so. I just cut & pasted how all the other topology_*()
things were implemented.

Making it a static inline appears to fix this problem. But before
embarrassing myself with a third broken version I'll let zero day
crunch on:

  git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git hide_ppin

to see if there is some subtle config or arch where the inline trick
doesn't work.

Thanks for the idea! :-)

-Tony
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Greg KH 4 years ago
On Thu, Apr 21, 2022 at 07:51:02PM -0700, Luck, Tony wrote:
> On Fri, Apr 22, 2022 at 10:00:54AM +1000, Stephen Rothwell wrote:
> > I assume that there is some good reason that topology_ppin() is not
> > implemented as a static inline function?
> 
> I don't think so. I just cut & pasted how all the other topology_*()
> things were implemented.
> 
> Making it a static inline appears to fix this problem. But before
> embarrassing myself with a third broken version I'll let zero day
> crunch on:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git hide_ppin
> 
> to see if there is some subtle config or arch where the inline trick
> doesn't work.
> 
> Thanks for the idea! :-)

Why not just do the following, which passes my build tests here:


diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 706dbf8bf249..ac6ad9ab67f9 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -155,9 +155,7 @@ static struct attribute *default_attrs[] = {
 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))
+	if (attr == &dev_attr_ppin.attr && !topology_ppin(kobj_to_dev(kobj)->id))
 		return 0;
 
 	return attr->mode;
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Posted by Greg KH 4 years ago
On Fri, Apr 22, 2022 at 08:00:50AM +0200, Greg KH wrote:
> On Thu, Apr 21, 2022 at 07:51:02PM -0700, Luck, Tony wrote:
> > On Fri, Apr 22, 2022 at 10:00:54AM +1000, Stephen Rothwell wrote:
> > > I assume that there is some good reason that topology_ppin() is not
> > > implemented as a static inline function?
> > 
> > I don't think so. I just cut & pasted how all the other topology_*()
> > things were implemented.
> > 
> > Making it a static inline appears to fix this problem. But before
> > embarrassing myself with a third broken version I'll let zero day
> > crunch on:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git hide_ppin
> > 
> > to see if there is some subtle config or arch where the inline trick
> > doesn't work.
> > 
> > Thanks for the idea! :-)
> 
> Why not just do the following, which passes my build tests here:
> 
> 
> diff --git a/drivers/base/topology.c b/drivers/base/topology.c
> index 706dbf8bf249..ac6ad9ab67f9 100644
> --- a/drivers/base/topology.c
> +++ b/drivers/base/topology.c
> @@ -155,9 +155,7 @@ static struct attribute *default_attrs[] = {
>  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))
> +	if (attr == &dev_attr_ppin.attr && !topology_ppin(kobj_to_dev(kobj)->id))
>  		return 0;
>  
>  	return attr->mode;

I've sent this as real patch now.

thanks,

greg k-h