[RFC tip/locking/lockdep v3 12/14] lockdep/selftest: Unleash irq_read_recursion2 and add more

2017-09-25 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 v3 07/14] lockdep: Adjust check_redundant() for recursive read change

2017-09-25 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 v3 13/14] lockdep/selftest: Add more recursive read related test cases

2017-09-25 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 v3 07/14] lockdep: Adjust check_redundant() for recursive read change

2017-09-25 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 --- kernel/locking/lockdep.c | 13 - 1 file changed, 8 insertions(+

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

2017-09-25 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 --- lib/locking-selftest.c | 161 + 1 file changed, 161 insertions(+) diff --git a/lib/locking

[RFC tip/locking/lockdep v3 09/14] lockdep: Add recursive read locks into dependency graph

2017-09-25 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 --- kernel/locking/lockdep.c | 16 +++- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking

[RFC tip/locking/lockdep v3 12/14] lockdep/selftest: Unleash irq_read_recursion2 and add more

2017-09-25 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 --- lib/locking-selftest.c | 59 -- 1 file changed, 47 insertions(+), 12

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

2017-09-25 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 9e7647e40918..a68f7df8adc5 100644 --- a/kernel/locking/lockdep.c +++ b/

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

2017-09-25 Thread Boqun Feng
-off-by: Boqun Feng --- 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 9e7647e40918..a68f7df8adc5 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1342,6

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

2017-09-25 Thread Boqun Feng
; 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.

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

2017-09-25 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 v3 04/14] lockdep: Introduce lock_list::dep

2017-09-25 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 v3 00/14] lockdep: Support deadlock detection for recursive read locks

2017-09-25 Thread Boqun Feng
Hi Ingo and Peter, This is V3 for recursive read lock support in lockdep. Changes since V2: * Add one revert patch for commit d82fed752942 ("locking/lockdep/selftests: Fix mixed read-write ABBA tests"), since we could handle recursive read lock correctly, so we don't

[RFC tip/locking/lockdep v3 01/14] lockdep: Demagic the return value of BFS

2017-09-25 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 | 134 --- 1 file chang

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

2017-09-25 Thread Boqun Feng
; 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. Sig

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

2017-09-25 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 Feng ---

[RFC tip/locking/lockdep v3 04/14] lockdep: Introduce lock_list::dep

2017-09-25 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-off-by:

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

2017-09-25 Thread Boqun Feng
Hi Ingo and Peter, This is V3 for recursive read lock support in lockdep. Changes since V2: * Add one revert patch for commit d82fed752942 ("locking/lockdep/selftests: Fix mixed read-write ABBA tests"), since we could handle recursive read lock correctly, so we don't

[RFC tip/locking/lockdep v3 01/14] lockdep: Demagic the return value of BFS

2017-09-25 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 --- kernel/locking/lockdep.c | 134 --- 1 file changed, 79 insertions(+), 55

[RFC tip/locking/lockdep v3 03/14] lockdep: Redefine LOCK_*_STATE* bits

2017-09-25 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 v3 03/14] lockdep: Redefine LOCK_*_STATE* bits

