linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/cputime: Mark function as __maybe_unused
@ 2020-08-18 17:03 Alex Dewar
  2020-08-18 18:13 ` Nick Desaulniers
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Dewar @ 2020-08-18 17:03 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	linux-kernel, clang-built-linux
  Cc: Alex Dewar

Depending on config options, account_other_time() may not be called
anywhere. Add __maybe_unused flag to fix clang warning.

Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
 kernel/sched/cputime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 5a55d2300452..43ede0d6661c 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -252,7 +252,7 @@ static __always_inline u64 steal_account_process_time(u64 maxtime)
 /*
  * Account how much elapsed time was spent in steal, irq, or softirq time.
  */
-static inline u64 account_other_time(u64 max)
+static inline u64 __maybe_unused account_other_time(u64 max)
 {
 	u64 accounted;
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched/cputime: Mark function as __maybe_unused
  2020-08-18 17:03 [PATCH] sched/cputime: Mark function as __maybe_unused Alex Dewar
@ 2020-08-18 18:13 ` Nick Desaulniers
  2020-08-18 19:57   ` Alex Dewar
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2020-08-18 18:13 UTC (permalink / raw)
  To: Alex Dewar
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, LKML,
	clang-built-linux

On Tue, Aug 18, 2020 at 10:04 AM Alex Dewar <alex.dewar90@gmail.com> wrote:
>
> Depending on config options, account_other_time() may not be called
> anywhere. Add __maybe_unused flag to fix clang warning.

Just curious, would moving this definition to be within an existing
preprocessor guard for a particular config also fix the issue? If so,
prefer that. If not, __maybe_unused is the way to go.

>
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> ---
>  kernel/sched/cputime.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 5a55d2300452..43ede0d6661c 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -252,7 +252,7 @@ static __always_inline u64 steal_account_process_time(u64 maxtime)
>  /*
>   * Account how much elapsed time was spent in steal, irq, or softirq time.
>   */
> -static inline u64 account_other_time(u64 max)
> +static inline u64 __maybe_unused account_other_time(u64 max)
>  {
>         u64 accounted;
>
> --
> 2.28.0
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200818170337.805624-1-alex.dewar90%40gmail.com.



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched/cputime: Mark function as __maybe_unused
  2020-08-18 18:13 ` Nick Desaulniers
@ 2020-08-18 19:57   ` Alex Dewar
  2020-08-18 20:02     ` Nick Desaulniers
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Dewar @ 2020-08-18 19:57 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Alex Dewar, Ingo Molnar, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, LKML, clang-built-linux

On Tue, Aug 18, 2020 at 11:13:10AM -0700, Nick Desaulniers wrote:
> On Tue, Aug 18, 2020 at 10:04 AM Alex Dewar <alex.dewar90@gmail.com> wrote:
> >
> > Depending on config options, account_other_time() may not be called
> > anywhere. Add __maybe_unused flag to fix clang warning.
> 
> Just curious, would moving this definition to be within an existing
> preprocessor guard for a particular config also fix the issue? If so,
> prefer that. If not, __maybe_unused is the way to go.

I don't think that'd work here: it's used within an "#ifdef
CONFIG_IRQ_TIME_ACCOUNTING" block and a separate "#ifdef
CONFIG_VIRT_CPU_ACCOUNTING_GEN" one. We could do:
	#if defined(CONFIG_IRQ_TIME_ACCOUNTING) ||
	    defined(CONFIG_VIRT_CPU_ACCOUNTING)
		...
... but that might be a bit ugly.

