Re: [PATCH v7 4/6] powerpc: lib/locks.c: Add cpu yield/wake helper function

2016-09-22 Thread Boqun Feng
Hi Xinhui, On Mon, Sep 19, 2016 at 05:23:55AM -0400, Pan Xinhui wrote: > Add two corresponding helper functions to support pv-qspinlock. > > For normal use, __spin_yield_cpu will confer current vcpu slices to the > target vcpu(say, a lock holder). If target vcpu is not specified or it > is in run

Re: [PATCH] torture: use ktime_t consistently

2016-06-21 Thread Boqun Feng
Hi Paul, On Tue, Jun 21, 2016 at 11:39:46AM -0700, Paul E. McKenney wrote: > On Mon, Jun 20, 2016 at 09:29:56PM +0200, Arnd Bergmann wrote: > > On Monday, June 20, 2016 11:37:57 AM CEST Paul E. McKenney wrote: > > > On Mon, Jun 20, 2016 at 08:29:48PM +0200, Arnd Bergmann wrote: > > > > On Monday,

Re: [RFC PATCH v7 1/7] Restartable sequences system call

2016-07-27 Thread Boqun Feng
Hi Mathieu, On Thu, Jul 21, 2016 at 05:14:16PM -0400, Mathieu Desnoyers wrote: > Expose a new system call allowing each thread to register one userspace > memory area to be used as an ABI between kernel and user-space for two > purposes: user-space restartable sequences and quick access to read th

[RFC 1/4] rseq/param_test: Convert test_data_entry::count to intptr_t

2016-07-27 Thread Boqun Feng
, having test_data_entry::count as int needs more care on endian handling. To make things simpler and more consistent, convert test_data_entry::count to type intptr_t, which also makes the coming tests for ppc64le and ppc64 share the same code. Signed-off-by: Boqun Feng --- tools/testing/selftests

[RFC 3/4] Restartable sequences: Wire up powerpc system call

2016-07-27 Thread Boqun Feng
-conditional atomics. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc

[RFC 2/4] Restartable sequences: powerpc architecture support

2016-07-27 Thread Boqun Feng
Call the rseq_handle_notify_resume() function on return to userspace if TIF_NOTIFY_RESUME thread flag is set. Increment the event counter and perform fixup on the pre-signal when a signal is delivered on top of a restartable sequence critical section. Signed-off-by: Boqun Feng --- arch/powerpc

[RFC 4/4] Restartable sequences: Add self-tests for PPC

2016-07-27 Thread Boqun Feng
As rseq syscall is enabled on PPC, implement the self-tests on PPC to verify the implementation of the syscall. Please note we only support 32bit userspace on BE kernel. Signed-off-by: Boqun Feng --- tools/testing/selftests/rseq/param_test.c | 14 tools/testing/selftests/rseq/rseq.h

Re: [RFC 4/4] Restartable sequences: Add self-tests for PPC

2016-07-27 Thread Boqun Feng
On Thu, Jul 28, 2016 at 02:59:45AM +, Mathieu Desnoyers wrote: > - On Jul 27, 2016, at 11:05 AM, Boqun Feng boqun.f...@gmail.com wrote: > > > As rseq syscall is enabled on PPC, implement the self-tests on PPC to > > verify the implementation of the syscall. > >

[RFC v2] Restartable sequences: Add self-tests for PPC

2016-07-28 Thread Boqun Feng
As rseq syscall is enabled on PPC, implement the self-tests on PPC to verify the implementation of the syscall. Please note we only support 32bit userspace on BE kernel. Signed-off-by: Boqun Feng --- v1-->v2: 1. Remove branch in rseq_finish() fastpath 2. Use bne- instead of

Re: [PATCH 1/4] spinlock: Document memory barrier rules

2016-09-01 Thread Boqun Feng
On Thu, Sep 01, 2016 at 01:51:34PM +0200, Peter Zijlstra wrote: > On Thu, Sep 01, 2016 at 01:04:26PM +0200, Manfred Spraul wrote: > > > >So for both power and arm64, you can in fact model spin_unlock_wait() > > >as LOCK+UNLOCK. > > > Is this consensus? > > Dunno, but it was done to fix your earl

Re: [RFC][PATCH] Fix a race between rwsem and the scheduler

2016-09-01 Thread Boqun Feng
On Thu, Sep 01, 2016 at 08:57:38AM +0200, Peter Zijlstra wrote: > On Thu, Sep 01, 2016 at 07:47:10AM +1000, Benjamin Herrenschmidt wrote: > > > > OK, for giggles, could you (or Balbir) check what happens if you take > > > that sync out? > > > The problem is no amount of testing can tell you it wo

Re: [PATCH 8/7] net/netfilter/nf_conntrack_core: Remove another memory barrier

2016-09-01 Thread Boqun Feng
Hi Manfred, On Thu, Sep 01, 2016 at 06:41:26PM +0200, Peter Zijlstra wrote: > On Thu, Sep 01, 2016 at 04:30:39PM +0100, Will Deacon wrote: > > On Thu, Sep 01, 2016 at 05:27:52PM +0200, Manfred Spraul wrote: > > > Since spin_unlock_wait() is defined as equivalent to spin_lock(); > > > spin_unlock()