2017-09-25 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 --- Document

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-25 Thread Boqun Feng
On Sun, Sep 24, 2017 at 02:23:04PM +, Mathieu Desnoyers wrote: [...] > >> > >> copy_mm() is performed without holding current->sighand->siglock, so > >> it appears to be racing with concurrent membarrier register cmd. > > > > Speak of racing, I think we currently have a problem if we do a >

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-25 Thread Boqun Feng
On Sun, Sep 24, 2017 at 02:23:04PM +, Mathieu Desnoyers wrote: [...] > >> > >> copy_mm() is performed without holding current->sighand->siglock, so > >> it appears to be racing with concurrent membarrier register cmd. > > > > Speak of racing, I think we currently have a problem if we do a >

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-24 Thread Boqun Feng
On Fri, Sep 22, 2017 at 03:10:10PM +, Mathieu Desnoyers wrote: > - On Sep 22, 2017, at 4:59 AM, Boqun Feng boqun.f...@gmail.com wrote: > > > On Tue, Sep 19, 2017 at 06:13:41PM -0400, Mathieu Desnoyers wrote: > > [...] > >> +static inline void membarrier_arch_

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-24 Thread Boqun Feng
On Fri, Sep 22, 2017 at 03:10:10PM +, Mathieu Desnoyers wrote: > - On Sep 22, 2017, at 4:59 AM, Boqun Feng boqun.f...@gmail.com wrote: > > > On Tue, Sep 19, 2017 at 06:13:41PM -0400, Mathieu Desnoyers wrote: > > [...] > >> +static inline void membarrier_arch_

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-22 Thread Boqun Feng
On Tue, Sep 19, 2017 at 06:13:41PM -0400, Mathieu Desnoyers wrote: [...] > +static inline void membarrier_arch_sched_in(struct task_struct *prev, > + struct task_struct *next) > +{ > + /* > + * Only need the full barrier when switching between processes. > + */ > + if

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-22 Thread Boqun Feng
On Tue, Sep 19, 2017 at 06:13:41PM -0400, Mathieu Desnoyers wrote: [...] > +static inline void membarrier_arch_sched_in(struct task_struct *prev, > + struct task_struct *next) > +{ > + /* > + * Only need the full barrier when switching between processes. > + */ > + if

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-22 Thread Boqun Feng
On Fri, Sep 22, 2017 at 10:24:41AM +0200, Peter Zijlstra wrote: > On Fri, Sep 22, 2017 at 11:22:06AM +0800, Boqun Feng wrote: > > > The idea is in membarrier_private_expedited(), we go through all ->curr > > on each CPU and > > > > 1) If it's a userspace task

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-22 Thread Boqun Feng
On Fri, Sep 22, 2017 at 10:24:41AM +0200, Peter Zijlstra wrote: > On Fri, Sep 22, 2017 at 11:22:06AM +0800, Boqun Feng wrote: > > > The idea is in membarrier_private_expedited(), we go through all ->curr > > on each CPU and > > > > 1) If it's a userspace task

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-21 Thread Boqun Feng
On Fri, Sep 22, 2017 at 11:22:06AM +0800, Boqun Feng wrote: > Hi Mathieu, > > On Tue, Sep 19, 2017 at 06:13:41PM -0400, Mathieu Desnoyers wrote: > > Provide a new command allowing processes to register their intent to use > > the private expedited command. > > >

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-21 Thread Boqun Feng
On Fri, Sep 22, 2017 at 11:22:06AM +0800, Boqun Feng wrote: > Hi Mathieu, > > On Tue, Sep 19, 2017 at 06:13:41PM -0400, Mathieu Desnoyers wrote: > > Provide a new command allowing processes to register their intent to use > > the private expedited command. > > >

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-21 Thread Boqun Feng
noconfig > build on PowerPC. > - Move asm/membarrier.h include under CONFIG_MEMBARRIER, fixing > allnoconfig build on PowerPC. > - Build and runtime tested on PowerPC. > > Signed-off-by: Mathieu Desnoyers <mathieu.desnoy...@efficios.com> > CC: Peter Zijlstra <pet...@infra

Re: [RFC PATCH v3 1/2] membarrier: Provide register expedited private command

2017-09-21 Thread Boqun Feng
noconfig > build on PowerPC. > - Move asm/membarrier.h include under CONFIG_MEMBARRIER, fixing > allnoconfig build on PowerPC. > - Build and runtime tested on PowerPC. > > Signed-off-by: Mathieu Desnoyers > CC: Peter Zijlstra > CC: Paul E. McKenney > CC: Boqun Feng &g

Re: [PATCH] lockdep: Print proper scenario if cross deadlock detected at acquisition time

2017-09-19 Thread Boqun Feng
On Tue, Sep 19, 2017 at 08:52:06PM +0800, Boqun Feng wrote: > For a potential deadlock about CROSSRELEASE as follow: > > P1 P2 > === = > lock(A) > lock(X) > lock(A) >

Re: [PATCH] lockdep: Print proper scenario if cross deadlock detected at acquisition time

2017-09-19 Thread Boqun Feng
On Tue, Sep 19, 2017 at 08:52:06PM +0800, Boqun Feng wrote: > For a potential deadlock about CROSSRELEASE as follow: > > P1 P2 > === = > lock(A) > lock(X) > lock(A) >

