lkml.org 
[lkml]   [2020]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 11/19] sched/core: Make migrate disable and CPU hotplug cooperative
On Fri, Oct 16, 2020 at 11:43:17AM +0800, zhout wrote:
> On Thu, Oct 15, 2020 at 01:05:43PM +0200, Peter Zijlstra wrote:
> > From: Thomas Gleixner <tglx@linutronix.de>
> >
>
> [ ... ]
>
> > +static inline bool rq_has_pinned_tasks(struct rq *rq)
> > +{
> > + return rq->nr_pinned;
> > +}
> > +
>
> Even I do not understand well enough, the return type of the
> above function is bool and rq->nr_pinned is unsigned int.
> Write this way:
>
> static inline bool rq_has_pinned_tasks(struct rq *rq)
> {
> return !!rq->nr_pinned;
> }

The C compiler does this for us. C has a lot of implicit type
conversions.

It is the same mechanism at work when we write:

if (rq->nr_pinned)

We know that works and we don't have to write:

if (!!rq->nr_pinned)

(although we may, but it is pointless).

\
 
 \ /
  Last update: 2020-10-16 11:36    [W:0.492 / U:0.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site