Re: [PATCH] sched/cputime: Mark function as __maybe_unused

From: Alex Dewar
Date: Tue Aug 18 2020 - 15:57:55 EST


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@xxxxxxxxx> 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@xxxxxxxxx>
> > ---
> > 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@xxxxxxxxxxxxxxxx.
> > 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