Re: [PATCH percpu/for-3.18-fixes] percpu-ref: fix DEAD flag contamination of percpu pointer

From: Shaohua Li
Date: Sat Nov 22 2014 - 19:47:16 EST


On Sat, Nov 22, 2014 at 12:06:02PM -0500, Tejun Heo wrote:
> On Sat, Nov 22, 2014 at 09:04:48AM -0800, Shaohua Li wrote:
> ...
> > > + /*
> > > + * Theoretically, the following could test just ATOMIC; however,
> > > + * then we'd have to mask off DEAD separately as DEAD may be
> > > + * visible without ATOMIC if we race with percpu_ref_kill(). DEAD
> > > + * implies ATOMIC anyway. Test them together.
> > > + */
> > > + if (unlikely(percpu_ptr & __PERCPU_REF_ATOMIC_DEAD))
> > > return false;
> >
> > this sounds not the correct answer. the DEAD/ATOMIC bit can be set by
> > percpu_ref_kill() right after the check.
>
> Yes, but that's why we're fetching @percpu_ptr with ACCESS_ONCE()
> before checking the flags.

Ok, I forgot we cache the percpu_ptr. Yes, this does work. You can add my
signed-off in the patch.

Thanks,
Shaohua
--
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/