lkml.org 
[lkml]   [2017]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC tip/core/rcu 12/15] lib/assoc_array: Remove smp_read_barrier_depends()
On Wed, Oct 11, 2017 at 05:07:05PM +0100, David Howells wrote:
> Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote:
>
> > It does not. In most cases, the barriered version would be
> > smp_store_release().
>
> Ummm... Is that good enough? Is:
>
> WRITE_ONCE(x, 1);
> WRITE_ONCE(x, 2);
>
> equivalent to:
>
> smp_store_release(x, 1);
> smp_store_release(x, 2);
>
> if CONFIG_SMP=n?

smp_store_release(&x, 1);
smp_store_release(&x, 2);

But yes, give or take that smp_store_release() potentially disables
more compiler optimizations than does WRITE_ONCE().

> (Consider what happens if an interrupt messes with x).

OK, I will bite... What is your scenario in which an interrupt
gives different results for CONFIG_SMP=n? The barriers

> If it is good enough, should we be using smp_load_acquire() rather than
> READ_ONCE()?

On x86, that might be OK, give or take that smp_load_acquire() potentially
disables more optimizations than does READ_ONCE(). But on ARM, PowerPC,
MIPS, and so on, smp_load_acquire() emits a memory-barrier instruction
and READ_ONCE() does not.

Thanx, Paul

\
 
 \ /
  Last update: 2017-10-11 18:22    [W:0.167 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site