> 
> >
> > Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> > ---
> >  kernel/sched/cputime.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> > index 5a55d2300452..43ede0d6661c 100644
> > --- a/kernel/sched/cputime.c
> > +++ b/kernel/sched/cputime.c
> > @@ -252,7 +252,7 @@ static __always_inline u64 steal_account_process_time(u64 maxtime)
> >  /*
> >   * Account how much elapsed time was spent in steal, irq, or softirq time.
> >   */
> > -static inline u64 account_other_time(u64 max)
> > +static inline u64 __maybe_unused account_other_time(u64 max)
> >  {
> >         u64 accounted;
> >
> > --
> > 2.28.0
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200818170337.805624-1-alex.dewar90%40gmail.com.
> 
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched/cputime: Mark function as __maybe_unused
  2020-08-18 19:57   ` Alex Dewar
@ 2020-08-18 20:02     ` Nick Desaulniers
  2020-08-18 20:20       ` Steven Rostedt
  2020-08-19  7:32       ` peterz
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Desaulniers @ 2020-08-18 20:02 UTC (permalink / raw)
  To: Alex Dewar
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, LKML,
	clang-built-linux

On Tue, Aug 18, 2020 at 12:57 PM Alex Dewar <alex.dewar90@gmail.com> wrote:
>
> On Tue, Aug 18, 2020 at 11:13:10AM -0700, Nick Desaulniers wrote:
> > On Tue, Aug 18, 2020 at 10:04 AM Alex Dewar <alex.dewar90@gmail.com> wrote:
> > >
> > > Depending on config options, account_other_time() may not be called
> > > anywhere. Add __maybe_unused flag to fix clang warning.
> >
> > Just curious, would moving this definition to be within an existing
> > preprocessor guard for a particular config also fix the issue? If so,
> > prefer that. If not, __maybe_unused is the way to go.
>
> I don't think that'd work here: it's used within an "#ifdef
> CONFIG_IRQ_TIME_ACCOUNTING" block and a separate "#ifdef
> CONFIG_VIRT_CPU_ACCOUNTING_GEN" one. We could do:
>         #if defined(CONFIG_IRQ_TIME_ACCOUNTING) ||
>             defined(CONFIG_VIRT_CPU_ACCOUNTING)
>                 ...
> ... but that might be a bit ugly.

Yeah, ok, in that case it's fine.  One issue with __maybe_unused is
that this function will stick around forever if all call sites get
removed.  But when the preprocessor checks start getting hairy,
__maybe_unused is maybe simpler.
Acked-by: Nick Desaulniers <ndesaulniers@google.com>

>
> >
> > >
> > > Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> > > ---
> > >  kernel/sched/cputime.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> > > index 5a55d2300452..43ede0d6661c 100644
> > > --- a/kernel/sched/cputime.c
> > > +++ b/kernel/sched/cputime.c
> > > @@ -252,7 +252,7 @@ static __always_inline u64 steal_account_process_time(u64 maxtime)
> > >  /*
> > >   * Account how much elapsed time was spent in steal, irq, or softirq time.
> > >   */
> > > -static inline u64 account_other_time(u64 max)
> > > +static inline u64 __maybe_unused account_other_time(u64 max)
> > >  {
> > >         u64 accounted;
> > >
> > > --
> > > 2.28.0
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> > > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200818170337.805624-1-alex.dewar90%40gmail.com.
> >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched/cputime: Mark function as __maybe_unused
  2020-08-18 20:02     ` Nick Desaulniers
@ 2020-08-18 20:20       ` Steven Rostedt
  2020-08-19  7:32       ` peterz
  1 sibling, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2020-08-18 20:20 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Alex Dewar, Ingo Molnar, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Ben Segall, Mel Gorman, LKML,
	clang-built-linux

On Tue, 18 Aug 2020 13:02:26 -0700
Nick Desaulniers <ndesaulniers@google.com> wrote:

> On Tue, Aug 18, 2020 at 12:57 PM Alex Dewar <alex.dewar90@gmail.com> wrote:
> >
> > On Tue, Aug 18, 2020 at 11:13:10AM -0700, Nick Desaulniers wrote:  
> > > On Tue, Aug 18, 2020 at 10:04 AM Alex Dewar <alex.dewar90@gmail.com> wrote:  
> > > >
> > > > Depending on config options, account_other_time() may not be called
> > > > anywhere. Add __maybe_unused flag to fix clang warning.  
> > >
> > > Just curious, would moving this definition to be within an existing
> > > preprocessor guard for a particular config also fix the issue? If so,
> > > prefer that. If not, __maybe_unused is the way to go.  
> >
> > I don't think that'd work here: it's used within an "#ifdef
> > CONFIG_IRQ_TIME_ACCOUNTING" block and a separate "#ifdef
> > CONFIG_VIRT_CPU_ACCOUNTING_GEN" one. We could do:
> >         #if defined(CONFIG_IRQ_TIME_ACCOUNTING) ||
> >             defined(CONFIG_VIRT_CPU_ACCOUNTING)
> >                 ...
> > ... but that might be a bit ugly.  
> 
> Yeah, ok, in that case it's fine.  One issue with __maybe_unused is
> that this function will stick around forever if all call sites get
> removed.  But when the preprocessor checks start getting hairy,
> __maybe_unused is maybe simpler.

For the reasons you state above, I'm almost thinking ugly may be better. :-/

But there's other places that have the "maybe_unused" in the scheduler
code for basically the same reasons, thus I guess it's OK.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve


> Acked-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> >  
> > >  
> > > >
> > > > Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> > > > ---
> > > >  kernel/sched/cputime.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> > > > index 5a55d2300452..43ede0d6661c 100644
> > > > --- a/kernel/sched/cputime.c
> > > > +++ b/kernel/sched/cputime.c
> > > > @@ -252,7 +252,7 @@ static __always_inline u64 steal_account_process_time(u64 maxtime)
> > > >  /*
> > > >   * Account how much elapsed time was spent in steal, irq, or softirq time.
> > > >   */
> > > > -static inline u64 account_other_time(u64 max)
> > > > +static inline u64 __maybe_unused account_other_time(u64 max)
> > > >  {
> > > >         u64 accounted;
> > > >
> > > > --
> > > > 2.28.0
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> > > > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200818170337.805624-1-alex.dewar90%40gmail.com.  
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > ~Nick Desaulniers  
> 
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched/cputime: Mark function as __maybe_unused
  2020-08-18 20:02     ` Nick Desaulniers
  2020-08-18 20:20       ` Steven Rostedt
@ 2020-08-19  7:32       ` peterz
  1 sibling, 0 replies; 6+ messages in thread
From: peterz @ 2020-08-19  7:32 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Alex Dewar, Ingo Molnar, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, LKML,
	clang-built-linux

On Tue, Aug 18, 2020 at 01:02:26PM -0700, Nick Desaulniers wrote:
> On Tue, Aug 18, 2020 at 12:57 PM Alex Dewar <alex.dewar90@gmail.com> wrote:
> >
> > On Tue, Aug 18, 2020 at 11:13:10AM -0700, Nick Desaulniers wrote:
> > > On Tue, Aug 18, 2020 at 10:04 AM Alex Dewar <alex.dewar90@gmail.com> wrote:
> > > >
> > > > Depending on config options, account_other_time() may not be called
> > > > anywhere. Add __maybe_unused flag to fix clang warning.
> > >
> > > Just curious, would moving this definition to be within an existing
> > > preprocessor guard for a particular config also fix the issue? If so,
> > > prefer that. If not, __maybe_unused is the way to go.
> >
> > I don't think that'd work here: it's used within an "#ifdef
> > CONFIG_IRQ_TIME_ACCOUNTING" block and a separate "#ifdef
> > CONFIG_VIRT_CPU_ACCOUNTING_GEN" one. We could do:
> >         #if defined(CONFIG_IRQ_TIME_ACCOUNTING) ||
> >             defined(CONFIG_VIRT_CPU_ACCOUNTING)
> >                 ...
> > ... but that might be a bit ugly.
> 
> Yeah, ok, in that case it's fine.  One issue with __maybe_unused is
> that this function will stick around forever if all call sites get
> removed.  But when the preprocessor checks start getting hairy,
> __maybe_unused is maybe simpler.

Urgh, also, I have vague memories that we made it 'static inline' to
avoid all this. Should we instead mark it __always_inline ?

Also; I detest the placement of __maybe_unused, it is not a return
value, but a git-grep showed me it is wide-spread :/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-19  7:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 17:03 [PATCH] sched/cputime: Mark function as __maybe_unused Alex Dewar
2020-08-18 18:13 ` Nick Desaulniers
2020-08-18 19:57   ` Alex Dewar
2020-08-18 20:02     ` Nick Desaulniers
2020-08-18 20:20       ` Steven Rostedt
2020-08-19  7:32       ` peterz

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).