[PATCH] lockdep: Print proper scenario if cross deadlock detected at acquisition time

2017-09-19 Thread Boqun Feng
cenario related to CROSSRELEASE to help users find their bugs more easily, so improve this. Cc: "Paul E. McKenney" <paul...@linux.vnet.ibm.com> Cc: Byungchul Park <byungchul.p...@lge.com> Cc: Steven Rostedt <rost...@goodmis.org> Signed-off-by: Boqun

[PATCH] lockdep: Print proper scenario if cross deadlock detected at acquisition time

2017-09-19 Thread Boqun Feng
cenario related to CROSSRELEASE to help users find their bugs more easily, so improve this. Cc: "Paul E. McKenney" Cc: Byungchul Park Cc: Steven Rostedt Signed-off-by: Boqun Feng --- The sample of print_circular_lock_scenario() is from Paul Mckenney. kernel/locking/lockdep.c | 17

Re: Query regarding synchronize_sched_expedited and resched_cpu

2017-09-18 Thread Boqun Feng
On Mon, Sep 18, 2017 at 09:04:56PM -0700, Paul E. McKenney wrote: > On Tue, Sep 19, 2017 at 11:48:22AM +0900, Byungchul Park wrote: > > On Mon, Sep 18, 2017 at 07:33:29PM -0700, Paul E. McKenney wrote: > > > > > Hello Paul and Steven, > > > > > So I think this is another false positive, and the

Re: Query regarding synchronize_sched_expedited and resched_cpu

2017-09-18 Thread Boqun Feng
On Mon, Sep 18, 2017 at 09:04:56PM -0700, Paul E. McKenney wrote: > On Tue, Sep 19, 2017 at 11:48:22AM +0900, Byungchul Park wrote: > > On Mon, Sep 18, 2017 at 07:33:29PM -0700, Paul E. McKenney wrote: > > > > > Hello Paul and Steven, > > > > > So I think this is another false positive, and the

Re: Memory-ordering recipes

2017-09-18 Thread Boqun Feng
On Mon, Sep 18, 2017 at 07:25:48AM -0700, Paul E. McKenney wrote: > On Mon, Sep 18, 2017 at 03:52:42PM +0800, Boqun Feng wrote: > > On Sun, Sep 17, 2017 at 04:05:09PM -0700, Paul E. McKenney wrote: > > > Hello! > > > > > > > Hi Paul, > > >

Re: Memory-ordering recipes

2017-09-18 Thread Boqun Feng
On Mon, Sep 18, 2017 at 07:25:48AM -0700, Paul E. McKenney wrote: > On Mon, Sep 18, 2017 at 03:52:42PM +0800, Boqun Feng wrote: > > On Sun, Sep 17, 2017 at 04:05:09PM -0700, Paul E. McKenney wrote: > > > Hello! > > > > > > > Hi Paul, > > >

Re: Memory-ordering recipes

2017-09-18 Thread Boqun Feng
On Sun, Sep 17, 2017 at 04:05:09PM -0700, Paul E. McKenney wrote: > Hello! > Hi Paul, > The topic of memory-ordering recipes came up at the Linux Plumbers > Conference microconference on Friday, so I thought that I should summarize > what is currently "out there": > > 1.

Re: Memory-ordering recipes

2017-09-18 Thread Boqun Feng
On Sun, Sep 17, 2017 at 04:05:09PM -0700, Paul E. McKenney wrote: > Hello! > Hi Paul, > The topic of memory-ordering recipes came up at the Linux Plumbers > Conference microconference on Friday, so I thought that I should summarize > what is currently "out there": > > 1.

Re: [PATCH] cgroup/cpuset: remove circular dependency deadlock

2017-09-07 Thread Boqun Feng
On Thu, Sep 07, 2017 at 09:28:48AM +0200, Peter Zijlstra wrote: > On Thu, Sep 07, 2017 at 11:34:12AM +0530, Prateek Sood wrote: > > Remove circular dependency deadlock in a scenario where hotplug of CPU is > > being done while there is updation in cgroup and cpuset triggered from > > userspace. >

Re: [PATCH] cgroup/cpuset: remove circular dependency deadlock

