Re: [PATCH 1/9] sched/core: add is_kthread() helper

From: Peter Zijlstra
Date: Wed Aug 21 2019 - 07:21:43 EST


On Mon, Aug 19, 2019 at 10:52:13AM +0200, Ingo Molnar wrote:
> * Mark Rutland <mark.rutland@xxxxxxx> wrote:
> > On Wed, Aug 14, 2019 at 01:26:43PM +0200, Geert Uytterhoeven wrote:
> > > On Wed, Aug 14, 2019 at 12:43 PM Mark Rutland <mark.rutland@xxxxxxx> wrote:

> > > > +static inline bool is_kthread(const struct task_struct *p)
> > > > +{
> > > > + return !!(p->flags & PF_KTHREAD);
> > >
> > > The !! is not really needed.
> > > Probably you followed is_idle_task() above (where it's also not needed).
> >
> > Indeed! I'm aware of the implicit bool conversion, but kept that for
> > consistency.
> >
> > Peter, Ingo, do you have a preference?
>
> So the !! pattern is useful where the return value is an integer (i.e.
> there's a risk of non-bool use) - but the return value is an explicit
> bool here, so !! is IMO an entirely superfluous obfuscation.

Yeah, no real preference, for giggles, (_Bool) also seems to work.