* [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes
@ 2021-06-17 18:57 Peter Zijlstra
2021-06-17 18:57 ` [PATCH 1/3] lockdep: Fix wait-type for empty stack Peter Zijlstra
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Peter Zijlstra @ 2021-06-17 18:57 UTC (permalink / raw)
To: mingo, will, longman, boqun.feng
Cc: linux-kernel, peterz, joro, bp, tglx, bigeasy
Hi,
Boris said, that Joerg said the locking selftests showed a few FAILED. They
were right.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] lockdep: Fix wait-type for empty stack
2021-06-17 18:57 [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Peter Zijlstra
@ 2021-06-17 18:57 ` Peter Zijlstra
2021-06-23 8:19 ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-06-17 18:57 ` [PATCH 2/3] lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING Peter Zijlstra
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Peter Zijlstra @ 2021-06-17 18:57 UTC (permalink / raw)
To: mingo, will, longman, boqun.feng
Cc: linux-kernel, peterz, joro, bp, tglx, bigeasy
Even the very first lock can violate the wait-context check, consider
the various IRQ contexts.
Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/locking/lockdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -4577,7 +4577,7 @@ static int check_wait_context(struct tas
u8 curr_inner;
int depth;
- if (!curr->lockdep_depth || !next_inner || next->trylock)
+ if (!next_inner || next->trylock)
return 0;
if (!next_outer)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING
2021-06-17 18:57 [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Peter Zijlstra
2021-06-17 18:57 ` [PATCH 1/3] lockdep: Fix wait-type for empty stack Peter Zijlstra
@ 2021-06-17 18:57 ` Peter Zijlstra
2021-06-23 8:19 ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-06-17 18:57 ` [PATCH 3/3] lockdep/selftest: Remove wait-type RCU_CALLBACK tests Peter Zijlstra
2021-06-18 9:23 ` [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Joerg Roedel
3 siblings, 1 reply; 8+ messages in thread
From: Peter Zijlstra @ 2021-06-17 18:57 UTC (permalink / raw)
To: mingo, will, longman, boqun.feng
Cc: linux-kernel, peterz, joro, bp, tglx, bigeasy
When PROVE_RAW_LOCK_NESTING=y many of the selftests FAILED because
HARDIRQ context is out-of-bounds for spinlocks. Instead make the
default hardware context the threaded hardirq context, which preserves
the old locking rules.
The wait-type specific locking selftests will have a non-threaded
HARDIRQ variant.
Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
lib/locking-selftest.c | 1 +
1 file changed, 1 insertion(+)
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -194,6 +194,7 @@ static void init_shared_classes(void)
#define HARDIRQ_ENTER() \
local_irq_disable(); \
__irq_enter(); \
+ lockdep_hardirq_threaded(); \
WARN_ON(!in_irq());
#define HARDIRQ_EXIT() \
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] lockdep/selftest: Remove wait-type RCU_CALLBACK tests
2021-06-17 18:57 [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Peter Zijlstra
2021-06-17 18:57 ` [PATCH 1/3] lockdep: Fix wait-type for empty stack Peter Zijlstra
2021-06-17 18:57 ` [PATCH 2/3] lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING Peter Zijlstra
@ 2021-06-17 18:57 ` Peter Zijlstra
2021-06-23 8:19 ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-06-18 9:23 ` [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Joerg Roedel
3 siblings, 1 reply; 8+ messages in thread
From: Peter Zijlstra @ 2021-06-17 18:57 UTC (permalink / raw)
To: mingo, will, longman, boqun.feng
Cc: linux-kernel, peterz, joro, bp, tglx, bigeasy
The problem is that rcu_callback_map doesn't have wait_types defined,
and doing so would make it indistinguishable from SOFTIRQ in any case.
Remove it.
Fixes: 9271a40d2a14 ("lockdep/selftest: Add wait context selftests")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
lib/locking-selftest.c | 17 -----------------
1 file changed, 17 deletions(-)
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2492,16 +2492,6 @@ static void rcu_sched_exit(int *_)
int rcu_sched_guard_##name __guard(rcu_sched_exit); \
rcu_read_lock_sched();
-static void rcu_callback_exit(int *_)
-{
- rcu_lock_release(&rcu_callback_map);
-}
-
-#define RCU_CALLBACK_CONTEXT(name, ...) \
- int rcu_callback_guard_##name __guard(rcu_callback_exit); \
- rcu_lock_acquire(&rcu_callback_map);
-
-
static void raw_spinlock_exit(raw_spinlock_t **lock)
{
raw_spin_unlock(*lock);
@@ -2558,8 +2548,6 @@ static void __maybe_unused inner##_in_##
* ---------------+-------+----------+------+-------
* RCU_BH | o | o | o | x
* ---------------+-------+----------+------+-------
- * RCU_CALLBACK | o | o | o | x
- * ---------------+-------+----------+------+-------
* RCU_SCHED | o | o | x | x
* ---------------+-------+----------+------+-------
* RAW_SPIN | o | o | x | x
@@ -2576,7 +2564,6 @@ GENERATE_2_CONTEXT_TESTCASE(NOTTHREADED_
GENERATE_2_CONTEXT_TESTCASE(SOFTIRQ, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RCU, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RCU_BH, , inner, inner_lock) \
-GENERATE_2_CONTEXT_TESTCASE(RCU_CALLBACK, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RCU_SCHED, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RAW_SPINLOCK, raw_lock_A, inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(SPINLOCK, lock_A, inner, inner_lock) \
@@ -2638,10 +2625,6 @@ static void wait_context_tests(void)
DO_CONTEXT_TESTCASE_OUTER_LIMITED_PREEMPTIBLE(RCU_BH);
pr_cont("\n");
- print_testname("in RCU callback context");
- DO_CONTEXT_TESTCASE_OUTER_LIMITED_PREEMPTIBLE(RCU_CALLBACK);
- pr_cont("\n");
-
print_testname("in RCU-sched context");
DO_CONTEXT_TESTCASE_OUTER_NOT_PREEMPTIBLE(RCU_SCHED);
pr_cont("\n");
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes
2021-06-17 18:57 [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Peter Zijlstra
` (2 preceding siblings ...)
2021-06-17 18:57 ` [PATCH 3/3] lockdep/selftest: Remove wait-type RCU_CALLBACK tests Peter Zijlstra
@ 2021-06-18 9:23 ` Joerg Roedel
3 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2021-06-18 9:23 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mingo, will, longman, boqun.feng, linux-kernel, bp, tglx, bigeasy
Hi Peter,
On Thu, Jun 17, 2021 at 08:57:17PM +0200, Peter Zijlstra wrote:
> Boris said, that Joerg said the locking selftests showed a few FAILED. They
> were right.
Thanks for looking into this. I tested the patches on my SEV-ES debug
kernel and can confirm that the failures in the locking selftests went
away, so
Tested-by: Joerg Roedel <jroedel@suse.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [tip: locking/core] lockdep/selftest: Remove wait-type RCU_CALLBACK tests
2021-06-17 18:57 ` [PATCH 3/3] lockdep/selftest: Remove wait-type RCU_CALLBACK tests Peter Zijlstra
@ 2021-06-23 8:19 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2021-06-23 8:19 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Peter Zijlstra (Intel), Joerg Roedel, x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 1a8122960484b19d8d887fb32e1cf42be5647533
Gitweb: https://git.kernel.org/tip/1a8122960484b19d8d887fb32e1cf42be5647533
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 17 Jun 2021 20:57:20 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 22 Jun 2021 16:42:08 +02:00
lockdep/selftest: Remove wait-type RCU_CALLBACK tests
The problem is that rcu_callback_map doesn't have wait_types defined,
and doing so would make it indistinguishable from SOFTIRQ in any case.
Remove it.
Fixes: 9271a40d2a14 ("lockdep/selftest: Add wait context selftests")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20210617190313.384290291@infradead.org
---
lib/locking-selftest.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index af12e84..161108e 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -2494,16 +2494,6 @@ static void rcu_sched_exit(int *_)
int rcu_sched_guard_##name __guard(rcu_sched_exit); \
rcu_read_lock_sched();
-static void rcu_callback_exit(int *_)
-{
- rcu_lock_release(&rcu_callback_map);
-}
-
-#define RCU_CALLBACK_CONTEXT(name, ...) \
- int rcu_callback_guard_##name __guard(rcu_callback_exit); \
- rcu_lock_acquire(&rcu_callback_map);
-
-
static void raw_spinlock_exit(raw_spinlock_t **lock)
{
raw_spin_unlock(*lock);
@@ -2560,8 +2550,6 @@ static void __maybe_unused inner##_in_##outer(void) \
* ---------------+-------+----------+------+-------
* RCU_BH | o | o | o | x
* ---------------+-------+----------+------+-------
- * RCU_CALLBACK | o | o | o | x
- * ---------------+-------+----------+------+-------
* RCU_SCHED | o | o | x | x
* ---------------+-------+----------+------+-------
* RAW_SPIN | o | o | x | x
@@ -2578,7 +2566,6 @@ GENERATE_2_CONTEXT_TESTCASE(NOTTHREADED_HARDIRQ, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(SOFTIRQ, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RCU, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RCU_BH, , inner, inner_lock) \
-GENERATE_2_CONTEXT_TESTCASE(RCU_CALLBACK, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RCU_SCHED, , inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(RAW_SPINLOCK, raw_lock_A, inner, inner_lock) \
GENERATE_2_CONTEXT_TESTCASE(SPINLOCK, lock_A, inner, inner_lock) \
@@ -2640,10 +2627,6 @@ static void wait_context_tests(void)
DO_CONTEXT_TESTCASE_OUTER_LIMITED_PREEMPTIBLE(RCU_BH);
pr_cont("\n");
- print_testname("in RCU callback context");
- DO_CONTEXT_TESTCASE_OUTER_LIMITED_PREEMPTIBLE(RCU_CALLBACK);
- pr_cont("\n");
-
print_testname("in RCU-sched context");
DO_CONTEXT_TESTCASE_OUTER_NOT_PREEMPTIBLE(RCU_SCHED);
pr_cont("\n");
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip: locking/core] lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING
2021-06-17 18:57 ` [PATCH 2/3] lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING Peter Zijlstra
@ 2021-06-23 8:19 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2021-06-23 8:19 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Peter Zijlstra (Intel), Joerg Roedel, x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: c0c2c0dad6a06e0c05e9a52d65f932bd54364c97
Gitweb: https://git.kernel.org/tip/c0c2c0dad6a06e0c05e9a52d65f932bd54364c97
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 17 Jun 2021 20:57:19 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 22 Jun 2021 16:42:08 +02:00
lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING
When PROVE_RAW_LOCK_NESTING=y many of the selftests FAILED because
HARDIRQ context is out-of-bounds for spinlocks. Instead make the
default hardware context the threaded hardirq context, which preserves
the old locking rules.
The wait-type specific locking selftests will have a non-threaded
HARDIRQ variant.
Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20210617190313.322096283@infradead.org
---
lib/locking-selftest.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 5c50b09..af12e84 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -195,6 +195,7 @@ static void init_shared_classes(void)
#define HARDIRQ_ENTER() \
local_irq_disable(); \
__irq_enter(); \
+ lockdep_hardirq_threaded(); \
WARN_ON(!in_irq());
#define HARDIRQ_EXIT() \
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip: locking/core] lockdep: Fix wait-type for empty stack
2021-06-17 18:57 ` [PATCH 1/3] lockdep: Fix wait-type for empty stack Peter Zijlstra
@ 2021-06-23 8:19 ` tip-bot2 for Peter Zijlstra
0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2021-06-23 8:19 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Peter Zijlstra (Intel), Joerg Roedel, x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: f8b298cc39f0619544c607eaef09fd0b2afd10f3
Gitweb: https://git.kernel.org/tip/f8b298cc39f0619544c607eaef09fd0b2afd10f3
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Thu, 17 Jun 2021 20:57:18 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 22 Jun 2021 16:42:08 +02:00
lockdep: Fix wait-type for empty stack
Even the very first lock can violate the wait-context check, consider
the various IRQ contexts.
Fixes: de8f5e4f2dc1 ("lockdep: Introduce wait-type checks")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20210617190313.256987481@infradead.org
---
kernel/locking/lockdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 6ff1e84..0584b20 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -4688,7 +4688,7 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)
u8 curr_inner;
int depth;
- if (!curr->lockdep_depth || !next_inner || next->trylock)
+ if (!next_inner || next->trylock)
return 0;
if (!next_outer)
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-06-23 8:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 18:57 [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Peter Zijlstra
2021-06-17 18:57 ` [PATCH 1/3] lockdep: Fix wait-type for empty stack Peter Zijlstra
2021-06-23 8:19 ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-06-17 18:57 ` [PATCH 2/3] lockdep/selftests: Fix selftests vs PROVE_RAW_LOCK_NESTING Peter Zijlstra
2021-06-23 8:19 ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-06-17 18:57 ` [PATCH 3/3] lockdep/selftest: Remove wait-type RCU_CALLBACK tests Peter Zijlstra
2021-06-23 8:19 ` [tip: locking/core] " tip-bot2 for Peter Zijlstra
2021-06-18 9:23 ` [PATCH 0/3] lockdep: PROVE_RAW_LOCK_NESTING=y fixes Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).