2017-09-07 Thread Boqun Feng
On Thu, Sep 07, 2017 at 09:28:48AM +0200, Peter Zijlstra wrote: > On Thu, Sep 07, 2017 at 11:34:12AM +0530, Prateek Sood wrote: > > Remove circular dependency deadlock in a scenario where hotplug of CPU is > > being done while there is updation in cgroup and cpuset triggered from > > userspace. >

Re: [PATCH -v2] blk-mq: Start to fix memory ordering...

2017-09-06 Thread Boqun Feng
> > If I got anything wrong, feel free to educate me by adding comments to > > clarify things ;-) > > > > Cc: Alan Stern <st...@rowland.harvard.edu> > > Cc: Will Deacon <will.dea...@arm.com> > > Cc: Ming Lei <tom.leim...@gmail.com> >

Re: [PATCH -v2] blk-mq: Start to fix memory ordering...

2017-09-06 Thread Boqun Feng
; > > > If I got anything wrong, feel free to educate me by adding comments to > > clarify things ;-) > > > > Cc: Alan Stern > > Cc: Will Deacon > > Cc: Ming Lei > > Cc: Christoph Hellwig > > Cc: Jens Axboe > > Cc: Andrea Parri > > Cc

Re: [RFC tip/locking v2 00/13] lockdep: Support deadlock detection for recursive read locks

2017-09-06 Thread Boqun Feng
On Wed, Sep 06, 2017 at 04:28:11PM +0800, Boqun Feng wrote: > Hi Ingo and Peter, > > This is V2 for recursive read lock support in lockdep. I fix several > bugs in V1 and also add irq inversion detection support for recursive > read locks. > > V1: https://marc

Re: [RFC tip/locking v2 00/13] lockdep: Support deadlock detection for recursive read locks

2017-09-06 Thread Boqun Feng
On Wed, Sep 06, 2017 at 04:28:11PM +0800, Boqun Feng wrote: > Hi Ingo and Peter, > > This is V2 for recursive read lock support in lockdep. I fix several > bugs in V1 and also add irq inversion detection support for recursive > read locks. > > V1: https://marc

[RFC tip/locking v2 09/13] lockdep: Add recursive read locks into dependency graph

2017-09-06 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, 3 insertions(+), 13 deletions(-) diff --git a/kernel/l

[RFC tip/locking v2 09/13] lockdep: Add recursive read locks into dependency graph

2017-09-06 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 --- kernel/locking/lockdep.c | 16 +++- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking

[RFC tip/locking v2 12/13] lockdep/selftest: Unleash irq_read_recursion2 and add more

2017-09-06 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 v2 11/13] lockdep: Take read/write status in consideration when generate chainkey

2017-09-06 Thread Boqun Feng
s now store the "hlock_id"s rather than lock_class indexes. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 60 ++-- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/kernel/locking/

[RFC tip/locking v2 11/13] lockdep: Take read/write status in consideration when generate chainkey

2017-09-06 Thread Boqun Feng
s now store the "hlock_id"s rather than lock_class indexes. Signed-off-by: Boqun Feng --- kernel/locking/lockdep.c | 60 ++-- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c ind

[RFC tip/locking v2 12/13] lockdep/selftest: Unleash irq_read_recursion2 and add more

2017-09-06 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 --- lib/locking-selftest.c | 59 -- 1 file changed, 47 insertions(+), 12

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

2017-09-06 Thread Boqun Feng
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(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c

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

2017-09-06 Thread Boqun Feng
for the development of supporting recursive read related deadlock detection. Signed-off-by: Boqun Feng --- lib/locking-selftest.c | 161 + 1 file changed, 161 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index cbdcec6a776e

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

2017-09-06 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 cd0b5c

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

2017-09-06 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 v2 10/13] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior

2017-09-06 Thread Boqun Feng
on detecting recursive read lock related deadlocks. Signed-off-by: Boqun Feng --- lib/locking-selftest.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index cd0b5c964bd0..1f794bb441a9 100644

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

2017-09-06 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 v2 05/13] lockdep: Extend __bfs() to work with multiple kinds of dependencies

2017-09-06 Thread Boqun Feng
; and 2) greedily pick a --(*N)--> as hard as possible. With this extension for __bfs(), we now only 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.

