[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.20.1709260143330.21864@nuc-kabylake>
Date: Tue, 26 Sep 2017 01:47:27 -0500 (CDT)
From: Christopher Lameter <cl@...ux.com>
To: Tejun Heo <tj@...nel.org>
cc: Mark Rutland <mark.rutland@....com>, linux-kernel@...r.kernel.org,
Arnd Bergmann <arnd@...db.de>,
Peter Zijlstra <peterz@...radead.org>,
Pranith Kumar <bobby.prani@...il.com>,
linux-arch@...r.kernel.org
Subject: Re: [PATCH] percpu: make this_cpu_generic_read() atomic w.r.t.
interrupts
On Mon, 25 Sep 2017, Tejun Heo wrote:
> 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.
This is a single fetch operation of a value that needs to be atomic. It
really does not matter if an interrupt happens before or after that load
because it could also occur before or after the preempt_enable/disable
without the code being able to distinguish that case.
The fetch of a scalar value from memory is an atomic operation and that is
required from all arches. There is an exception for double word fetches.
Maybe we would need to special code that case but so far this does not
seem to have been an issue.
Powered by blists - more mailing lists