Re: [PATCH] percpu: make this_cpu_generic_read() atomic w.r.t. interrupts
From: Tejun Heo
Date: Mon Sep 25 2017 - 11:44:12 EST
Hello,
On Mon, Sep 25, 2017 at 04:33:02PM +0100, Mark Rutland wrote:
> Unfortunately, the generic this_cpu_read(), which is intended to be
> irq-safe, is not:
>
> #define this_cpu_generic_read(pcp) \
> ({ \
> typeof(pcp) __ret; \
> preempt_disable_notrace(); \
> __ret = raw_cpu_generic_read(pcp); \
> preempt_enable_notrace(); \
> __ret; \
> })
I see. Yeah, that looks like the bug there.
> I guess it'd be preferable to manipulate that in-place.
>
> > Adding READ_ONCE() doesn't generically guarantee that the reads won't
> > be split - e.g. there are arch which simply can't load a 64bit value
> > with a single instruction.
>
> In which case, it really sounds like this_cpu_generic_read() needs to
> disable interrupts too...
Can you please spin up a patch for this?
Thanks.
--
tejun