[RFC tip/locking v2 06/13] lockdep: Adjust check_redundant() for recursive read change

2017-09-06 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 file

[RFC tip/locking v2 03/13] lockdep: Change the meanings of LOCK_{USED_IN, ENABLED}_*_{READ}

2017-09-06 Thread Boqun Feng
her add necessary changes in next versions or leave those as TODOs) Such a change is needed for a future improvement on recursive read related irq inversion deadlock detection. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 4 ++-- 1 file changed, 2 inserti

[RFC tip/locking v2 06/13] lockdep: Adjust check_redundant() for recursive read change

2017-09-06 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 --- kernel/locking/lockdep.c | 13 - 1 file changed, 8 insertions(+

[RFC tip/locking v2 03/13] lockdep: Change the meanings of LOCK_{USED_IN, ENABLED}_*_{READ}

2017-09-06 Thread Boqun Feng
her add necessary changes in next versions or leave those as TODOs) Such a change is needed for a future improvement on recursive read related irq inversion deadlock detection. Signed-off-by: Boqun Feng --- kernel/locking/lockdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --

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

2017-09-06 Thread Boqun Feng
; and 2) greedily pick a --(*N)--> as hard as possible. With this extension for __bfs(), we now only 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

[RFC tip/locking v2 07/13] lockdep: Support deadlock detection for recursive read in check_noncircular()

2017-09-06 Thread Boqun Feng
-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index d9959f25247a..8a09b1a02342 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/l

[RFC tip/locking v2 04/13] lockdep: Introduce lock_list::dep

2017-09-06 Thread Boqun Feng
pair of two locks, 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). Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/lockdep.h | 2 ++ kernel/locking/lockdep.c | 46 +

[RFC tip/locking v2 07/13] lockdep: Support deadlock detection for recursive read in check_noncircular()

2017-09-06 Thread Boqun Feng
-off-by: Boqun Feng --- kernel/locking/lockdep.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index d9959f25247a..8a09b1a02342 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1345,6

[RFC tip/locking v2 04/13] lockdep: Introduce lock_list::dep

2017-09-06 Thread Boqun Feng
pair of two locks, 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). Signed-off-by: Boqun Feng --- include/linux/lockdep.h | 2 ++ kernel/locking/lockdep.c | 46 +++

[RFC tip/locking v2 02/13] lockdep: Make __bfs() visit every dependency rather than every class until a match

2017-09-06 Thread Boqun Feng
e 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, each dependency is guaranteed to be visited until we find a match. Signed-off-by: Boqun Feng <boqun.f..

[RFC tip/locking v2 02/13] lockdep: Make __bfs() visit every dependency rather than every class until a match

2017-09-06 Thread Boqun Feng
e 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, each dependency is guaranteed to be visited until we find a match. Signed-off-by: Boqun Feng --- kernel/l

[RFC tip/locking v2 01/13] lockdep: Demagic the return value of BFS

2017-09-06 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 | 134 --- 1 file chang

[RFC tip/locking v2 01/13] lockdep: Demagic the return value of BFS

2017-09-06 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 --- kernel/locking/lockdep.c | 134 --- 1 file changed, 79 insertions(+), 55

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

2017-09-06 Thread Boqun Feng
Hi Ingo and Peter, This is V2 for recursive read lock support in lockdep. I fix several bugs in V1 and also add irq inversion detection support for recursive read locks. V1: https://marc.info/?l=linux-kernel=150393341825453 As Peter pointed out:

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

2017-09-06 Thread Boqun Feng
Hi Ingo and Peter, This is V2 for recursive read lock support in lockdep. I fix several bugs in V1 and also add irq inversion detection support for recursive read locks. V1: https://marc.info/?l=linux-kernel=150393341825453 As Peter pointed out:

Re: [PATCH 4/4] lockdep: Fix workqueue crossrelease annotation

2017-09-05 Thread Boqun Feng
On Wed, Sep 06, 2017 at 08:52:35AM +0900, Byungchul Park wrote: > On Tue, Sep 05, 2017 at 03:46:43PM +0200, Peter Zijlstra wrote: > > On Tue, Sep 05, 2017 at 07:58:38PM +0900, Byungchul Park wrote: > > > On Tue, Sep 05, 2017 at 07:31:44PM +0900, Byungchul Park wrote: > > > > Recursive-read and the

