Re: [PATCH 08/14] hrtimer: Allow hrtimer::function() to free the timer
From: Peter Zijlstra
Date: Mon Jun 08 2015 - 06:55:51 EST
On Mon, Jun 08, 2015 at 11:14:17AM +0200, Peter Zijlstra wrote:
> On Mon, Jun 08, 2015 at 12:33:17AM +0200, Oleg Nesterov wrote:
> > Not sure I read this patch correctly, it doesn't apply to Linus's tree.
>
> I was working on tip/master, there's a number of timer patches in there.
>
> > And I simply can not understand the complication in hrtimer_active(),
> > please help!
> >
> > On 06/05, Peter Zijlstra wrote:
> > >
> > > +bool hrtimer_active(const struct hrtimer *timer)
> > > +{
> > > + struct hrtimer_cpu_base *cpu_base;
> > > + unsigned int seq;
> > > + bool active;
> > > +
> > > + do {
> > > + active = false;
> > > + cpu_base = READ_ONCE(timer->base->cpu_base);
> > > + seq = raw_read_seqcount(&cpu_base->seq);
> > > +
> > > + if (timer->state != HRTIMER_STATE_INACTIVE ||
> > > + cpu_base->running == timer)
> > > + active = true;
> >
> > Why we can't simply return true in this case?
> >
> > Unless you lock this timer, hrtimer_active() is inherently racy anyway.
> > Granted, it must not wrongly return False if the timer is pending or
> > running.
> >
> > But "false positive" does not differ from the case when (say) the
> > running timer->function() finishes right after hrtimer_active() returns
> > True.
OK I can't read; you asked why delay the return true inside that loop.
Yes we can as per your argument. I think I ended up being too paranoid
or something.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/