Re: [PATCH 3/3] timer: Reduce unnecessary sighand lock contention

Frederic Weisbecker
2015-08-27T21:12:26Z

On Thu, Aug 27, 2015 at 01:29:50PM -0700, Jason Low wrote:
> On Thu, 2015-08-27 at 14:53 +0200, Frederic Weisbecker wrote:
> > Sure, like:
> >
> > #define CPUTIMER_RUNNING 0x1
> > #define CPUTIMER_CHECKING 0x2
> >
> > struct thread_group_cputimer {
> > struct task_cputime_atomic cputime_atomic;
> > int status;
> > }
> >
> > So from cputimer_running() you just need to check:
> >
> > if (cputimer->status & CPUTIMER_RUNNING)
> >
> > And from run_posix_cpu_timer() fast-path:
> >
> > if (cputimer->status == CPUTIMER_RUNNING)
> >
> > so that ignores CPUTIMER_CHECKING case.
>
> Right, having just 1 "status" field can simply things a bit. The
> (cputimer->status == CPUTIMER_RUNNING) check does appear misleading
> though, since we're technically not only checking for if the "cputimer
> is running".
>
> Maybe something like:
>
> int status = cputimer->status;
> if ((status & CPUTIMER_RUNNING) && !(status & CPUTIMER_CHECKING))
>
> makes it more obvious what's going on here.

The result is the same but it may clarify the code indeed.

Thanks.