* [PATCH v1] sched/topology: Make compiler happy about unused constant definitions @ 2020-08-24 15:39 Andy Shevchenko 2020-08-24 17:09 ` Valentin Schneider 0 siblings, 1 reply; 12+ messages in thread From: Andy Shevchenko @ 2020-08-24 15:39 UTC (permalink / raw) To: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel Cc: Andy Shevchenko, Valentin Schneider, Dietmar Eggemann Compilation of almost each file ends up with In file included from .../include/linux/energy_model.h:10, from .../include/linux/device.h:16, from .../drivers/spi/spi.c:8: .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = | ^~~~~~~~~~~~~~~~~~~~~~~~~ ... Make compiler happy by annotating the static constants with __maybwe_unused. Fixes: 4ee4ea443a5d ("sched/topology: Introduce SD metaflag for flags needing > 1 groups") Cc: Valentin Schneider <valentin.schneider@arm.com> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- include/linux/sched/topology.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 2d59ca77103e..ec440b67599c 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -27,14 +27,14 @@ enum { /* Generate a mask of SD flags with the SDF_NEEDS_GROUPS metaflag */ #define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_NEEDS_GROUPS)) | -static const unsigned int SD_DEGENERATE_GROUPS_MASK = +static __maybe_unused const unsigned int SD_DEGENERATE_GROUPS_MASK = #include <linux/sched/sd_flags.h> 0; #undef SD_FLAG #ifdef CONFIG_SCHED_DEBUG #define SD_FLAG(_name, mflags) [__##_name] = { .meta_flags = mflags, .name = #_name }, -static const struct { +static __maybe_unused const struct { unsigned int meta_flags; char *name; } sd_flag_debug[] = { -- 2.28.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-24 15:39 [PATCH v1] sched/topology: Make compiler happy about unused constant definitions Andy Shevchenko @ 2020-08-24 17:09 ` Valentin Schneider 2020-08-25 8:26 ` Andy Shevchenko 0 siblings, 1 reply; 12+ messages in thread From: Valentin Schneider @ 2020-08-24 17:09 UTC (permalink / raw) To: Andy Shevchenko Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann Hi, On 24/08/20 16:39, Andy Shevchenko wrote: > Compilation of almost each file ends up with > > In file included from .../include/linux/energy_model.h:10, > from .../include/linux/device.h:16, > from .../drivers/spi/spi.c:8: > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > ... > > Make compiler happy by annotating the static constants with __maybwe_unused. > That should see some use as long as the build is for SMP. This whole region is guarded by #ifdef CONFIG_SMP, so an !SMP build shouldn't trigger this. With what config/kernel are you getting this? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-24 17:09 ` Valentin Schneider @ 2020-08-25 8:26 ` Andy Shevchenko 2020-08-25 9:03 ` Valentin Schneider 2020-08-25 10:23 ` David Laight 0 siblings, 2 replies; 12+ messages in thread From: Andy Shevchenko @ 2020-08-25 8:26 UTC (permalink / raw) To: Valentin Schneider Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > On 24/08/20 16:39, Andy Shevchenko wrote: > > Compilation of almost each file ends up with > > > > In file included from .../include/linux/energy_model.h:10, > > from .../include/linux/device.h:16, > > from .../drivers/spi/spi.c:8: > > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] > > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > > ... > > > > Make compiler happy by annotating the static constants with __maybwe_unused. > > > > That should see some use as long as the build is for SMP. This whole region > is guarded by #ifdef CONFIG_SMP, so an !SMP build shouldn't trigger this. Isn't SMP is default for most of the kernel builds? And honestly I didn't get the purpose of this comment. > With what config/kernel are you getting this? x86_64_defconfig from the kernel sources with some drivers added (SMP or so has not been touched, DEBUG_SHED was enabled once to confirm that another static const has same issue). -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 8:26 ` Andy Shevchenko @ 2020-08-25 9:03 ` Valentin Schneider 2020-08-25 10:12 ` Valentin Schneider 2020-08-25 10:23 ` David Laight 1 sibling, 1 reply; 12+ messages in thread From: Valentin Schneider @ 2020-08-25 9:03 UTC (permalink / raw) To: Andy Shevchenko Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On 25/08/20 09:26, Andy Shevchenko wrote: > On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: >> On 24/08/20 16:39, Andy Shevchenko wrote: >> > Compilation of almost each file ends up with >> > >> > In file included from .../include/linux/energy_model.h:10, >> > from .../include/linux/device.h:16, >> > from .../drivers/spi/spi.c:8: >> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] >> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = >> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ >> > ... >> > >> > Make compiler happy by annotating the static constants with __maybwe_unused. >> > >> >> That should see some use as long as the build is for SMP. This whole region >> is guarded by #ifdef CONFIG_SMP, so an !SMP build shouldn't trigger this. > > Isn't SMP is default for most of the kernel builds? > And honestly I didn't get the purpose of this comment. > Sorry, that's what I get for trying to be too succinct; what I tried to say was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where this is coming from. >> With what config/kernel are you getting this? > > x86_64_defconfig from the kernel sources with some drivers added (SMP or so has > not been touched, DEBUG_SHED was enabled once to confirm that another static > const has same issue). Thanks, I'll poke around this. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 9:03 ` Valentin Schneider @ 2020-08-25 10:12 ` Valentin Schneider 2020-08-25 11:24 ` Andy Shevchenko 0 siblings, 1 reply; 12+ messages in thread From: Valentin Schneider @ 2020-08-25 10:12 UTC (permalink / raw) To: Andy Shevchenko Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On 25/08/20 10:03, Valentin Schneider wrote: > On 25/08/20 09:26, Andy Shevchenko wrote: >> On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: >>> On 24/08/20 16:39, Andy Shevchenko wrote: >>> > Compilation of almost each file ends up with >>> > >>> > In file included from .../include/linux/energy_model.h:10, >>> > from .../include/linux/device.h:16, >>> > from .../drivers/spi/spi.c:8: >>> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] >>> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = >>> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ >>> > ... >>> > >>> > Make compiler happy by annotating the static constants with __maybwe_unused. > Sorry, that's what I get for trying to be too succinct; what I tried to say > was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the > build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where > this is coming from. So I see how having this as a constvar rather than a constexpr is somewhat daft (we get an instance per compilation unit), but none of my compilers seem to complain (even with W=1). AFAIA the kernelbot didn't catch any of it either. Out of curiosity, what's your compiler & compiler version? Alternatively we can make this a "proper" constant expression with the below. --- diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 2d59ca77103e..b1331c4c48e9 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -27,9 +27,11 @@ enum { /* Generate a mask of SD flags with the SDF_NEEDS_GROUPS metaflag */ #define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_NEEDS_GROUPS)) | -static const unsigned int SD_DEGENERATE_GROUPS_MASK = +enum { + SD_DEGENERATE_GROUPS_MASK = #include <linux/sched/sd_flags.h> -0; +0 +}; #undef SD_FLAG #ifdef CONFIG_SCHED_DEBUG ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 10:12 ` Valentin Schneider @ 2020-08-25 11:24 ` Andy Shevchenko 2020-08-25 11:26 ` Andy Shevchenko 0 siblings, 1 reply; 12+ messages in thread From: Andy Shevchenko @ 2020-08-25 11:24 UTC (permalink / raw) To: Valentin Schneider Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On Tue, Aug 25, 2020 at 11:12:21AM +0100, Valentin Schneider wrote: > On 25/08/20 10:03, Valentin Schneider wrote: > > On 25/08/20 09:26, Andy Shevchenko wrote: > >> On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > >>> On 24/08/20 16:39, Andy Shevchenko wrote: > >>> > Compilation of almost each file ends up with > >>> > > >>> > In file included from .../include/linux/energy_model.h:10, > >>> > from .../include/linux/device.h:16, > >>> > from .../drivers/spi/spi.c:8: > >>> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] > >>> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > >>> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > >>> > ... > >>> > > >>> > Make compiler happy by annotating the static constants with __maybwe_unused. > > > Sorry, that's what I get for trying to be too succinct; what I tried to say > > was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the > > build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where > > this is coming from. > > So I see how having this as a constvar rather than a constexpr is somewhat > daft (we get an instance per compilation unit), but none of my compilers > seem to complain (even with W=1). AFAIA the kernelbot didn't catch any of > it either. > > Out of curiosity, what's your compiler & compiler version? % gcc --version gcc (Debian 10.2.0-5) 10.2.0 % make O=... W=1 C=1 CF=-D__CHECK_ENDIAN__ -j64 > Alternatively we can make this a "proper" constant expression with the > below. It doesn't fix another static const in the same file, though that one requires DEBUG_SCHED to be enabled. Do you want me to split this fix and fix only the other case? > --- > > diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h > index 2d59ca77103e..b1331c4c48e9 100644 > --- a/include/linux/sched/topology.h > +++ b/include/linux/sched/topology.h > @@ -27,9 +27,11 @@ enum { > > /* Generate a mask of SD flags with the SDF_NEEDS_GROUPS metaflag */ > #define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_NEEDS_GROUPS)) | > -static const unsigned int SD_DEGENERATE_GROUPS_MASK = > +enum { > + SD_DEGENERATE_GROUPS_MASK = > #include <linux/sched/sd_flags.h> > -0; > +0 > +}; > #undef SD_FLAG > > #ifdef CONFIG_SCHED_DEBUG -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 11:24 ` Andy Shevchenko @ 2020-08-25 11:26 ` Andy Shevchenko 2020-08-25 11:32 ` Andy Shevchenko 0 siblings, 1 reply; 12+ messages in thread From: Andy Shevchenko @ 2020-08-25 11:26 UTC (permalink / raw) To: Valentin Schneider Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On Tue, Aug 25, 2020 at 02:24:05PM +0300, Andy Shevchenko wrote: > On Tue, Aug 25, 2020 at 11:12:21AM +0100, Valentin Schneider wrote: > > On 25/08/20 10:03, Valentin Schneider wrote: > > > On 25/08/20 09:26, Andy Shevchenko wrote: > > >> On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > > >>> On 24/08/20 16:39, Andy Shevchenko wrote: > > >>> > Compilation of almost each file ends up with > > >>> > > > >>> > In file included from .../include/linux/energy_model.h:10, > > >>> > from .../include/linux/device.h:16, > > >>> > from .../drivers/spi/spi.c:8: > > >>> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] > > >>> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > > >>> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > > >>> > ... > > >>> > > > >>> > Make compiler happy by annotating the static constants with __maybwe_unused. > > > > > Sorry, that's what I get for trying to be too succinct; what I tried to say > > > was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the > > > build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where > > > this is coming from. > > > > So I see how having this as a constvar rather than a constexpr is somewhat > > daft (we get an instance per compilation unit), but none of my compilers > > seem to complain (even with W=1). AFAIA the kernelbot didn't catch any of > > it either. > > > > Out of curiosity, what's your compiler & compiler version? > > % gcc --version > gcc (Debian 10.2.0-5) 10.2.0 > > % make O=... W=1 C=1 CF=-D__CHECK_ENDIAN__ -j64 > > > Alternatively we can make this a "proper" constant expression with the > > below. > > It doesn't fix another static const in the same file, though that one requires > DEBUG_SCHED to be enabled. > > Do you want me to split this fix and fix only the other case? Just checked and the other case has been brought by b6e862f38672 ("sched/topology: Define and assign sched_domain flag metadata") with your authorship. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 11:26 ` Andy Shevchenko @ 2020-08-25 11:32 ` Andy Shevchenko 2020-08-25 12:00 ` Valentin Schneider 0 siblings, 1 reply; 12+ messages in thread From: Andy Shevchenko @ 2020-08-25 11:32 UTC (permalink / raw) To: Valentin Schneider Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On Tue, Aug 25, 2020 at 02:26:05PM +0300, Andy Shevchenko wrote: > On Tue, Aug 25, 2020 at 02:24:05PM +0300, Andy Shevchenko wrote: > > On Tue, Aug 25, 2020 at 11:12:21AM +0100, Valentin Schneider wrote: > > > On 25/08/20 10:03, Valentin Schneider wrote: > > > > On 25/08/20 09:26, Andy Shevchenko wrote: > > > >> On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > > > >>> On 24/08/20 16:39, Andy Shevchenko wrote: > > > >>> > Compilation of almost each file ends up with > > > >>> > > > > >>> > In file included from .../include/linux/energy_model.h:10, > > > >>> > from .../include/linux/device.h:16, > > > >>> > from .../drivers/spi/spi.c:8: > > > >>> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] > > > >>> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > > > >>> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > > > >>> > ... > > > >>> > > > > >>> > Make compiler happy by annotating the static constants with __maybwe_unused. > > > > > > > Sorry, that's what I get for trying to be too succinct; what I tried to say > > > > was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the > > > > build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where > > > > this is coming from. > > > > > > So I see how having this as a constvar rather than a constexpr is somewhat > > > daft (we get an instance per compilation unit), but none of my compilers > > > seem to complain (even with W=1). AFAIA the kernelbot didn't catch any of > > > it either. And even without compiler or any other analyzer / bot I can 100% sure tell that spi.c does *not* use that symbol. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 11:32 ` Andy Shevchenko @ 2020-08-25 12:00 ` Valentin Schneider 2020-08-25 12:38 ` Andy Shevchenko 0 siblings, 1 reply; 12+ messages in thread From: Valentin Schneider @ 2020-08-25 12:00 UTC (permalink / raw) To: Andy Shevchenko Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On 25/08/20 12:32, Andy Shevchenko wrote: > On Tue, Aug 25, 2020 at 02:26:05PM +0300, Andy Shevchenko wrote: >> On Tue, Aug 25, 2020 at 02:24:05PM +0300, Andy Shevchenko wrote: >> > On Tue, Aug 25, 2020 at 11:12:21AM +0100, Valentin Schneider wrote: >> > > On 25/08/20 10:03, Valentin Schneider wrote: >> > > > On 25/08/20 09:26, Andy Shevchenko wrote: >> > > >> On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: >> > > >>> On 24/08/20 16:39, Andy Shevchenko wrote: >> > > >>> > Compilation of almost each file ends up with >> > > >>> > >> > > >>> > In file included from .../include/linux/energy_model.h:10, >> > > >>> > from .../include/linux/device.h:16, >> > > >>> > from .../drivers/spi/spi.c:8: >> > > >>> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] >> > > >>> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = >> > > >>> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ >> > > >>> > ... >> > > >>> > >> > > >>> > Make compiler happy by annotating the static constants with __maybwe_unused. >> > > >> > > > Sorry, that's what I get for trying to be too succinct; what I tried to say >> > > > was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the >> > > > build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where >> > > > this is coming from. >> > > >> > > So I see how having this as a constvar rather than a constexpr is somewhat >> > > daft (we get an instance per compilation unit), but none of my compilers >> > > seem to complain (even with W=1). AFAIA the kernelbot didn't catch any of >> > > it either. > > And even without compiler or any other analyzer / bot I can 100% sure tell that > spi.c does *not* use that symbol. Aye aye, this is a daft constvar placement from my end, apologies. For the SD_DEGENERATE_GROUPS_MASK, that one could directly be shoved into kernel/sched/topology.c (or done via an enum, I don't care too much). I suppose the other one causing you grief is sd_flag_debug[]; that one too really shouldn't be in a header. I need to access that in two separate files, so I guess I'll have to cook up some wrappers. Let me take a jab at it, it's my own mess after all... ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 12:00 ` Valentin Schneider @ 2020-08-25 12:38 ` Andy Shevchenko 0 siblings, 0 replies; 12+ messages in thread From: Andy Shevchenko @ 2020-08-25 12:38 UTC (permalink / raw) To: Valentin Schneider Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On Tue, Aug 25, 2020 at 01:00:12PM +0100, Valentin Schneider wrote: > On 25/08/20 12:32, Andy Shevchenko wrote: > > On Tue, Aug 25, 2020 at 02:26:05PM +0300, Andy Shevchenko wrote: > >> On Tue, Aug 25, 2020 at 02:24:05PM +0300, Andy Shevchenko wrote: > >> > On Tue, Aug 25, 2020 at 11:12:21AM +0100, Valentin Schneider wrote: > >> > > On 25/08/20 10:03, Valentin Schneider wrote: > >> > > > On 25/08/20 09:26, Andy Shevchenko wrote: > >> > > >> On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > >> > > >>> On 24/08/20 16:39, Andy Shevchenko wrote: > >> > > >>> > Compilation of almost each file ends up with > >> > > >>> > > >> > > >>> > In file included from .../include/linux/energy_model.h:10, > >> > > >>> > from .../include/linux/device.h:16, > >> > > >>> > from .../drivers/spi/spi.c:8: > >> > > >>> > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not used [-Wunused-const-variable=] > >> > > >>> > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > >> > > >>> > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > >> > > >>> > ... > >> > > >>> > > >> > > >>> > Make compiler happy by annotating the static constants with __maybwe_unused. > >> > > > >> > > > Sorry, that's what I get for trying to be too succinct; what I tried to say > >> > > > was that SD_DEGENERATE_GROUPS_MASK should very much be used for SMP. If the > >> > > > build is !SMP, it shouldn't even be defined, IOW I'm perplexed as to where > >> > > > this is coming from. > >> > > > >> > > So I see how having this as a constvar rather than a constexpr is somewhat > >> > > daft (we get an instance per compilation unit), but none of my compilers > >> > > seem to complain (even with W=1). AFAIA the kernelbot didn't catch any of > >> > > it either. > > > > And even without compiler or any other analyzer / bot I can 100% sure tell that > > spi.c does *not* use that symbol. > > Aye aye, this is a daft constvar placement from my end, apologies. > > For the SD_DEGENERATE_GROUPS_MASK, that one could directly be shoved into > kernel/sched/topology.c (or done via an enum, I don't care too much). > > I suppose the other one causing you grief is sd_flag_debug[]; that one too > really shouldn't be in a header. I need to access that in two separate > files, so I guess I'll have to cook up some wrappers. > > Let me take a jab at it, it's my own mess after all... Thank you! Ping me if you would need to test a patch or so. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 8:26 ` Andy Shevchenko 2020-08-25 9:03 ` Valentin Schneider @ 2020-08-25 10:23 ` David Laight 2020-08-25 11:30 ` 'Andy Shevchenko' 1 sibling, 1 reply; 12+ messages in thread From: David Laight @ 2020-08-25 10:23 UTC (permalink / raw) To: 'Andy Shevchenko', Valentin Schneider Cc: Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann From: Andy Shevchenko > Sent: 25 August 2020 09:27 > > On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > > On 24/08/20 16:39, Andy Shevchenko wrote: > > > Compilation of almost each file ends up with > > > > > > In file included from .../include/linux/energy_model.h:10, > > > from .../include/linux/device.h:16, > > > from .../drivers/spi/spi.c:8: > > > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not > used [-Wunused-const-variable=] > > > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > > > ... > > > > > > Make compiler happy by annotating the static constants with __maybwe_unused. > > > > > > > That should see some use as long as the build is for SMP. This whole region > > is guarded by #ifdef CONFIG_SMP, so an !SMP build shouldn't trigger this. > > Isn't SMP is default for most of the kernel builds? > And honestly I didn't get the purpose of this comment. The real fix is to not use 'static const' in C. IIRC it is still a memory location (that can be patched) not a compile time constant. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v1] sched/topology: Make compiler happy about unused constant definitions 2020-08-25 10:23 ` David Laight @ 2020-08-25 11:30 ` 'Andy Shevchenko' 0 siblings, 0 replies; 12+ messages in thread From: 'Andy Shevchenko' @ 2020-08-25 11:30 UTC (permalink / raw) To: David Laight Cc: Valentin Schneider, Ingo Molnar, Peter Zijlstra, Vincent Guittot, linux-kernel, Dietmar Eggemann On Tue, Aug 25, 2020 at 10:23:05AM +0000, David Laight wrote: > From: Andy Shevchenko > > Sent: 25 August 2020 09:27 > > On Mon, Aug 24, 2020 at 06:09:41PM +0100, Valentin Schneider wrote: > > > On 24/08/20 16:39, Andy Shevchenko wrote: > > > > Compilation of almost each file ends up with > > > > > > > > In file included from .../include/linux/energy_model.h:10, > > > > from .../include/linux/device.h:16, > > > > from .../drivers/spi/spi.c:8: > > > > .../include/linux/sched/topology.h:30:27: warning: ‘SD_DEGENERATE_GROUPS_MASK’ defined but not > > used [-Wunused-const-variable=] > > > > 30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK = > > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > > > > ... > > > > > > > > Make compiler happy by annotating the static constants with __maybwe_unused. > > > > > > > > > > That should see some use as long as the build is for SMP. This whole region > > > is guarded by #ifdef CONFIG_SMP, so an !SMP build shouldn't trigger this. > > > > Isn't SMP is default for most of the kernel builds? > > And honestly I didn't get the purpose of this comment. > > The real fix is to not use 'static const' in C. > IIRC it is still a memory location (that can be patched) not > a compile time constant. Yep. The topology.h can be rather split to topology.c with exported symbols (exported or just visible for linker, depends on the case). -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-08-25 12:38 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-24 15:39 [PATCH v1] sched/topology: Make compiler happy about unused constant definitions Andy Shevchenko 2020-08-24 17:09 ` Valentin Schneider 2020-08-25 8:26 ` Andy Shevchenko 2020-08-25 9:03 ` Valentin Schneider 2020-08-25 10:12 ` Valentin Schneider 2020-08-25 11:24 ` Andy Shevchenko 2020-08-25 11:26 ` Andy Shevchenko 2020-08-25 11:32 ` Andy Shevchenko 2020-08-25 12:00 ` Valentin Schneider 2020-08-25 12:38 ` Andy Shevchenko 2020-08-25 10:23 ` David Laight 2020-08-25 11:30 ` 'Andy Shevchenko'
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).