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

From: peterz
Date: Wed Aug 19 2020 - 03:33:19 EST


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@xxxxxxxxx> 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@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.
>
> 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 :/