Re: [PATCH 4/4] lockdep: Fix workqueue crossrelease annotation

2017-09-05 Thread Boqun Feng
On Wed, Sep 06, 2017 at 08:52:35AM +0900, Byungchul Park wrote: > On Tue, Sep 05, 2017 at 03:46:43PM +0200, Peter Zijlstra wrote: > > On Tue, Sep 05, 2017 at 07:58:38PM +0900, Byungchul Park wrote: > > > On Tue, Sep 05, 2017 at 07:31:44PM +0900, Byungchul Park wrote: > > > > Recursive-read and the

[PATCH] kernel: Emphasize the return value of READ_ONCE() is honored

2017-09-02 Thread Boqun Feng
<paul...@linux.vnet.ibm.com> Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- include/linux/compiler.h | 26 ++ 1 file changed, 26 insertions(+) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index eca8ad75e28b..b386dbf8c65c 100644 --- a/include/linux/compil

[PATCH] kernel: Emphasize the return value of READ_ONCE() is honored

2017-09-02 Thread Boqun Feng
been using, but also makes the implementation requirement more accurate. In the future, we can either make compiler writers accept our use of 'volatile', or(if that fails) find another way to provide this guarantee. Cc: Akira Yokosawa Cc: Paul E. McKenney Signed-off-by: Boqun Feng --- include

Re: [PATCH v2] membarrier: provide register sync core cmd

2017-08-29 Thread Boqun Feng
u Desnoyers <mathieu.desnoy...@efficios.com> > CC: Peter Zijlstra <pet...@infradead.org> > CC: Paul E. McKenney <paul...@linux.vnet.ibm.com> > CC: Boqun Feng <boqun.f...@gmail.com> > CC: Andrew Hunter <a...@google.com> > CC: Maged Michael <maged.mich.

Re: [PATCH v2] membarrier: provide register sync core cmd

2017-08-29 Thread Boqun Feng
0.12 > Non-registered processes: 2.73 0.08 > Registered processes: 3.07 0.02 > > Changes since v1: > - Add missing MEMBARRIER_CMD_REGISTER_SYNC_CORE header documentation, > - Add benchmarks to commit message. > > Signed-off-by: Ma

[tip:locking/core] sched/completion: Avoid unnecessary stack allocation for COMPLETION_INITIALIZER_ONSTACK()

2017-08-29 Thread tip-bot for Boqun Feng
Commit-ID: ec81048cc340bb03334e6ca62661ecc0a684897a Gitweb: http://git.kernel.org/tip/ec81048cc340bb03334e6ca62661ecc0a684897a Author: Boqun Feng <boqun.f...@gmail.com> AuthorDate: Wed, 23 Aug 2017 23:25:38 +0800 Committer: Ingo Molnar <mi...@kernel.org> CommitDate: Tue, 29

[tip:locking/core] sched/completion: Avoid unnecessary stack allocation for COMPLETION_INITIALIZER_ONSTACK()

2017-08-29 Thread tip-bot for Boqun Feng
Commit-ID: ec81048cc340bb03334e6ca62661ecc0a684897a Gitweb: http://git.kernel.org/tip/ec81048cc340bb03334e6ca62661ecc0a684897a Author: Boqun Feng AuthorDate: Wed, 23 Aug 2017 23:25:38 +0800 Committer: Ingo Molnar CommitDate: Tue, 29 Aug 2017 15:14:38 +0200 sched/completion: Avoid

[tip:locking/core] acpi/nfit: Fix COMPLETION_INITIALIZER_ONSTACK() abuse

2017-08-29 Thread tip-bot for Boqun Feng
Commit-ID: 1c322ac06d9af7ea259098ae5dc977855207d335 Gitweb: http://git.kernel.org/tip/1c322ac06d9af7ea259098ae5dc977855207d335 Author: Boqun Feng <boqun.f...@gmail.com> AuthorDate: Thu, 24 Aug 2017 22:22:36 +0800 Committer: Ingo Molnar <mi...@kernel.org> CommitDate: Tue, 29

[tip:locking/core] acpi/nfit: Fix COMPLETION_INITIALIZER_ONSTACK() abuse

