Re: [PATCH 2/3] tools/memory-model: Refactor some RCU relations

2018-11-15 Thread Boqun Feng
Hi Alan, On Thu, Nov 15, 2018 at 11:19:58AM -0500, Alan Stern wrote: > In preparation for adding support for SRCU, refactor the definitions > of rcu-fence, rcu-rscsi, rcu-link, and rb by moving the po and po? > terms from the first two to the second two. An rcu-gp relation is > added; it is

Re: [PATCH] rcu: Use cpus_read_lock() while looking at cpu_online_mask

2018-10-15 Thread Boqun Feng
On Mon, Oct 15, 2018 at 05:09:03PM +0200, Sebastian Andrzej Siewior wrote: > On 2018-10-15 23:07:15 [+0800], Boqun Feng wrote: > > Hi, Sebastian > Hi Boqun, > > > On Mon, Oct 15, 2018 at 04:42:17PM +0200, Sebastian Andrzej Siewior wrote: > > > On 2018-10-13 06:4

Re: [PATCH] rcu: Use cpus_read_lock() while looking at cpu_online_mask

2018-10-15 Thread Boqun Feng
Hi, Sebastian On Mon, Oct 15, 2018 at 04:42:17PM +0200, Sebastian Andrzej Siewior wrote: > On 2018-10-13 06:48:13 [-0700], Paul E. McKenney wrote: > > > > My concern would be that it would queue it by default for the current > > CPU, which would serialize the processing, losing the concurrency

Re: [PATCH tip/core/rcu 2/2] rcu: Make expedited GPs handle CPU 0 being offline

2018-06-26 Thread Boqun Feng
On Tue, Jun 26, 2018 at 12:27:47PM -0700, Paul E. McKenney wrote: > On Tue, Jun 26, 2018 at 07:46:52PM +0800, Boqun Feng wrote: > > On Tue, Jun 26, 2018 at 06:44:47PM +0800, Boqun Feng wrote: > > > On Tue, Jun 26, 2018 at 11:38:20AM +0200, Peter Zijlstra wrote: > > > &

Re: [PATCH tip/core/rcu 2/2] rcu: Make expedited GPs handle CPU 0 being offline

2018-06-26 Thread Boqun Feng
On Tue, Jun 26, 2018 at 06:44:47PM +0800, Boqun Feng wrote: > On Tue, Jun 26, 2018 at 11:38:20AM +0200, Peter Zijlstra wrote: > > On Mon, Jun 25, 2018 at 03:43:32PM -0700, Paul E. McKenney wrote: > > > + preempt_disable(); > > > + for_each_leaf

Re: [PATCH tip/core/rcu 2/2] rcu: Make expedited GPs handle CPU 0 being offline

