linux-next: build warning after merge of the driver-core.current tree
Subsystems (2)
Hi all,
After merging the driver-core.current tree, today's linux-next build (x86_64 allnoconfig) produced this warning:
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);
| ^~~
Introduced by commit
aa63a74d4535 ("topology/sysfs: Hide PPIN on systems that do not support it.")
Signature · 2 lines
Cheers, Stephen Rothwell
Greg KH
maintainerQuoted 5 lines · Stephen Rothwell
Hi all,
After merging the driver-core.current tree, today's linux-next build (
x86_64allnoconfig) produced this warning:
Quoted 8 lines
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);
| ^~~Introduced by commit
aa63a74d4535("topology/sysfs: Hide PPIN on systems that do not support it.")
Tony, can you please send a fixup patch for this, or should I just revert this commit for now?
thanks,
greg k-h
PATCH 1/1 topology/sysfs: Fix allnoconfig build breakage.
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
My CPP-fu wasn't up to a modification to topology_ppin(), so I added a (probably redundant) check for "dev" being a NULL pointer.
---
Better fixes with clever CPP macro tricks gratefully welcomed
--- drivers/base/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/topology.c +1 -1
@@ -157,7 +157,7 @@ static umode_t topology_is_visible(struct kobject *kobj, {struct device *dev =kobj_to_dev (kobj); -if (attr == &dev_attr_ppin.attr && !topology_ppin (dev->id)) +if (!dev || (attr == &dev_attr_ppin.attr && !topology_ppin (dev->id)))return 0 ;return attr->mode;
Signature · 1 line
2.35.1
Greg KH
maintainerRe: [PATCH] topology/sysfs: Fix allnoconfig build breakage.
Quoted 31 lines · Tony
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=nthecpu_data()macro expands toboot_cpu_data(ignoring its argument) with the end result:boot_cpu_data.ppin
My CPP-fu wasn't up to a modification to
topology_ppin(), so I added a (probably redundant) check for "dev" being a NULL pointer.Fixes c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Tony Luck <[email protected]>---
Better fixes with clever CPP macro tricks gratefully welcomed--- drivers/base/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/base/topology.c +0
-0
drivers/base/topology.c static umode_t topology_is_visible(struct kobject *kobj, · line 160
Quoted 5 lines
drivers/base/topology.c +1
-1@@ -157,7 +157,7 @@ static umode_t topology_is_visible(struct kobject *kobj, {struct device *dev =kobj_to_dev (kobj); -if (attr == &dev_attr_ppin.attr && !topology_ppin (dev->id)) +if (!dev || (attr == &dev_attr_ppin.attr && !topology_ppin (dev->id)))
!dev is impossible to ever hit, that's the sign that the code is wrong and needs to be fixed :(
Sorry, this is not going to be an acceptable change.
greg k-h
PATCH v2 1/1 topology/sysfs: Fix allnoconfig build breakage.
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.
---
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(-)
drivers/base/topology.c +1 -3
@@ -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;
Signature · 1 line
2.35.1
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Hi Tony,
Quoted 2 lines · Tony
Fixes c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")
This is actually commit aa63a74d4535.
Signature · 2 lines
Cheers, Stephen Rothwell
RE: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Quoted 3 lines
Quoted 1 line
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.
Hi Tony,
Quoted 7 lines · Tony
Quoted 4 lines
Quoted 2 lines
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.
Quoted 7 lines
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?
Signature · 2 lines
Cheers, Stephen Rothwell
Re: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Quoted 2 lines · Stephen Rothwell
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
Greg KH
maintainerRe: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Quoted 11 lines · Tony
Quoted 2 lines · Stephen Rothwell
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:
Quoted 6 lines
git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.githide_ppinto 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:
drivers/base/topology.c +1 -3
@@ -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;
Greg KH
maintainerRe: [PATCH v2] topology/sysfs: Fix allnoconfig build breakage.
Quoted 27 lines · Greg KH
Quoted 11 lines · Tony
Quoted 2 lines · Stephen Rothwell
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:
Quoted 6 lines
git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.githide_ppinto 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:
drivers/base/topology.c +0
-0
drivers/base/topology.c static struct attribute *default_attrs[] = { · line 161
Quoted 10 lines
drivers/base/topology.c +1
-3@@ -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