Re: [RFC PATCH v7 1/7] Restartable sequences system call

2016-08-07 Thread Boqun Feng
On Sun, Aug 07, 2016 at 03:36:24PM +, Mathieu Desnoyers wrote: > - On Aug 3, 2016, at 11:45 AM, Boqun Feng boqun.f...@gmail.com wrote: > > > On Wed, Aug 03, 2016 at 03:19:40PM +0200, Peter Zijlstra wrote: > >> On Thu, Jul 21, 2016 at 05:14:16PM -0400, Mathieu Desnoye

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote: > On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote: > > > > So with the latest fixes there's a new lockdep warning on one of my > > testboxes: > > > > [ 11.322487] EXT4-fs (sda2): mounted filesystem with ordered data mo

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 01:37:46PM +0900, Byungchul Park wrote: > On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote: > > On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote: > > > On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote: > > > &g

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 02:05:06PM +0900, Byungchul Park wrote: > On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote: > > > I see... > > > > > > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be > > > released > > >

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-17 Thread Boqun Feng
On Thu, Aug 17, 2017 at 09:48:11AM +0200, Ingo Molnar wrote: > > * Boqun Feng wrote: > > > --- a/kernel/workqueue.c > > +++ b/kernel/workqueue.c > > @@ -2431,6 +2431,27 @@ struct wq_barrier { > > struct task_struct *task; /* purely informati

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-17 Thread Boqun Feng
On Thu, Aug 17, 2017 at 10:12:24AM +0200, Ingo Molnar wrote: > > * Boqun Feng wrote: > > > > BTW., I don't think the #ifdef is necessary: lockdep_init_map_crosslock > > > should map > > > to nothing when lockdep is disabled, right? > > >

[PATCH] workqueue/lockdep: Explicitly initialize wq_barrier::done::map

2017-08-17 Thread Boqun Feng
, so the false positive above is avoided. Also define the empty lockdep_init_map_crosslock() for !CROSSRELEASE to make the code simple and away from unnecessary #ifdefs. Reported-by: Ingo Molnar Signed-off-by: Boqun Feng Cc: Byungchul Park --- include/linux/lockdep.h | 1 + kernel/workqueue.c

Re: [RFC PATCH for 4.15 14/14] Restartable sequences: Provide self-tests

2017-10-15 Thread Boqun Feng
equence made of zero or more loads, one > > speculative word-sized store, completed by a word-sized store with > > release semantic, > > - rseq_finish_memcpy(): > > End of restartable sequence made of zero or more loads, a > > speculative copy of a variable length

Re: [PATCH v7 0/6] vfs: Use dlock list for SB's s_inodes list

2017-10-26 Thread Boqun Feng
On Thu, Oct 26, 2017 at 02:28:55PM -0400, Waiman Long wrote: > On 10/05/2017 02:43 PM, Waiman Long wrote: > > > > This is a follow up of the following patchset: > > > > [PATCH v7 0/4] vfs: Use per-cpu list for SB's s_inodes list > > https://lkml.org/lkml/2016/4/12/1009 > > > > This patchset pro

Re: [PATCH v7 1/6] lib/dlock-list: Distributed and lock-protected lists

2017-10-18 Thread Boqun Feng
On Thu, Oct 05, 2017 at 06:43:23PM +, Waiman Long wrote: [...] > +/* > + * Find the first entry of the next available list. > + */ > +extern struct dlock_list_node * > +__dlock_list_next_list(struct dlock_list_iter *iter); > + > +/** > + * __dlock_list_next_entry - Iterate to the next entry of

Re: [PATCH v7 10/10] lib/dlock-list: Fix use-after-unlock problem in dlist_for_each_entry_safe()

2017-10-30 Thread Boqun Feng
ate the use-after-unlock problem. > > Better than what I proposed, thanks for looking into this! > > Reported-by: Boqun Feng > > Signed-off-by: Waiman Long > > Looks good to me. You can add: > > Rev

[RFC 0/5] atomics: powerpc: implement relaxed/acquire/release variants of some atomics

2015-08-27 Thread Boqun Feng
Relaxed/acquire/release variants of atomic operations {add,sub}_return and {cmp,}xchg are introduced by commit: "atomics: add acquire/release/relaxed variants of some atomic operations" which is now on locking/core branch of tip tree. By default, the generic code will implement relaxed variants

[RFC 4/5] powerpc: atomic: implement xchg_* and atomic{,64}_xchg_* variants

2015-08-27 Thread Boqun Feng
Implement xchg_relaxed and define atomic{,64}_xchg_* as xchg_relaxed, based on these _relaxed variants, release/acquire variants can be built. Note that xchg_relaxed and atomic_{,64}_xchg_relaxed are not compiler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 2

[RFC 5/5] powerpc: atomic: implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-08-27 Thread Boqun Feng
Unlike other atomic operation variants, cmpxchg{,64}_acquire and atomic{,64}_cmpxchg_acquire don't have acquire semantics if the cmp part fails, so we need to implement these using assembly. Note cmpxchg{,64}_relaxed and atomic{,64}_cmpxchg_relaxed are not compiler barriers. Signed-off-by:

[RFC 2/5] atomics: introduce arch_atomic_op_{acquire,release,fence} helpers

2015-08-27 Thread Boqun Feng
variants based on _relaxed variants. Signed-off-by: Boqun Feng --- include/linux/atomic.h | 16 1 file changed, 16 insertions(+) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 00a5763..622255b 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h

[RFC 1/5] atomics: add test for atomic operations with _relaxed variants

2015-08-27 Thread Boqun Feng
that we can examine their assembly code. Signed-off-by: Boqun Feng --- lib/atomic64_test.c | 91 ++--- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index 83c33a5b..0484437 100644 --- a/lib

[RFC 3/5] powerpc: atomic: implement atomic{,64}_{add,sub}_return_* variants

2015-08-27 Thread Boqun Feng
ot; otherwise. For full ordered semantics, like the original ones, smp_lwsync() is put before relaxed variants and smp_mb__after_atomic() is put after. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 88 --- 1 file changed, 64 insertions(+), 24 deletions(-)

Re: [PATCH v2] sched: fix tsk->pi_lock isn't held when do_set_cpus_allowed()

2015-08-27 Thread Boqun Feng
Hi Wanpeng, On Fri, Aug 28, 2015 at 12:02:47PM +0800, Wanpeng Li wrote: > This patch fix it by following the rules for changing > task_struct::cpus_allowed > w/ both pi_lock and rq->lock are held. > > Reported-by: kernel test robot > Reported-by: Sasha Levin > Signed-off-by: Wanpeng Li > --

Re: [RFC 2/5] atomics: introduce arch_atomic_op_{acquire,release,fence} helpers

2015-08-28 Thread Boqun Feng
Hi Peter, On Fri, Aug 28, 2015 at 01:36:14PM +0200, Peter Zijlstra wrote: > On Fri, Aug 28, 2015 at 10:48:16AM +0800, Boqun Feng wrote: > > Some architectures may have their special barriers for acquire, release > > and fence semantics, general memory barriers(smp_mb_

Re: [RFC 3/5] powerpc: atomic: implement atomic{,64}_{add,sub}_return_* variants

2015-08-28 Thread Boqun Feng
Hi Peter, On Fri, Aug 28, 2015 at 12:48:54PM +0200, Peter Zijlstra wrote: > On Fri, Aug 28, 2015 at 10:48:17AM +0800, Boqun Feng wrote: > > +/* > > + * Since {add,sub}_return_relaxed and xchg_relaxed are implemented with > > + * a "bne-" instruction at the end, so

Re: [RFC 3/5] powerpc: atomic: implement atomic{,64}_{add,sub}_return_* variants

2015-08-28 Thread Boqun Feng
On Fri, Aug 28, 2015 at 08:06:14PM +0800, Boqun Feng wrote: > Hi Peter, > > On Fri, Aug 28, 2015 at 12:48:54PM +0200, Peter Zijlstra wrote: > > On Fri, Aug 28, 2015 at 10:48:17AM +0800, Boqun Feng wrote: > > > +/* > > > + * Since {add,sub}_return_relaxed and

Re: [RFC 3/5] powerpc: atomic: implement atomic{,64}_{add,sub}_return_* variants

2015-08-28 Thread Boqun Feng
On Fri, Aug 28, 2015 at 05:39:21PM +0200, Peter Zijlstra wrote: > On Fri, Aug 28, 2015 at 10:16:02PM +0800, Boqun Feng wrote: > > > > Ah.. just read through the thread you mentioned, I might misunderstand > > you, probably because I didn't understand RCpc well.. > &g

Re: wake_up_process implied memory barrier clarification

2015-08-29 Thread Boqun Feng
t still be 0 even if we add a write barrier explicitly, which means that even if wake_up() guarantees a write barrier, the original example still doesn't have the desired order guarantee. In fact, the original example can explains the conditionality of barriers in wait_*() rather than wak

Re: wake_up_process implied memory barrier clarification

2015-08-30 Thread Boqun Feng
Hi Oleg, On Sat, Aug 29, 2015 at 04:27:07PM +0200, Oleg Nesterov wrote: > Hello Boqun, > ... > > By this, I think you actually means the example below the added text, > > i.e. the example for "to repeat..", right? > > And above. Even > > The barrier occurs before the task state is cleared

Re: wake_up_process implied memory barrier clarification

2015-08-31 Thread Boqun Feng
Hi Paul, On Mon, Aug 31, 2015 at 01:37:39PM -0700, Paul E. McKenney wrote: > On Mon, Aug 31, 2015 at 08:33:35PM +0200, Oleg Nesterov wrote: > > On 08/31, Boqun Feng wrote: > > > > > > Fair enough, I went too far. How about just a single paragraph saying > >

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Boqun Feng
On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nesterov wrote: > On 09/01, Boqun Feng wrote: > > > > But I'm still a little confused at Oleg's words: > > > > "What is really important is that we have a barrier before we _read_ the > > task state.&qu

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Boqun Feng
On Tue, Sep 01, 2015 at 06:39:23PM +0200, Oleg Nesterov wrote: > On 09/01, Boqun Feng wrote: > > > > On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nesterov wrote: > > > > > > And just in case, wake_up() differs in a sense that it doesn't even need > >

Re: [PATCH] Documentation: Remove misleading examples of the barriers in wake_*()

2015-10-12 Thread Boqun Feng
On Sun, Oct 11, 2015 at 05:40:44PM -0700, Paul E. McKenney wrote: > On Sun, Oct 11, 2015 at 11:26:40PM +0800, Boqun Feng wrote: > > On Tue, Oct 06, 2015 at 06:06:50PM +0200, Peter Zijlstra wrote: > > > On Thu, Sep 24, 2015 at 09:21:22PM +0800, Boqun Feng wrote: > > > >

Re: [RFC v2 1/7] atomics: Add test for atomic operations with _relaxed variants

2015-10-12 Thread Boqun Feng
On Mon, Oct 12, 2015 at 10:30:34AM +0100, Will Deacon wrote: > On Wed, Sep 16, 2015 at 04:49:29PM +0100, Boqun Feng wrote: > > Some atomic operations now have _{relaxed, acquire, release} variants, > > this patch then adds some trivial tests for two purpose: > > > > 1.

Re: [PATCH] Documentation: Remove misleading examples of the barriers in wake_*()

2015-10-12 Thread Boqun Feng
On Mon, Oct 12, 2015 at 01:54:38PM +0200, Peter Zijlstra wrote: > On Mon, Oct 12, 2015 at 05:06:36PM +0800, Boqun Feng wrote: > > Understood. > > > > But, IMO, the position of this section is already misleading: > > > > (*) Implicit kernel memory barri

[PATCH v3 0/6] atomics: powerpc: Implement relaxed/acquire/release variants of some atomics

2015-10-12 Thread Boqun Feng
Hi, This is v3 of the series. Link for v1: https://lkml.org/lkml/2015/8/27/798 Link for v2: https://lkml.org/lkml/2015/9/16/527 Paul, Peter and Will, thank you all for the comments and suggestions, that's really a lot of fun to discuss these with you and very enlightening to me ;-) Changes sinc

[PATCH v3 2/6] atomics: Add test for atomic operations with _relaxed variants

2015-10-12 Thread Boqun Feng
that we can examine their assembly code. Signed-off-by: Boqun Feng --- lib/atomic64_test.c | 120 ++-- 1 file changed, 79 insertions(+), 41 deletions(-) diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index 83c33a5b..18e422b 100644 --- a/lib

[PATCH v3 4/6] powerpc: atomic: Implement atomic{,64}_*_return_* variants

2015-10-12 Thread Boqun Feng
__atomic_op_fence is defined as smp_lwsync() + _relaxed + smp_mb__after_atomic() to guarantee a full barrier. Implement atomic{,64}_{add,sub,inc,dec}_return_relaxed, and build other variants with these helpers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 122 ++

[PATCH v3 3/6] atomics: Allow architectures to define their own __atomic_op_* helpers

2015-10-12 Thread Boqun Feng
-by: Boqun Feng --- include/linux/atomic.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 27e580d..947c1dc 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -43,20 +43,29 @@ static inline int atomic_read_ctrl

[PATCH v3 5/6] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants

2015-10-12 Thread Boqun Feng
Implement xchg_relaxed and atomic{,64}_xchg_relaxed, based on these _relaxed variants, release/acquire variants and fully ordered versions can be built. Note that xchg_relaxed and atomic_{,64}_xchg_relaxed are not compiler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm

[PATCH v3 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-12 Thread Boqun Feng
, we keep the assembly implementation of fully ordered cmpxchg operations. Note cmpxchg{,64}_relaxed and atomic{,64}_cmpxchg_relaxed are not compiler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 10 +++ arch/powerpc/include/asm/cmpxchg.h | 141

Re: [PATCH v3 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-12 Thread Boqun Feng
Oops.. sorry. I will resend this one with correct address list. On Mon, Oct 12, 2015 at 10:14:01PM +0800, Boqun Feng wrote: > According to memory-barriers.txt, xchg, cmpxchg and their atomic{,64}_ > versions all need to imply a full barrier, however they are now just > RELEASE+ACQUIRE,

[PATCH RESEND v3 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-12 Thread Boqun Feng
PPC_ATOMIC_EXIT_BARRIER in __{cmp,}xchg_{u32,u64} respectively to guarantee a full barrier semantics of atomic{,64}_{cmp,}xchg() and {cmp,}xchg(). This patch is a complement of commit b97021f85517 ("powerpc: Fix atomic_xxx_return barrier semantics"). Cc: # 3.4.y- Signed-off-by: Boqun Feng --- arch/power

Re: [lkp] [PATCH v3 2/6] atomics: Add test for atomic operations with _relaxed variants

2015-10-12 Thread Boqun Feng
sts.ozlabs.org", "Peter Zijlstra ", > "Ingo Molnar " > , "Benjamin Herrenschmidt ", "Paul Mackerras > ", "Michael Ellerman ", "Thomas > Gleixner e>", "Will Deacon ", "\"Paul E. McKenney\" &

Re: [kbuild-all] [lkp] [PATCH v3 2/6] atomics: Add test for atomic operations with _relaxed variants

2015-10-12 Thread Boqun Feng
On Tue, Oct 13, 2015 at 12:02:00AM +0800, Fengguang Wu wrote: > On Mon, Oct 12, 2015 at 11:42:24PM +0800, Boqun Feng wrote: > > Hi Fengguang, > > > > On Mon, Oct 12, 2015 at 11:29:14PM +0800, Fengguang Wu wrote: > > > Hi Boqun, > > > > > > The base

Re: [PATCH v3 4/6] powerpc: atomic: Implement atomic{,64}_*_return_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 02:21:32PM +0100, Will Deacon wrote: > On Mon, Oct 12, 2015 at 10:14:04PM +0800, Boqun Feng wrote: [snip] > > +/* > > + * Since {add,sub}_return_relaxed and xchg_relaxed are implemented with > > + * a "bne-" instruction at the end, so

Re: [PATCH v3 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 02:24:04PM +0100, Will Deacon wrote: > On Mon, Oct 12, 2015 at 10:14:06PM +0800, Boqun Feng wrote: > > Implement cmpxchg{,64}_relaxed and atomic{,64}_cmpxchg_relaxed, based on > > which _release variants can be built. > > > > To avoid super

Re: [PATCH v3 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 10:32:59PM +0800, Boqun Feng wrote: > On Tue, Oct 13, 2015 at 02:24:04PM +0100, Will Deacon wrote: > > On Mon, Oct 12, 2015 at 10:14:06PM +0800, Boqun Feng wrote: > > > Implement cmpxchg{,64}_relaxed and atomic{,64}_cmpxchg_relaxed, based on > > &

Re: [PATCH v3 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 03:43:33PM +0100, Will Deacon wrote: > On Tue, Oct 13, 2015 at 10:32:59PM +0800, Boqun Feng wrote: [snip] > > > > Mostly because of the comments in include/linux/atomic.h: > > > > * For compound atomics performing both a load and a store, ACQ

Re: [PATCH v3 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 04:04:27PM +0100, Will Deacon wrote: > On Tue, Oct 13, 2015 at 10:58:30PM +0800, Boqun Feng wrote: > > On Tue, Oct 13, 2015 at 03:43:33PM +0100, Will Deacon wrote: > > > Putting a barrier in the middle of that critical section is probably a > > >

Re: [PATCH RESEND v3 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-13 Thread Boqun Feng
On Wed, Oct 14, 2015 at 11:10:00AM +1100, Michael Ellerman wrote: > On Mon, 2015-10-12 at 22:30 +0800, Boqun Feng wrote: > > According to memory-barriers.txt, xchg, cmpxchg and their atomic{,64}_ > > versions all need to imply a full barrier, however they are now just > > RELE

Re: [PATCH v3 4/6] powerpc: atomic: Implement atomic{,64}_*_return_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 09:35:54PM +0800, Boqun Feng wrote: > On Tue, Oct 13, 2015 at 02:21:32PM +0100, Will Deacon wrote: > > On Mon, Oct 12, 2015 at 10:14:04PM +0800, Boqun Feng wrote: > [snip] > > > +/* > > > + * Since {add,sub}_return_relaxed and xchg_relaxed ar

Re: [PATCH v3 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-13 Thread Boqun Feng
On Tue, Oct 13, 2015 at 04:04:27PM +0100, Will Deacon wrote: > On Tue, Oct 13, 2015 at 10:58:30PM +0800, Boqun Feng wrote: > > On Tue, Oct 13, 2015 at 03:43:33PM +0100, Will Deacon wrote: > > > Putting a barrier in the middle of that critical section is probably a > > >

Re: [PATCH RESEND v3 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-14 Thread Boqun Feng
On Wed, Oct 14, 2015 at 10:06:13AM +0200, Peter Zijlstra wrote: > On Wed, Oct 14, 2015 at 08:51:34AM +0800, Boqun Feng wrote: > > On Wed, Oct 14, 2015 at 11:10:00AM +1100, Michael Ellerman wrote: > > > > Thanks for fixing this. In future you should send a patch like this as a

[PATCH tip/locking/core v4 0/6] atomics: powerpc: Implement relaxed/acquire/release variants of some atomics

2015-10-14 Thread Boqun Feng
Hi all, This is v4 of the series. Link for v1: https://lkml.org/lkml/2015/8/27/798 Link for v2: https://lkml.org/lkml/2015/9/16/527 Link for v3: https://lkml.org/lkml/2015/10/12/368 Changes since v3: * avoid to introduce smp_acquire_barrier__after_atomic() (Will Deacon) * e

[PATCH tip/locking/core v4 2/6] atomics: Add test for atomic operations with _relaxed variants

2015-10-14 Thread Boqun Feng
that we can examine their assembly code. Signed-off-by: Boqun Feng --- lib/atomic64_test.c | 120 ++-- 1 file changed, 79 insertions(+), 41 deletions(-) diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index 83c33a5b..18e422b 100644 --- a/lib

[PATCH tip/locking/core v4 3/6] atomics: Allow architectures to define their own __atomic_op_* helpers

2015-10-14 Thread Boqun Feng
-by: Boqun Feng --- include/linux/atomic.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 27e580d..947c1dc 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -43,20 +43,29 @@ static inline int atomic_read_ctrl

[PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-14 Thread Boqun Feng
PPC_ATOMIC_EXIT_BARRIER in __{cmp,}xchg_{u32,u64} respectively to guarantee a full barrier semantics of atomic{,64}_{cmp,}xchg() and {cmp,}xchg(). This patch is a complement of commit b97021f85517 ("powerpc: Fix atomic_xxx_return barrier semantics"). Acked-by: Michael Ellerman Cc: # 3.4+ Signed-off-by:

[PATCH tip/locking/core v4 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-14 Thread Boqun Feng
piler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 10 +++ arch/powerpc/include/asm/cmpxchg.h | 149 - 2 files changed, 158 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/includ

[PATCH tip/locking/core v4 5/6] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants

2015-10-14 Thread Boqun Feng
Implement xchg_relaxed and atomic{,64}_xchg_relaxed, based on these _relaxed variants, release/acquire variants and fully ordered versions can be built. Note that xchg_relaxed and atomic_{,64}_xchg_relaxed are not compiler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm

[PATCH tip/locking/core v4 4/6] powerpc: atomic: Implement atomic{,64}_*_return_* variants

2015-10-14 Thread Boqun Feng
defined as smp_lwsync() + _relaxed + smp_mb__after_atomic() to guarantee a full barrier. Implement atomic{,64}_{add,sub,inc,dec}_return_relaxed, and build other variants with these helpers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 116 ---

[PATCH] powerpc: Kconfig: remove BE-only platforms from LE kernel build

2015-09-06 Thread Boqun Feng
[Suggested-by: Cédric Le Goater ]. Signed-off-by: Boqun Feng --- arch/powerpc/platforms/cell/Kconfig | 4 ++-- arch/powerpc/platforms/maple/Kconfig| 2 +- arch/powerpc/platforms/pasemi/Kconfig | 2 +- arch/powerpc/platforms/powermac/Kconfig | 2 +- arch/powerpc/platforms/ps3/Kconfig | 2

Re: wake_up_process implied memory barrier clarification

2015-09-07 Thread Boqun Feng
Hi Oleg, On Mon, Sep 07, 2015 at 07:06:52PM +0200, Oleg Nesterov wrote: > Sorry for delay, > > On 09/02, Boqun Feng wrote: > > > > On Tue, Sep 01, 2015 at 06:39:23PM +0200, Oleg Nesterov wrote: > > > On 09/01, Boqun Feng wrote: > > > > > > &g

[PATCH] Documentation: Remove misleading examples of the barriers in wake_*()

2015-09-07 Thread Boqun Feng
r to call this out and remove the misleading examples. This patch removes the misleading examples along with their explanations, calls it out that those implied barriers are only for sleep and wakeup related variables and adds a new example to explain the implied barrier in wake_up() and c

[PATCH v2] atomics,cmpxchg: Privatize the inclusion of asm/cmpxchg.h

2015-09-08 Thread Boqun Feng
definitions of all the{cmp,}xchg variants. Therefore, we should privatize the inclusions of asm/cmpxchg.h to keep it only included in arch/* and replace the inclusions outside with linux/atomic.h Acked-by: Will Deacon Signed-off-by: Boqun Feng --- v1 --> v2: 1. rebase on current mas

Re: [PATCH] powerpc: Kconfig: remove BE-only platforms from LE kernel build

2015-09-08 Thread Boqun Feng
Hi Michael, On Wed, Sep 09, 2015 at 12:26:44PM +1000, Michael Ellerman wrote: > On Mon, 2015-09-07 at 07:58 +0800, Boqun Feng wrote: > > diff --git a/arch/powerpc/platforms/cell/Kconfig > > b/arch/powerpc/platforms/cell/Kconfig > > index 2f23133..808a904 100644 > > -

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-14 Thread Boqun Feng
On Wed, Oct 14, 2015 at 02:44:53PM -0700, Paul E. McKenney wrote: > On Wed, Oct 14, 2015 at 11:04:19PM +0200, Peter Zijlstra wrote: > > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > > Suppose we have something like the following, where "a" and "x" are both > > > initially ze

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-14 Thread Boqun Feng
On Thu, Oct 15, 2015 at 08:53:21AM +0800, Boqun Feng wrote: > On Wed, Oct 14, 2015 at 02:44:53PM -0700, Paul E. McKenney wrote: > > On Wed, Oct 14, 2015 at 11:04:19PM +0200, Peter Zijlstra wrote: > > > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: >

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-14 Thread Boqun Feng
Hi Paul, On Thu, Oct 15, 2015 at 08:53:21AM +0800, Boqun Feng wrote: > On Wed, Oct 14, 2015 at 02:44:53PM -0700, Paul E. McKenney wrote: [snip] > > To that end, the herd tool can make a diagram of what it thought > > happened, and I have attached it. I used this diagram to try and

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-14 Thread Boqun Feng
On Wed, Oct 14, 2015 at 08:07:05PM -0700, Paul E. McKenney wrote: > On Thu, Oct 15, 2015 at 08:53:21AM +0800, Boqun Feng wrote: [snip] > > > > I'm afraid more than that, the above litmus also shows that > > > > CPU 0

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-15 Thread Boqun Feng
On Thu, Oct 15, 2015 at 11:35:44AM +0100, Will Deacon wrote: > > So arm64 is ok. Doesn't lwsync order store->store observability for PPC? > I did some litmus and put the result here. My understanding might be wrong, and I think Paul can explain the lwsync and store->store order better ;-) When

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-15 Thread Boqun Feng
On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > On Wed, Oct 14, 2015 at 11:55:56PM +0800, Boqun Feng wrote: > > According to memory-barriers.txt, xchg, cmpxchg and their atomic{,64}_ > > versions all need to imply a full barrier, however they are now just >

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-21 Thread Boqun Feng
On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > On Tue, Oct 20, 2015 at 11:21:47AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 03:15:32PM +0800, Boqun Feng wrote: > > > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > &

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-22 Thread Boqun Feng
On Wed, Oct 21, 2015 at 09:48:25PM +0200, Peter Zijlstra wrote: > On Wed, Oct 21, 2015 at 12:35:23PM -0700, Paul E. McKenney wrote: > > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > > > > > > > https://lkml.org/lkml/2015/8/26/596 > > > > So a full barrier on o

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-18 Thread Boqun Feng
On Thu, Oct 15, 2015 at 09:30:40AM -0700, Paul E. McKenney wrote: > On Thu, Oct 15, 2015 at 12:48:03PM +0800, Boqun Feng wrote: > > On Wed, Oct 14, 2015 at 08:07:05PM -0700, Paul E. McKenney wrote: [snip] > > > > > Why not try creating a longer litmus test that requires P0

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-18 Thread Boqun Feng
On Fri, Oct 09, 2015 at 10:40:39AM +0100, Will Deacon wrote: > On Fri, Oct 09, 2015 at 10:31:38AM +0200, Peter Zijlstra wrote: [snip] > > > > So lots of little confusions added up to complete fail :-{ > > > > Mostly I think it was the UNLOCK x + LOCK x are fully ordered (where I > > forgot: but n

Re: [PATCH tip/locking/core v8 1/5] locking/qspinlock: Use _acquire/_release versions of cmpxchg & xchg

2015-10-19 Thread Boqun Feng
Hi Waiman, On Thu, Oct 15, 2015 at 06:51:03PM -0400, Waiman Long wrote: > This patch replaces the cmpxchg() and xchg() calls in the native > qspinlock code with the more relaxed _acquire or _release versions of > those calls to enable other architectures to adopt queued spinlocks > with less memor

Re: [PATCH tip/locking/core v8 1/5] locking/qspinlock: Use _acquire/_release versions of cmpxchg & xchg

2015-10-19 Thread Boqun Feng
On Mon, Oct 19, 2015 at 08:46:02PM -0700, Davidlohr Bueso wrote: > On Tue, 20 Oct 2015, Boqun Feng wrote: > > >>@@ -93,7 +94,7 @@ static __always_inline void queued_spin_unlock(struct > >>qspinlock *lock) > >>/* > >> * smp_mb__before_atomic

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-20 Thread Boqun Feng
On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > Am I missing something here? If not, it seems to me that you need > the leading lwsync to instead be a sync. > > Of course, if I am not missing something, then this applies also to the > value-returning RMW atomic operations t

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-20 Thread Boqun Feng
On Mon, Oct 19, 2015 at 12:23:24PM +0200, Peter Zijlstra wrote: > On Mon, Oct 19, 2015 at 09:17:18AM +0800, Boqun Feng wrote: > > This is confusing me right now. ;-) > > > > Let's use a simple example for only one primitive, as I understand it, > > if we say a pr

Re: [PATCH v2] barriers: introduce smp_mb__release_acquire and update documentation

2015-10-20 Thread Boqun Feng
On Mon, Oct 12, 2015 at 04:30:48PM -0700, Paul E. McKenney wrote: > On Fri, Oct 09, 2015 at 07:33:28PM +0100, Will Deacon wrote: > > On Fri, Oct 09, 2015 at 10:43:27AM -0700, Paul E. McKenney wrote: > > > On Fri, Oct 09, 2015 at 10:51:29AM +0100, Will Deacon wrote: [snip] > > > > > We could also i

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-24 Thread Boqun Feng
On Sat, Oct 24, 2015 at 12:26:27PM +0200, Peter Zijlstra wrote: > On Thu, Oct 22, 2015 at 08:07:16PM +0800, Boqun Feng wrote: > > On Wed, Oct 21, 2015 at 09:48:25PM +0200, Peter Zijlstra wrote: > > > On Wed, Oct 21, 2015 at 12:35:23PM -0700, Paul E. McKenney wrote: > >

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-25 Thread Boqun Feng
On Sat, Oct 24, 2015 at 07:53:56PM +0800, Boqun Feng wrote: > On Sat, Oct 24, 2015 at 12:26:27PM +0200, Peter Zijlstra wrote: > > > > Right, futexes are a pain; and I think we all agreed we didn't want to > > go rely on implementation details unless we absolutely _

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-25 Thread Boqun Feng
On Wed, Oct 21, 2015 at 12:36:38PM -0700, Paul E. McKenney wrote: > On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > > I am not seeing a sync there, but I really have to defer to the > > > maintainers on this o

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-26 Thread Boqun Feng
On Mon, Oct 26, 2015 at 11:20:01AM +0900, Michael Ellerman wrote: > > Sorry guys, these threads are so long I tend not to read them very actively :} > > Looking at the system call path, the straight line path does not include any > barriers. I can't see any hidden in macros either. > > We also h

Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier

2015-10-26 Thread Boqun Feng
On Mon, Oct 26, 2015 at 02:20:21PM +1100, Paul Mackerras wrote: > On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > > I am not seeing a sync there, but I really have to defer to the > > > maintainers on this one

[PATCH tip/locking/core v5 1/6] powerpc: atomic: Make _return atomics and *{cmp}xchg fully ordered

2015-10-26 Thread Boqun Feng
RIER and PPC_ATOMIC_EXIT_BARRIER in __{cmp,}xchg_{u32,u64} respectively to guarantee fully ordered semantics of atomic{,64}_{cmp,}xchg() and {cmp,}xchg(), as a complement of commit b97021f85517 ("powerpc: Fix atomic_xxx_return barrier semantics"). Cc: # 3.4+ Signed-off-by: Boqun Feng ---

[PATCH tip/locking/core v5 6/6] powerpc: atomic: Implement cmpxchg{,64}_* and atomic{,64}_cmpxchg_* variants

2015-10-26 Thread Boqun Feng
piler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm/atomic.h | 10 +++ arch/powerpc/include/asm/cmpxchg.h | 149 - 2 files changed, 158 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/includ

[PATCH tip/locking/core v5 2/6] atomics: Add test for atomic operations with _relaxed variants

2015-10-26 Thread Boqun Feng
that we can examine their assembly code. Signed-off-by: Boqun Feng --- lib/atomic64_test.c | 120 ++-- 1 file changed, 79 insertions(+), 41 deletions(-) diff --git a/lib/atomic64_test.c b/lib/atomic64_test.c index 83c33a5b..18e422b 100644 --- a/lib

[PATCH tip/locking/core v5 0/6] atomics: powerpc: Implement relaxed/acquire/release variants of some atomics

2015-10-26 Thread Boqun Feng
Hi all, This is v5 of the series. Link for v1: https://lkml.org/lkml/2015/8/27/798 Link for v2: https://lkml.org/lkml/2015/9/16/527 Link for v3: https://lkml.org/lkml/2015/10/12/368 Link for v4: https://lkml.org/lkml/2015/10/14/670 Changes since v4: * define PPC_ATOMIC_ENTRY_BARRIER as "s

[PATCH tip/locking/core v5 4/6] powerpc: atomic: Implement atomic{,64}_*_return_* variants

2015-10-26 Thread Boqun Feng
on the platform without "lwsync", we can use "isync" rather than "sync" as an acquire barrier. Therefore in __atomic_op_acquire() we use PPC_ACQUIRE_BARRIER, which is barrier() on UP, "lwsync" if available and "isync" otherwise. Implement atomic{

[PATCH tip/locking/core v5 5/6] powerpc: atomic: Implement xchg_* and atomic{,64}_xchg_* variants

2015-10-26 Thread Boqun Feng
Implement xchg_relaxed and atomic{,64}_xchg_relaxed, based on these _relaxed variants, release/acquire variants and fully ordered versions can be built. Note that xchg_relaxed and atomic_{,64}_xchg_relaxed are not compiler barriers. Signed-off-by: Boqun Feng --- arch/powerpc/include/asm

[PATCH tip/locking/core v5 3/6] atomics: Allow architectures to define their own __atomic_op_* helpers

2015-10-26 Thread Boqun Feng
-by: Boqun Feng --- include/linux/atomic.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 27e580d..947c1dc 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -43,20 +43,29 @@ static inline int atomic_read_ctrl

  1   2   3   4   5   6   7   8   9   10   >