2017-08-29 Thread tip-bot for Boqun Feng
Commit-ID: 1c322ac06d9af7ea259098ae5dc977855207d335 Gitweb: http://git.kernel.org/tip/1c322ac06d9af7ea259098ae5dc977855207d335 Author: Boqun Feng AuthorDate: Thu, 24 Aug 2017 22:22:36 +0800 Committer: Ingo Molnar CommitDate: Tue, 29 Aug 2017 15:14:38 +0200 acpi/nfit: Fix

[RFC RESEND tip 5/5] lockdep: Take read/write status in consideration when generate chainkey

2017-08-28 Thread Boqun Feng
s now store the "hlock_id"s rather than lock_class indexes. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 60 ++-- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/kernel/locking/

[RFC RESEND tip 5/5] lockdep: Take read/write status in consideration when generate chainkey

2017-08-28 Thread Boqun Feng
s now store the "hlock_id"s rather than lock_class indexes. Signed-off-by: Boqun Feng --- kernel/locking/lockdep.c | 60 ++-- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c ind

[RFC RESEND tip 4/5] lockdep: Support deadlock detection for recursive read locks in check_noncircular()

2017-08-28 Thread Boqun Feng
gt; B and B-->C). In other words, a lock cannot be the transfer station if it only has *->R dependencies with previous locks and R->* dependencies with following locks. If we could still find a circle under this rule, a deadlock is reported. Signed-off-by: Boqun Feng <boqun.f...@gm

[RFC RESEND tip 4/5] lockdep: Support deadlock detection for recursive read locks in check_noncircular()

2017-08-28 Thread Boqun Feng
gt; B and B-->C). In other words, a lock cannot be the transfer station if it only has *->R dependencies with previous locks and R->* dependencies with following locks. If we could still find a circle under this rule, a deadlock is reported. Signed-off-by: Boqun Feng --- include/linux/loc

[RFC RESEND tip 3/5] lockdep: Demagic the return value of BFS

2017-08-28 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 | 134 --- 1 file chang

[RFC RESEND tip 3/5] lockdep: Demagic the return value of BFS

2017-08-28 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 --- kernel/locking/lockdep.c | 134 --- 1 file changed, 79 insertions(+), 55

[RFC RESEND tip 1/5] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior

2017-08-28 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 3c7151

[RFC RESEND tip 1/5] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior

2017-08-28 Thread Boqun Feng
on detecting recursive read lock related deadlocks. Signed-off-by: Boqun Feng --- lib/locking-selftest.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 3c7151a6cd98..747a5379aeee 100644

[RFC RESEND tip 2/5] lockdep/selftest: Add more recursive read related test cases

2017-08-28 Thread Boqun Feng
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(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c

[RFC RESEND tip 2/5] lockdep/selftest: Add more recursive read related test cases

2017-08-28 Thread Boqun Feng
for the development of supporting recursive read related deadlock detection. Signed-off-by: Boqun Feng --- lib/locking-selftest.c | 161 + 1 file changed, 161 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 747a5379aeee

[RFC RESEND tip 0/5] lockdep: Support deadlock detection for recursive read locks

2017-08-28 Thread Boqun Feng
(Resend because getting weird reject, Sorry) Hi Ingo and Peter, As Peter pointed out: https://marc.info/?l=linux-kernel=150349072023540 The lockdep current has a limit support for recursive read locks, the deadlock case as follow could not be detected: read_lock(A);

[RFC RESEND tip 0/5] lockdep: Support deadlock detection for recursive read locks

2017-08-28 Thread Boqun Feng
(Resend because getting weird reject, Sorry) Hi Ingo and Peter, As Peter pointed out: https://marc.info/?l=linux-kernel=150349072023540 The lockdep current has a limit support for recursive read locks, the deadlock case as follow could not be detected: read_lock(A);

[RFC tip 5/5] lockdep: Take read/write status in consideration when generate chainkey

2017-08-28 Thread Boqun Feng
s now store the "hlock_id"s rather than lock_class indexes. Signed-off-by: Boqun Feng <boqun.f...@gmail.com> --- kernel/locking/lockdep.c | 60 ++-- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/kernel/locking/

<    2   3   4   5   6   7   8   9   10   11   >