2018-06-26 Thread Boqun Feng
On Tue, Jun 26, 2018 at 11:38:20AM +0200, Peter Zijlstra wrote: > On Mon, Jun 25, 2018 at 03:43:32PM -0700, Paul E. McKenney wrote: > > + preempt_disable(); > > + for_each_leaf_node_possible_cpu(rnp, cpu) { > > + if (cpu_is_offline(cpu)) /* Preemption

Re: write_lock_irq(_lock)

2018-05-24 Thread Boqun Feng
treat read_lock() as pure recursive read locks in lib/locking-seftest.c, and this is useful, especially for the lockdep development selftest, so we keep this via a variable to force switching lock annotation for read_lock(). Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/lo

Re: [PATCH 07/14] powerpc: Add support for restartable sequences

2018-05-20 Thread Boqun Feng
On Fri, May 18, 2018 at 02:17:17PM -0400, Mathieu Desnoyers wrote: > - On May 17, 2018, at 7:50 PM, Boqun Feng boqun.f...@gmail.com wrote: > [...] > >> > I think you're right. So we have to introduce callsite to rseq_syscall() > >> > in syscall path, something l

Re: [PATCH 07/14] powerpc: Add support for restartable sequences

2018-05-17 Thread Boqun Feng
On Thu, May 17, 2018, at 11:28 PM, Mathieu Desnoyers wrote: > - On May 16, 2018, at 9:19 PM, Boqun Feng boqun.f...@gmail.com wrote: > > > On Wed, May 16, 2018 at 04:13:16PM -0400, Mathieu Desnoyers wrote: > >> - On May 16, 2018, at 12:18 PM, Peter Zijlstra

Re: [PATCH 07/14] powerpc: Add support for restartable sequences

2018-05-16 Thread Boqun Feng
On Wed, May 16, 2018 at 04:13:16PM -0400, Mathieu Desnoyers wrote: > - On May 16, 2018, at 12:18 PM, Peter Zijlstra pet...@infradead.org wrote: > > > On Mon, Apr 30, 2018 at 06:44:26PM -0400, Mathieu Desnoyers wrote: > >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > >> index

[PATCH v2] locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs

2018-05-07 Thread Boqun Feng
. No change in functionality or code generation. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Mark Rutland <mark.rutl...@arm.com> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Thomas Gleixner <t...@linutronix.de&g

Re: [PATCH] locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs

2018-05-06 Thread Boqun Feng
On Sun, May 6, 2018, at 8:11 PM, Ingo Molnar wrote: > > * Boqun Feng <boqun.f...@gmail.com> wrote: > > > > The only change I made beyond a trivial build fix is that I also added > > > the release > > > atomics variants explicitly: > >

[tip:locking/core] locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs

2018-05-06 Thread tip-bot for Boqun Feng
Commit-ID: 0476a632cb3aa88c03cefc294050a9a86760e88d Gitweb: https://git.kernel.org/tip/0476a632cb3aa88c03cefc294050a9a86760e88d Author: Boqun Feng <boqun.f...@gmail.com> AuthorDate: Sat, 5 May 2018 19:28:17 +0800 Committer: Ingo Molnar <mi...@kernel.org> CommitDate: Sat, 5 Ma

Re: [PATCH] locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs

2018-05-05 Thread Boqun Feng
On Sat, May 05, 2018 at 03:27:51PM +0200, Ingo Molnar wrote: > > * Boqun Feng <boqun.f...@gmail.com> wrote: > > > > May I suggest the patch below? No change in functionality, but it > > > documents the > > > lack of the cmpxchg_release() APIs and maps

Re: [RFC PATCH] locking/atomics/powerpc: Clarify why the cmpxchg_relaxed() family of APIs falls back to full cmpxchg()

2018-05-05 Thread Boqun Feng
On Sat, May 05, 2018 at 12:35:50PM +0200, Ingo Molnar wrote: > > * Boqun Feng <boqun.f...@gmail.com> wrote: > > > On Sat, May 05, 2018 at 11:38:29AM +0200, Ingo Molnar wrote: > > > > > > * Ingo Molnar <mi...@kernel.org> wrote: > > >

Re: [RFC PATCH] locking/atomics/powerpc: Introduce optimized cmpxchg_release() family of APIs for PowerPC

2018-05-05 Thread Boqun Feng
Hi Ingo, On Sat, May 05, 2018 at 12:00:55PM +0200, Ingo Molnar wrote: > > * Ingo Molnar wrote: > > > > So there's no loss in arch flexibility. > > > > BTW., PowerPC for example is already in such a situation, it does not > > define > > atomic_cmpxchg_release(), only the

Re: [PATCH] locking/atomics: Clean up the atomic.h maze of #defines

2018-05-05 Thread Boqun Feng
On Sat, May 05, 2018 at 11:38:29AM +0200, Ingo Molnar wrote: > > * Ingo Molnar wrote: > > > * Peter Zijlstra wrote: > > > > > > So we could do the following simplification on top of that: > > > > > > > > #ifndef atomic_fetch_dec_relaxed > > > > #

Re: [RFC tip/locking/lockdep v6 01/20] lockdep/Documention: Recursive read lock detection reasoning

2018-04-27 Thread Boqun Feng
(Copy more people) On Wed, Apr 11, 2018 at 09:50:51PM +0800, Boqun Feng wrote: > This patch add the documentation piece for the reasoning of deadlock > detection related to recursive read lock. The following sections are > added: > > * Explain what is a recursive read lock, an

Re: [PATCH] fasync: Fix deadlock between task-context and interrupt-context kill_fasync()

2018-04-27 Thread Boqun Feng
On Tue, Apr 17, 2018 at 07:01:10AM -0700, Matthew Wilcox wrote: > On Thu, Apr 05, 2018 at 02:58:06PM +0300, Kirill Tkhai wrote: > > I observed the following deadlock between them: > > > > [task 1] [task 2] [task 3] > > kill_fasync()

Re: [RFC tip/locking/lockdep v6 01/20] lockdep/Documention: Recursive read lock detection reasoning

2018-04-16 Thread Boqun Feng
On Sat, Apr 14, 2018 at 05:38:54PM -0700, Randy Dunlap wrote: > Hi, > Hello Randy, > Just a few typos etc. below... > Thanks! I fixed those typos according to your comments. > On 04/11/2018 06:50 AM, Boqun Feng wrote: > > Signed-off-by: Boqun Feng

Re: [RFC tip/locking/lockdep v6 19/20] rcu: Equip sleepable RCU with lockdep dependency graph checks

2018-04-13 Thread Boqun Feng
On Thu, Apr 12, 2018 at 11:12:17AM +0200, Peter Zijlstra wrote: > On Thu, Apr 12, 2018 at 10:12:33AM +0800, Boqun Feng wrote: > > A trivial fix/hack would be adding local_irq_disable() and > > local_irq_enable() around srcu_lock_sync() like: > > > > static inline

Re: [PATCH] memory-model: fix cheat sheet typo

2018-04-12 Thread Boqun Feng
On Wed, Apr 11, 2018 at 07:06:36PM +0200, Paolo Bonzini wrote: > On 11/04/2018 18:31, Peter Zijlstra wrote: > >>>Prior Operation Subsequent Operation > >>>--- - > >>>

Re: [RFC tip/locking/lockdep v6 19/20] rcu: Equip sleepable RCU with lockdep dependency graph checks

2018-04-11 Thread Boqun Feng
On Wed, Apr 11, 2018 at 11:57:30AM -0700, Paul E. McKenney wrote: > On Wed, Apr 11, 2018 at 09:56:44PM +0800, Boqun Feng wrote: > > Although all flavors of RCU are annotated correctly with lockdep > > annotations as recursive read locks, the 'check' parameter for their > >

[RFC tip/locking/lockdep v6 20/20] lockdep/selftest: Add a test case for SRCU

2018-04-11 Thread Boqun Feng
Since we now could detect deadlock cases for sleepable RCU, a self test case is added. More other complex scenarios may be added later to srcu_tests(). Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- lib/locking-sel

[RFC tip/locking/lockdep v6 19/20] rcu: Equip sleepable RCU with lockdep dependency graph checks

2018-04-11 Thread Boqun Feng
to sleepable RCU with lockdep. Cc: Paul E. McKenney <paul...@linux.vnet.ibm.com> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/srcu.h | 51 +-- kernel/rcu/srcutiny.c | 2 ++ kernel/rcu/srcutree.c | 2 ++ 3 files changed, 5

[RFC tip/locking/lockdep v6 02/20] lockdep: Demagic the return value of BFS

2018-04-11 Thread Boqun Feng
for the return value of __bfs() and its friends, this improves the code readability of the code, and further, could help if we want to extend the BFS. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 136 --- 1 file chang

[RFC tip/locking/lockdep v6 05/20] lockdep: Reduce the size of lock_list::distance

2018-04-11 Thread Boqun Feng
structure. Suggested-by: Peter Zijlstra <pet...@infradead.org> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/lockdep.h | 2 +- kernel/locking/lockdep.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/lockdep.h b/include/lin

[RFC tip/locking/lockdep v6 06/20] lockdep: Introduce lock_list::dep

2018-04-11 Thread Boqun Feng
presented as "prev -(RR)-> next". So we use 4 bits for the presence of each type in lock_list::dep. Helper functions and marcos are also introduced to convert a pair of locks into lock_list::dep bit and maintain the addition of different types of dependencies. Signed-off-by: Boqu

[RFC tip/locking/lockdep v6 04/20] lockdep: Redefine LOCK_*_STATE* bits

2018-04-11 Thread Boqun Feng
ecursive) new: LOCK_* : stands for non-recursive(write lock and non-recursive read lock) LOCK_*_RR: stands for recursive read lock Such a change is needed for a future improvement on recursive read related irq inversion deadlock detection. Signed-off-by: Boqun Feng <boqu

[RFC tip/locking/lockdep v6 07/20] lockdep: Extend __bfs() to work with multiple types of dependencies

2018-04-11 Thread Boqun Feng
functions, which also cleans up a little bit for the __bfs() root initialization code. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/lockdep.h | 2 + kernel/locking/lockdep.c | 103 +++ 2 files changed, 88 insertions(+), 17

[RFC tip/locking/lockdep v6 09/20] lockdep: Support deadlock detection for recursive read locks in check_noncircular()

2018-04-11 Thread Boqun Feng
a new match function hlock_conflict() to replace the class_equal() for the deadlock check in check_noncircular(). Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 35 +++ 1 file changed, 31 insertions(+), 4 deletions(-) diff --git

[RFC tip/locking/lockdep v6 12/20] lockdep: Add recursive read locks into dependency graph

2018-04-11 Thread Boqun Feng
Since we have all the fundamental to handle recursive read locks, we now add them into the dependency graph. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 16 +--- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/kernel/locking/loc

[RFC tip/locking/lockdep v6 13/20] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior

2018-04-11 Thread Boqun Feng
on detecting recursive read lock related deadlocks. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- lib/locking-selftest.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index b5c129

[RFC tip/locking/lockdep v6 16/20] lockdep/selftest: Add more recursive read related test cases

2018-04-11 Thread Boqun Feng
not deadlock. Those self testcases are valuable for the development of supporting recursive read related deadlock detection. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- lib/locking-selftest.c | 161 + 1 file changed, 161 insertions(+)

[RFC tip/locking/lockdep v6 14/20] lockdep: Take read/write status in consideration when generate chainkey

2018-04-11 Thread Boqun Feng
nkeys, the chain_hlocks array now store the "hlock_id"s rather than lock_class indexes. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 56 +++- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/ke

[RFC tip/locking/lockdep v6 18/20] MAINTAINERS: Add myself as a LOCKING PRIMITIVES reviewer

2018-04-11 Thread Boqun Feng
any help for lock related code. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6e950b8b4a41..255e5f25df54 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8243,6 +8243,7 @@ F:Documen

[RFC tip/locking/lockdep v6 10/20] lockdep: Adjust check_redundant() for recursive read change

2018-04-11 Thread Boqun Feng
o-add dependency, we replace the match function for __bfs() check_redundant(), we check for the case that either @next is R (anything is not weaker than it) or the end point of the path is N (which is not weaker than anything). Signed-off-by: Boqun Feng <boqun.f...@gmail.com>

[RFC tip/locking/lockdep v6 17/20] Revert "locking/lockdep/selftests: Fix mixed read-write ABBA tests"

2018-04-11 Thread Boqun Feng
This reverts commit d82fed75294229abc9d757f08a4817febae6c4f4. Since we now could handle mixed read-write deadlock detection well, the self tests could be detected as expected, no need to use this work-around. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- lib/locking-selftest

[RFC tip/locking/lockdep v6 15/20] lockdep/selftest: Unleash irq_read_recursion2 and add more

2018-04-11 Thread Boqun Feng
Now since we can handle recursive read related irq inversion deadlocks correctly, uncomment the irq_read_recursion2 and add more testcases. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- lib/locking-selftest.c | 59 -- 1 file chang

[RFC tip/locking/lockdep v6 11/20] lockdep: Fix recursive read lock related safe->unsafe detection

2018-04-11 Thread Boqun Feng
n one search, and __bfs() only report whether a match is found or not, we are then lack of the information for print_bad_irq_dependency(), so we introduce a new function match_bit(), which returns the matched usage bit in __bfs(), and it must be called after we find a match. Signed-off-by: Boqun F

[RFC tip/locking/lockdep v6 08/20] lockdep: Make __bfs(.match) return bool

2018-04-11 Thread Boqun Feng
Suggested-by: Peter Zijlstra <pet...@infradead.org> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 53ce81e8a6a

[RFC tip/locking/lockdep v6 01/20] lockdep/Documention: Recursive read lock detection reasoning

2018-04-11 Thread Boqun Feng
types of dependencies, and the definition of strong paths. * Proof for a closed strong path is both sufficient and necessary for deadlock detections with recursive read locks involved. The proof could also explain why we call the path "strong" Signed-off-by:

[RFC tip/locking/lockdep v6 03/20] lockdep: Make __bfs() visit every dependency until a match

2018-04-11 Thread Boqun Feng
: we now mark lock_class::lockdep_dependency_gen_id to indicate _all the dependencies_ in its lock_{after,before} have been visited in the __bfs() (note we only take one direction in a __bfs() search). In this way, every dependency is guaranteed to be visited until we find a match. Signed-off-by: Boqun Fe

[RFC tip/locking/lockdep v6 00/20] lockdep: Support deadlock detection for recursive read locks

2018-04-11 Thread Boqun Feng
Hi Ingo and Peter, This is V6 for recursive read lock support in lockdep. I moved the explanation about reasoning to patch #1, which will help understand this whole series. This patchset is based on v4.16. Other changes since V5: * Rewrite the the explanation of the reasoning, focus on

Re: [PATCH 10/10] locking/qspinlock: Elide back-to-back RELEASE operations with smp_wmb()

2018-04-06 Thread Boqun Feng
On Thu, Apr 05, 2018 at 05:59:07PM +0100, Will Deacon wrote: > The qspinlock slowpath must ensure that the MCS node is fully initialised > before it can be reached by another other CPU. This is currently enforced > by using a RELEASE operation when updating the tail and also when linking > the

Re: [PATCH 08/10] locking/qspinlock: Merge struct __qspinlock into struct qspinlock

2018-04-06 Thread Boqun Feng
dea...@arm.com> As I said in the IRC, it's glad to see such a merge ;-) Acked-by: Boqun Feng <boqun.f...@gmail.com> Regards, Boqun > --- > arch/x86/include/asm/qspinlock.h | 2 +- > arch/x86/include/asm/qspinlock_paravirt.h | 3 +- > include/asm-generic/qspinlock

Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable sequences system call (v12)

2018-03-28 Thread Boqun Feng
On Tue, Mar 27, 2018 at 12:05:23PM -0400, Mathieu Desnoyers wrote: [...] > Changes since v11: > > - Replace task struct rseq_preempt, rseq_signal, and rseq_migrate > bool by u32 rseq_event_mask. [...] > @@ -979,6 +980,17 @@ struct task_struct { > unsigned long

Re: [RFC tip/locking/lockdep v5 07/17] lockdep: Adjust check_redundant() for recursive read change

2018-03-16 Thread Boqun Feng
On Thu, Feb 22, 2018 at 06:29:06PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:08:54PM +0800, Boqun Feng wrote: > > As we have four kinds of dependencies now, check_redundant() should only > > report redundant if we have a dependency path which is equal or >

Re: smp_mb__after_spinlock requirement too strong?

2018-03-12 Thread Boqun Feng
On Mon, Mar 12, 2018 at 04:18:00PM +0800, 焦晓冬 wrote: > >> Peter pointed out in this patch https://patchwork.kernel.org/patch/9771921/ > >> that the spinning-lock used at __schedule() should be RCsc to ensure > >> visibility of writes prior to __schedule when the task is to be migrated to > >>

Re: [PATCH v2 2/2] riscv/atomic: Strengthen implementations with fences

2018-03-12 Thread Boqun Feng
On Fri, Mar 09, 2018 at 04:21:37PM -0800, Daniel Lustig wrote: > On 3/9/2018 2:57 PM, Palmer Dabbelt wrote: > > On Fri, 09 Mar 2018 13:30:08 PST (-0800), parri.and...@gmail.com wrote: > >> On Fri, Mar 09, 2018 at 10:54:27AM -0800, Palmer Dabbelt wrote: > >>> On Fri, 09 Mar 2018 10:36:44 PST

Re: smp_mb__after_spinlock requirement too strong?

2018-03-11 Thread Boqun Feng
On Sun, Mar 11, 2018 at 03:55:41PM +0800, 焦晓冬 wrote: > Peter pointed out in this patch https://patchwork.kernel.org/patch/9771921/ > that the spinning-lock used at __schedule() should be RCsc to ensure > visibility of writes prior to __schedule when the task is to be migrated to > another CPU. >

Re: [PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions

2018-03-11 Thread Boqun Feng
On Fri, Mar 09, 2018 at 12:17:07PM -0800, Paul E. McKenney wrote: > On Fri, Mar 09, 2018 at 02:57:00PM +0800, Boqun Feng wrote: > > On Thu, Mar 08, 2018 at 07:42:55AM -0800, Paul E. McKenney wrote: > > > On Thu, Mar 08, 2018 at 04:30:06PM +0800, Boqun Feng wrote: > > > &

[tip:locking/urgent] rtmutex: Make rt_mutex_futex_unlock() safe for irq-off callsites

2018-03-09 Thread tip-bot for Boqun Feng
Commit-ID: 6b0ef92fee2a3189eba6d6b827b247cb4f6da7e9 Gitweb: https://git.kernel.org/tip/6b0ef92fee2a3189eba6d6b827b247cb4f6da7e9 Author: Boqun Feng <boqun.f...@gmail.com> AuthorDate: Fri, 9 Mar 2018 14:56:28 +0800 Committer: Thomas Gleixner <t...@linutronix.de> CommitDate: Fri

Re: [PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions

2018-03-08 Thread Boqun Feng
On Thu, Mar 08, 2018 at 07:42:55AM -0800, Paul E. McKenney wrote: > On Thu, Mar 08, 2018 at 04:30:06PM +0800, Boqun Feng wrote: > > On Thu, Mar 08, 2018 at 12:54:29PM +0800, Boqun Feng wrote: > > > On Wed, Mar 07, 2018 at 08:30:17PM -0800, Paul

[RFC] rtmutex: Make rt_mutex_futex_unlock() safe at irq-off callsites

2018-03-08 Thread Boqun Feng
eu Desnoyers <mathieu.desnoy...@efficios.com> Cc: Lai Jiangshan <jiangshan...@gmail.com> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> Fixes: 0

[PATCH] rcu: Use the proper lockdep annotation in dump_blkd_tasks()

2018-03-08 Thread Boqun Feng
vanilla lockdep annotations on rcu_node::lock, and that requires accessing ->lock of rcu_node directly. However we need to keep rcu_node::lock __private to avoid breaking its extra ordering guarantee. And we have a dedicated lockdep annotation for rcu_node::lock, so use it. Signed-off-by: Boqun F

[PATCH v3] rcu: exp: Protect all sync_rcu_preempt_exp_done() with rcu_node lock

2018-03-08 Thread Boqun Feng
mis-use in the future. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- v2 --> v3: Replace lockdep_assert_held() with raw_lockdep_assert_held_rcu_node(), to make sparse happy v1 --> v2: Kill unnecessary blank lines kernel/rcu/tree_exp.h | 28 +++

Re: [rcu:rcu/dev 39/39] kernel/rcu/tree_exp.h:163:9: sparse: incorrect type in argument 1 (different modifiers)

2018-03-08 Thread Boqun Feng
On Thu, Mar 08, 2018 at 04:34:43PM -0800, Paul E. McKenney wrote: > On Fri, Mar 09, 2018 at 06:52:34AM +0800, Boqun Feng wrote: > > On Fri, Mar 09, 2018 at 05:41:27AM +0800, kbuild test robot wrote: > > > tree: > > > https://git.kernel.org/pub/scm/linux/kerne

Re: [rcu:rcu/dev 39/39] kernel/rcu/tree_exp.h:163:9: sparse: incorrect type in argument 1 (different modifiers)

2018-03-08 Thread Boqun Feng
On Fri, Mar 09, 2018 at 05:41:27AM +0800, kbuild test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git > rcu/dev > head: b8909ec707bb5beba94e7c7d62cc6b3115ceae50 > commit: b8909ec707bb5beba94e7c7d62cc6b3115ceae50 [39/39] rcu: Protect all >

[PATCH v2] rcu: exp: Protect all sync_rcu_preempt_exp_done() with rcu_node lock

2018-03-08 Thread Boqun Feng
mis-use in the future. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- v1 --> v2: Kill unnecessary blank lines kernel/rcu/tree_exp.h | 28 +--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h in

[PATCH] rcu: exp: Protect all sync_rcu_preempt_exp_done() with rcu_node lock

2018-03-08 Thread Boqun Feng
mis-use in the future. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/rcu/tree_exp.h | 30 +++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 2fd882b08b7c..150839a2c00a 100644 --- a/kernel/

Re: [PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions

2018-03-08 Thread Boqun Feng
On Thu, Mar 08, 2018 at 12:54:29PM +0800, Boqun Feng wrote: > On Wed, Mar 07, 2018 at 08:30:17PM -0800, Paul E. McKenney wrote: > [...] > > > > > > +/* > > > + * Like sync_rcu_preempt_exp_done(), but this function assumes the caller > > > + * doesn't ho

Re: [PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions

2018-03-07 Thread Boqun Feng
On Wed, Mar 07, 2018 at 08:30:17PM -0800, Paul E. McKenney wrote: [...] > > > > +/* > > + * Like sync_rcu_preempt_exp_done(), but this function assumes the caller > > + * doesn't hold the rcu_node's ->lock, and will acquire and release the > > lock > > + * itself > > + */ > > +static bool

Re: [PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions

2018-03-07 Thread Boqun Feng
On Wed, Mar 07, 2018 at 07:48:29AM -0800, Paul E. McKenney wrote: > On Wed, Mar 07, 2018 at 04:49:39PM +0800, Boqun Feng wrote: > > Since commit d9a3da0699b2 ("rcu: Add expedited grace-period support for > > preemptible RCU"), there are comments for some funtions in > &

[PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions

2018-03-07 Thread Boqun Feng
the comments Signed-off-by: Boqun Feng <boqun.f...@gmail.com> Fixes: d9a3da0699b2 ("rcu: Add expedited grace-period support for preemptible RCU") --- kernel/rcu/tree_exp.h | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/tree_exp.h

Re: [RFC] rcu: Prevent expedite reporting within RCU read-side section

2018-03-06 Thread Boqun Feng
On Tue, Mar 06, 2018 at 02:31:58PM +0900, Byungchul Park wrote: > Hello Paul and RCU folks, > > I am afraid I correctly understand and fix it. But I really wonder why > sync_rcu_exp_handler() reports the quiescent state even in the case that > current task is within a RCU read-side section. Do I

Re: [PATCH 2/2 v2 RFC] tools/memory-model: redefine rb in terms of rcu-fence

2018-03-01 Thread Boqun Feng
On Thu, Mar 01, 2018 at 10:37:58AM -0800, Paul E. McKenney wrote: > On Thu, Mar 01, 2018 at 09:49:06AM -0800, Paul E. McKenney wrote: > > On Thu, Mar 01, 2018 at 10:49:05AM -0500, Alan Stern wrote: > > > On Thu, 1 Mar 2018, Boqun Feng wrote: > > > > &

Re: [PATCH 2/2 v2 RFC] tools/memory-model: redefine rb in terms of rcu-fence

2018-03-01 Thread Boqun Feng
On Wed, Feb 28, 2018 at 08:49:37PM -0800, Paul E. McKenney wrote: > On Thu, Mar 01, 2018 at 09:55:31AM +0800, Boqun Feng wrote: > > On Wed, Feb 28, 2018 at 03:13:54PM -0500, Alan Stern wrote: > > > This patch reorganizes the definition of rb in the Linux Kernel Memory >

Re: [PATCH 2/2 v2 RFC] tools/memory-model: redefine rb in terms of rcu-fence

2018-02-28 Thread Boqun Feng
On Wed, Feb 28, 2018 at 03:13:54PM -0500, Alan Stern wrote: > This patch reorganizes the definition of rb in the Linux Kernel Memory > Consistency Model. The relation is now expressed in terms of > rcu-fence, which consists of a sequence of gp and rscs links separated > by rcu-link links, in

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-27 Thread Boqun Feng
On Tue, Feb 27, 2018 at 01:06:35PM +0800, Boqun Feng wrote: > On Mon, Feb 26, 2018 at 04:24:27PM +, Will Deacon wrote: > > On Mon, Feb 26, 2018 at 08:06:59AM -0800, Linus Torvalds wrote: > > > On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget <luc.maran...@i

Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock()

2018-02-26 Thread Boqun Feng
On Mon, Feb 26, 2018 at 04:24:27PM +, Will Deacon wrote: > On Mon, Feb 26, 2018 at 08:06:59AM -0800, Linus Torvalds wrote: > > On Mon, Feb 26, 2018 at 6:21 AM, Luc Maranget wrote: > > > > > > That is, locks are not implemented from more basic primitive but are > > >

Re: [RFC tip/locking/lockdep v5 16/17] lockdep: Documention for recursive read lock detection reasoning

2018-02-26 Thread Boqun Feng
On Sat, Feb 24, 2018 at 11:53:20PM +0100, Andrea Parri wrote: > On Thu, Feb 22, 2018 at 03:09:03PM +0800, Boqun Feng wrote: > > As now we support recursive read lock deadlock detection, add related > > explanation in the Documentation/lockdep/lockdep-desgin.txt: > >

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-26 Thread Boqun Feng
On Mon, Feb 26, 2018 at 06:15:24PM +0800, Boqun Feng wrote: > On Mon, Feb 26, 2018 at 10:00:50AM +0100, Peter Zijlstra wrote: > > On Sat, Feb 24, 2018 at 05:26:52PM +0800, Boqun Feng wrote: > > > > This is for case like: > > > > > > > >

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-26 Thread Boqun Feng
On Mon, Feb 26, 2018 at 10:00:50AM +0100, Peter Zijlstra wrote: > On Sat, Feb 24, 2018 at 05:26:52PM +0800, Boqun Feng wrote: > > > This is for case like: > > > > > > TASK1: > > > read_lock(A); > > > read_lock(B); >

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-24 Thread Boqun Feng
On Sat, Feb 24, 2018 at 05:00:19PM +0800, Boqun Feng wrote: > On Sat, Feb 24, 2018 at 09:38:07AM +0100, Peter Zijlstra wrote: > > On Sat, Feb 24, 2018 at 02:30:05PM +0800, Boqun Feng wrote: > > > On Sat, Feb 24, 2018 at 01:32:50PM +0800

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-24 Thread Boqun Feng
On Sat, Feb 24, 2018 at 09:38:07AM +0100, Peter Zijlstra wrote: > On Sat, Feb 24, 2018 at 02:30:05PM +0800, Boqun Feng wrote: > > On Sat, Feb 24, 2018 at 01:32:50PM +0800, Boqun Feng wrote: > > > > /* > > >* DEP_*_BIT in lock_list::dep > > >* &

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-23 Thread Boqun Feng
On Sat, Feb 24, 2018 at 01:32:50PM +0800, Boqun Feng wrote: [...] > > I also reorder bit number for each kind of dependency, so that we have a > simple __calc_dep_bit(), see the following: > > /* >* DEP_*_BIT in lock_list::dep >* >* For d

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-23 Thread Boqun Feng
On Sat, Feb 24, 2018 at 01:32:50PM +0800, Boqun Feng wrote: > On Fri, Feb 23, 2018 at 08:37:32PM +0800, Boqun Feng wrote: > > On Fri, Feb 23, 2018 at 12:55:20PM +0100, Peter Zijlstra wrote: > > > On Thu, Feb 22, 2018 at 03:08:51PM +0800, Boqun Feng wrote: > > > >

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-23 Thread Boqun Feng
On Fri, Feb 23, 2018 at 08:37:32PM +0800, Boqun Feng wrote: > On Fri, Feb 23, 2018 at 12:55:20PM +0100, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 03:08:51PM +0800, Boqun Feng wrote: > > > @@ -1012,6 +1013,33 @@ static inline bool bfs_error(enum bfs_result res) >

Re: [RFC tip/locking/lockdep v5 15/17] lockdep: Reduce the size of lock_list

2018-02-23 Thread Boqun Feng
On Fri, Feb 23, 2018 at 12:38:43PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:09:02PM +0800, Boqun Feng wrote: > > diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h > > index a1f91f8680bd..3fce8dbf5091 100644 > > --- a/include/linux/lockdep.h &g

Re: [RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-23 Thread Boqun Feng
On Fri, Feb 23, 2018 at 12:55:20PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:08:51PM +0800, Boqun Feng wrote: > > @@ -1012,6 +1013,33 @@ static inline bool bfs_error(enum bfs_result res) > > return res < 0; > > } > > > > +#define DE

Re: [RFC tip/locking/lockdep v5 08/17] lockdep: Fix recursive read lock related safe->unsafe detection

2018-02-23 Thread Boqun Feng
On Fri, Feb 23, 2018 at 04:21:34PM +0800, Boqun Feng wrote: > On Thu, Feb 22, 2018 at 06:46:54PM +0100, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 03:08:55PM +0800, Boqun Feng wrote: > > > There are four cases for recursive read lock realted deadlocks: > > >

Re: [RFC tip/locking/lockdep v5 08/17] lockdep: Fix recursive read lock related safe->unsafe detection

2018-02-23 Thread Boqun Feng
On Thu, Feb 22, 2018 at 06:46:54PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:08:55PM +0800, Boqun Feng wrote: > > There are four cases for recursive read lock realted deadlocks: > > > > (--(X..Y)--> means a strong dependency path starts with a --(X*)--&

Re: [RFC tip/locking/lockdep v5 05/17] lockdep: Extend __bfs() to work with multiple kinds of dependencies

2018-02-22 Thread Boqun Feng
On Fri, Feb 23, 2018 at 12:31:20AM +0800, Boqun Feng wrote: > On Thu, Feb 22, 2018 at 04:51:43PM +0100, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 04:30:34PM +0100, Peter Zijlstra wrote: > > > On Thu, Feb 22, 2018 at 11:12:10PM +0800, Boqun Feng wrote: > > > >

Re: [RFC tip/locking/lockdep v5 05/17] lockdep: Extend __bfs() to work with multiple kinds of dependencies

2018-02-22 Thread Boqun Feng
On Thu, Feb 22, 2018 at 05:08:11PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 11:12:10PM +0800, Boqun Feng wrote: > > On Thu, Feb 22, 2018 at 03:26:14PM +0100, Peter Zijlstra wrote: > > > On Thu, Feb 22, 2018 at 03:08:52PM +0800, Boqun Feng wrote: > > &g

Re: [RFC tip/locking/lockdep v5 05/17] lockdep: Extend __bfs() to work with multiple kinds of dependencies

2018-02-22 Thread Boqun Feng
On Thu, Feb 22, 2018 at 04:51:43PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 04:30:34PM +0100, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 11:12:10PM +0800, Boqun Feng wrote: > > > On Thu, Feb 22, 2018 at 03:26:14PM +0100, Peter Zijlstra wrote: > >

Re: [RFC tip/locking/lockdep v5 06/17] lockdep: Support deadlock detection for recursive read in check_noncircular()

2018-02-22 Thread Boqun Feng
On Thu, Feb 22, 2018 at 04:16:26PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:54:34PM +0100, Peter Zijlstra wrote: > > On Thu, Feb 22, 2018 at 03:08:53PM +0800, Boqun Feng wrote: > > > > > +static inline int hlock_conflict(struct lock

Re: [RFC tip/locking/lockdep v5 05/17] lockdep: Extend __bfs() to work with multiple kinds of dependencies

2018-02-22 Thread Boqun Feng
On Thu, Feb 22, 2018 at 03:26:14PM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 03:08:52PM +0800, Boqun Feng wrote: > > Now we have four kinds of dependencies in the dependency graph, and not > > all the pathes carry strong dependencies, for example: > > >

Re: [PATCH RFC tools/lkmm 10/12] tools/memory-model: Add a S lock-based external-view litmus test

2018-02-22 Thread Boqun Feng
On Thu, Feb 22, 2018 at 11:15:04AM +0100, Peter Zijlstra wrote: > On Thu, Feb 22, 2018 at 02:58:47PM +0800, Boqun Feng wrote: > > > And yes, if we go with a purely RCpc interpretation of acquire and > > > release, then I don't believe the writes in the previous critica

[RFC tip/locking/lockdep v5 04/17] lockdep: Introduce lock_list::dep

2018-02-21 Thread Boqun Feng
ks, four kinds of dependencies could all exist between them, so we use 4 bit for the presence of each kind(stored in lock_list::dep). Helper functions and marcos are also introduced to convert a pair of locks into ::dep bit and maintain the addition of different kinds of dependencies. Signed-

[RFC tip/locking/lockdep v5 02/17] lockdep: Make __bfs() visit every dependency until a match

2018-02-21 Thread Boqun Feng
: we now mark lock_class::lockdep_dependency_gen_id to indicate _all the dependencies_ in its lock_{after,before} have been visited in the __bfs()(note we only take one direction in a __bfs() search). In this way, every dependency is guaranteed to be visited until we find a match. Signed-off-by: Boqun Fe

[RFC tip/locking/lockdep v5 05/17] lockdep: Extend __bfs() to work with multiple kinds of dependencies

2018-02-21 Thread Boqun Feng
t; and 2) greedily pick a -(*N)-> as hard as possible. With this extension for __bfs(), we now need to initialize the root of __bfs() properly(with a correct ->is_rr), to do so, we introduce some helper functions, which also cleans up a little bit for the __bfs() root initialization code. Signed-off-

[RFC tip/locking/lockdep v5 08/17] lockdep: Fix recursive read lock related safe->unsafe detection

2018-02-21 Thread Boqun Feng
urrent check_usage() only checks 1) and 2), so this patch adds checks for 3) and 4) and makes sure when find_usage_{back,for}wards find an irq-read-{,un}safe lock, the traverse path should ends at a dependency --(*N)-->. Note when we search backwards, --(*N)--> indicates a real dependency --(N*)--

[RFC tip/locking/lockdep v5 07/17] lockdep: Adjust check_redundant() for recursive read change

2018-02-21 Thread Boqun Feng
...--(*R)-->next To do so, we need to pass the recursive-read status of @next into check_redundant(). This patch changes the parameter of check_redundant() and the match function to achieve this. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 13 - 1

[RFC tip/locking/lockdep v5 17/17] MAINTAINERS: Add myself as a LOCKING PRIMITIVES reviewer

2018-02-21 Thread Boqun Feng
any help for lock related code. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 9a7f76eadae9..197dc9c5162f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8239,6 +8239,7 @@ F:Documen

[RFC tip/locking/lockdep v5 13/17] lockdep/selftest: Add more recursive read related test cases

2018-02-21 Thread Boqun Feng
not deadlock. Those self testcases are valuable for the development of supporting recursive read related deadlock detection. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- lib/locking-selftest.c | 161 + 1 file changed, 161 insertions(+)

[RFC tip/locking/lockdep v5 16/17] lockdep: Documention for recursive read lock detection reasoning

2018-02-21 Thread Boqun Feng
ion. * Informal proof of recursive read lock deadlock detection. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> Cc: Randy Dunlap <rdun...@infradead.org> --- Documentation/locking/lockdep-design.txt | 170 +++ 1 file changed, 170 insertions(+) diff --git a/Docume

[RFC tip/locking/lockdep v5 06/17] lockdep: Support deadlock detection for recursive read in check_noncircular()

2018-02-21 Thread Boqun Feng
-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 07bcfaac6fe2..e1be088a34c4 100644 --- a/kernel/locking/lockdep.c +++ b/

[RFC tip/locking/lockdep v5 15/17] lockdep: Reduce the size of lock_list

2018-02-21 Thread Boqun Feng
, as a result we can reduce the size increment introduced by recursive read lock detection and keep the lock_list the same size as before. Suggested-by: Peter Zijlstra <pet...@infradead.org> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/lockdep.h | 6 +++--- kernel/locki

[RFC tip/locking/lockdep v5 01/17] lockdep: Demagic the return value of BFS

2018-02-21 Thread Boqun Feng
for the return value of __bfs() and its friends, this improves the code readability of the code, and further, could help if we want to extend the BFS. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 136 --- 1 file chang

  1   2   3   4   5   6   7   8   >