* [PATCH 0/2 -rt] make locckdep selftest work on -rt
@ 2012-04-16 7:01 Yong Zhang
2012-04-16 7:01 ` [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock Yong Zhang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Yong Zhang @ 2012-04-16 7:01 UTC (permalink / raw)
To: linux-rt-users, linux-kernel; +Cc: tglx
On -rt,
1) There is no softirq context any more;
2) rwlock can not be used in harirq context;
Wrt that, convert spinlock to raw spinlock to make spinlock+hardirq
work, and discard the test for rwlock+hardirq and softirq.
BTW, I think patch#1 can go to upstream.
Thanks,
Yong
---
Yong Zhang (2):
lockdep: selftest: convert spinlock to raw spinlock
lockdep: selftest: Only do hardirq context test for raw spinlock
lib/locking-selftest.c | 57 +++++++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 17 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock 2012-04-16 7:01 [PATCH 0/2 -rt] make locckdep selftest work on -rt Yong Zhang @ 2012-04-16 7:01 ` Yong Zhang 2013-02-14 17:58 ` [tip:core/locking] lockdep: Selftest: " tip-bot for Yong Zhang 2013-02-22 12:33 ` tip-bot for Yong Zhang 2012-04-16 7:01 ` [PATCH 2/2 -rt] lockdep: selftest: Only do hardirq context test for " Yong Zhang 2012-04-17 7:23 ` [PATCH 3/3 -rt] lockdep: selftest: save/restore migrate_disable count Yong Zhang 2 siblings, 2 replies; 6+ messages in thread From: Yong Zhang @ 2012-04-16 7:01 UTC (permalink / raw) To: linux-rt-users, linux-kernel; +Cc: tglx, Yong Zhang From: Yong Zhang <yong.zhang@windriver.com> spinlock is sleepable on -rt and can not be used in interrupt context. Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> --- lib/locking-selftest.c | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 7aae0f2..c3eb261 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -47,10 +47,10 @@ __setup("debug_locks_verbose=", setup_debug_locks_verbose); * Normal standalone locks, for the circular and irq-context * dependency tests: */ -static DEFINE_SPINLOCK(lock_A); -static DEFINE_SPINLOCK(lock_B); -static DEFINE_SPINLOCK(lock_C); -static DEFINE_SPINLOCK(lock_D); +static DEFINE_RAW_SPINLOCK(lock_A); +static DEFINE_RAW_SPINLOCK(lock_B); +static DEFINE_RAW_SPINLOCK(lock_C); +static DEFINE_RAW_SPINLOCK(lock_D); static DEFINE_RWLOCK(rwlock_A); static DEFINE_RWLOCK(rwlock_B); @@ -73,12 +73,12 @@ static DECLARE_RWSEM(rwsem_D); * but X* and Y* are different classes. We do this so that * we do not trigger a real lockup: */ -static DEFINE_SPINLOCK(lock_X1); -static DEFINE_SPINLOCK(lock_X2); -static DEFINE_SPINLOCK(lock_Y1); -static DEFINE_SPINLOCK(lock_Y2); -static DEFINE_SPINLOCK(lock_Z1); -static DEFINE_SPINLOCK(lock_Z2); +static DEFINE_RAW_SPINLOCK(lock_X1); +static DEFINE_RAW_SPINLOCK(lock_X2); +static DEFINE_RAW_SPINLOCK(lock_Y1); +static DEFINE_RAW_SPINLOCK(lock_Y2); +static DEFINE_RAW_SPINLOCK(lock_Z1); +static DEFINE_RAW_SPINLOCK(lock_Z2); static DEFINE_RWLOCK(rwlock_X1); static DEFINE_RWLOCK(rwlock_X2); @@ -107,10 +107,10 @@ static DECLARE_RWSEM(rwsem_Z2); */ #define INIT_CLASS_FUNC(class) \ static noinline void \ -init_class_##class(spinlock_t *lock, rwlock_t *rwlock, struct mutex *mutex, \ - struct rw_semaphore *rwsem) \ +init_class_##class(raw_spinlock_t *lock, rwlock_t *rwlock, \ + struct mutex *mutex, struct rw_semaphore *rwsem)\ { \ - spin_lock_init(lock); \ + raw_spin_lock_init(lock); \ rwlock_init(rwlock); \ mutex_init(mutex); \ init_rwsem(rwsem); \ @@ -168,10 +168,10 @@ static void init_shared_classes(void) * Shortcuts for lock/unlock API variants, to keep * the testcases compact: */ -#define L(x) spin_lock(&lock_##x) -#define U(x) spin_unlock(&lock_##x) +#define L(x) raw_spin_lock(&lock_##x) +#define U(x) raw_spin_unlock(&lock_##x) #define LU(x) L(x); U(x) -#define SI(x) spin_lock_init(&lock_##x) +#define SI(x) raw_spin_lock_init(&lock_##x) #define WL(x) write_lock(&rwlock_##x) #define WU(x) write_unlock(&rwlock_##x) @@ -911,7 +911,7 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft) #define I2(x) \ do { \ - spin_lock_init(&lock_##x); \ + raw_spin_lock_init(&lock_##x); \ rwlock_init(&rwlock_##x); \ mutex_init(&mutex_##x); \ init_rwsem(&rwsem_##x); \ -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip:core/locking] lockdep: Selftest: convert spinlock to raw spinlock 2012-04-16 7:01 ` [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock Yong Zhang @ 2013-02-14 17:58 ` tip-bot for Yong Zhang 2013-02-22 12:33 ` tip-bot for Yong Zhang 1 sibling, 0 replies; 6+ messages in thread From: tip-bot for Yong Zhang @ 2013-02-14 17:58 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, yong.zhang0, tglx Commit-ID: d751f38c002c3fd9334b0a2622da149c73bee979 Gitweb: http://git.kernel.org/tip/d751f38c002c3fd9334b0a2622da149c73bee979 Author: Yong Zhang <yong.zhang0@gmail.com> AuthorDate: Mon, 16 Apr 2012 15:01:55 +0800 Committer: Thomas Gleixner <tglx@linutronix.de> CommitDate: Thu, 14 Feb 2013 18:39:07 +0100 lockdep: Selftest: convert spinlock to raw spinlock To make the lockdep selftest working on RT we need to convert the spinlock tests to a raw spinlock. Otherwise we cannot run the irq context checks. For mainline this is just annotational as spinlocks are mapped to raw_spinlocks anyway. Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> Link: http://lkml.kernel.org/r/1334559716-18447-2-git-send-email-yong.zhang0@gmail.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- lib/locking-selftest.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 7aae0f2..c3eb261 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -47,10 +47,10 @@ __setup("debug_locks_verbose=", setup_debug_locks_verbose); * Normal standalone locks, for the circular and irq-context * dependency tests: */ -static DEFINE_SPINLOCK(lock_A); -static DEFINE_SPINLOCK(lock_B); -static DEFINE_SPINLOCK(lock_C); -static DEFINE_SPINLOCK(lock_D); +static DEFINE_RAW_SPINLOCK(lock_A); +static DEFINE_RAW_SPINLOCK(lock_B); +static DEFINE_RAW_SPINLOCK(lock_C); +static DEFINE_RAW_SPINLOCK(lock_D); static DEFINE_RWLOCK(rwlock_A); static DEFINE_RWLOCK(rwlock_B); @@ -73,12 +73,12 @@ static DECLARE_RWSEM(rwsem_D); * but X* and Y* are different classes. We do this so that * we do not trigger a real lockup: */ -static DEFINE_SPINLOCK(lock_X1); -static DEFINE_SPINLOCK(lock_X2); -static DEFINE_SPINLOCK(lock_Y1); -static DEFINE_SPINLOCK(lock_Y2); -static DEFINE_SPINLOCK(lock_Z1); -static DEFINE_SPINLOCK(lock_Z2); +static DEFINE_RAW_SPINLOCK(lock_X1); +static DEFINE_RAW_SPINLOCK(lock_X2); +static DEFINE_RAW_SPINLOCK(lock_Y1); +static DEFINE_RAW_SPINLOCK(lock_Y2); +static DEFINE_RAW_SPINLOCK(lock_Z1); +static DEFINE_RAW_SPINLOCK(lock_Z2); static DEFINE_RWLOCK(rwlock_X1); static DEFINE_RWLOCK(rwlock_X2); @@ -107,10 +107,10 @@ static DECLARE_RWSEM(rwsem_Z2); */ #define INIT_CLASS_FUNC(class) \ static noinline void \ -init_class_##class(spinlock_t *lock, rwlock_t *rwlock, struct mutex *mutex, \ - struct rw_semaphore *rwsem) \ +init_class_##class(raw_spinlock_t *lock, rwlock_t *rwlock, \ + struct mutex *mutex, struct rw_semaphore *rwsem)\ { \ - spin_lock_init(lock); \ + raw_spin_lock_init(lock); \ rwlock_init(rwlock); \ mutex_init(mutex); \ init_rwsem(rwsem); \ @@ -168,10 +168,10 @@ static void init_shared_classes(void) * Shortcuts for lock/unlock API variants, to keep * the testcases compact: */ -#define L(x) spin_lock(&lock_##x) -#define U(x) spin_unlock(&lock_##x) +#define L(x) raw_spin_lock(&lock_##x) +#define U(x) raw_spin_unlock(&lock_##x) #define LU(x) L(x); U(x) -#define SI(x) spin_lock_init(&lock_##x) +#define SI(x) raw_spin_lock_init(&lock_##x) #define WL(x) write_lock(&rwlock_##x) #define WU(x) write_unlock(&rwlock_##x) @@ -911,7 +911,7 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft) #define I2(x) \ do { \ - spin_lock_init(&lock_##x); \ + raw_spin_lock_init(&lock_##x); \ rwlock_init(&rwlock_##x); \ mutex_init(&mutex_##x); \ init_rwsem(&rwsem_##x); \ ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip:core/locking] lockdep: Selftest: convert spinlock to raw spinlock 2012-04-16 7:01 ` [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock Yong Zhang 2013-02-14 17:58 ` [tip:core/locking] lockdep: Selftest: " tip-bot for Yong Zhang @ 2013-02-22 12:33 ` tip-bot for Yong Zhang 1 sibling, 0 replies; 6+ messages in thread From: tip-bot for Yong Zhang @ 2013-02-22 12:33 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, yong.zhang0, tglx Commit-ID: 9fb1b90ce0a847a8cc9492a6c1f347b5be1f33ff Gitweb: http://git.kernel.org/tip/9fb1b90ce0a847a8cc9492a6c1f347b5be1f33ff Author: Yong Zhang <yong.zhang0@gmail.com> AuthorDate: Mon, 16 Apr 2012 15:01:55 +0800 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Tue, 19 Feb 2013 08:43:35 +0100 lockdep: Selftest: convert spinlock to raw spinlock To make the lockdep selftest working on RT we need to convert the spinlock tests to a raw spinlock. Otherwise we cannot run the irq context checks. For mainline this is just annotational as spinlocks are mapped to raw_spinlocks anyway. Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> Link: http://lkml.kernel.org/r/1334559716-18447-2-git-send-email-yong.zhang0@gmail.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- lib/locking-selftest.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 7aae0f2..c3eb261 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -47,10 +47,10 @@ __setup("debug_locks_verbose=", setup_debug_locks_verbose); * Normal standalone locks, for the circular and irq-context * dependency tests: */ -static DEFINE_SPINLOCK(lock_A); -static DEFINE_SPINLOCK(lock_B); -static DEFINE_SPINLOCK(lock_C); -static DEFINE_SPINLOCK(lock_D); +static DEFINE_RAW_SPINLOCK(lock_A); +static DEFINE_RAW_SPINLOCK(lock_B); +static DEFINE_RAW_SPINLOCK(lock_C); +static DEFINE_RAW_SPINLOCK(lock_D); static DEFINE_RWLOCK(rwlock_A); static DEFINE_RWLOCK(rwlock_B); @@ -73,12 +73,12 @@ static DECLARE_RWSEM(rwsem_D); * but X* and Y* are different classes. We do this so that * we do not trigger a real lockup: */ -static DEFINE_SPINLOCK(lock_X1); -static DEFINE_SPINLOCK(lock_X2); -static DEFINE_SPINLOCK(lock_Y1); -static DEFINE_SPINLOCK(lock_Y2); -static DEFINE_SPINLOCK(lock_Z1); -static DEFINE_SPINLOCK(lock_Z2); +static DEFINE_RAW_SPINLOCK(lock_X1); +static DEFINE_RAW_SPINLOCK(lock_X2); +static DEFINE_RAW_SPINLOCK(lock_Y1); +static DEFINE_RAW_SPINLOCK(lock_Y2); +static DEFINE_RAW_SPINLOCK(lock_Z1); +static DEFINE_RAW_SPINLOCK(lock_Z2); static DEFINE_RWLOCK(rwlock_X1); static DEFINE_RWLOCK(rwlock_X2); @@ -107,10 +107,10 @@ static DECLARE_RWSEM(rwsem_Z2); */ #define INIT_CLASS_FUNC(class) \ static noinline void \ -init_class_##class(spinlock_t *lock, rwlock_t *rwlock, struct mutex *mutex, \ - struct rw_semaphore *rwsem) \ +init_class_##class(raw_spinlock_t *lock, rwlock_t *rwlock, \ + struct mutex *mutex, struct rw_semaphore *rwsem)\ { \ - spin_lock_init(lock); \ + raw_spin_lock_init(lock); \ rwlock_init(rwlock); \ mutex_init(mutex); \ init_rwsem(rwsem); \ @@ -168,10 +168,10 @@ static void init_shared_classes(void) * Shortcuts for lock/unlock API variants, to keep * the testcases compact: */ -#define L(x) spin_lock(&lock_##x) -#define U(x) spin_unlock(&lock_##x) +#define L(x) raw_spin_lock(&lock_##x) +#define U(x) raw_spin_unlock(&lock_##x) #define LU(x) L(x); U(x) -#define SI(x) spin_lock_init(&lock_##x) +#define SI(x) raw_spin_lock_init(&lock_##x) #define WL(x) write_lock(&rwlock_##x) #define WU(x) write_unlock(&rwlock_##x) @@ -911,7 +911,7 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft) #define I2(x) \ do { \ - spin_lock_init(&lock_##x); \ + raw_spin_lock_init(&lock_##x); \ rwlock_init(&rwlock_##x); \ mutex_init(&mutex_##x); \ init_rwsem(&rwsem_##x); \ ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2 -rt] lockdep: selftest: Only do hardirq context test for raw spinlock 2012-04-16 7:01 [PATCH 0/2 -rt] make locckdep selftest work on -rt Yong Zhang 2012-04-16 7:01 ` [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock Yong Zhang @ 2012-04-16 7:01 ` Yong Zhang 2012-04-17 7:23 ` [PATCH 3/3 -rt] lockdep: selftest: save/restore migrate_disable count Yong Zhang 2 siblings, 0 replies; 6+ messages in thread From: Yong Zhang @ 2012-04-16 7:01 UTC (permalink / raw) To: linux-rt-users, linux-kernel; +Cc: tglx, Yong Zhang From: Yong Zhang <yong.zhang@windriver.com> On -rt there is no softirq context any more and rwlock is sleepable, disable softirq context test and rwlock+irq test. Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> --- lib/locking-selftest.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index c3eb261..23b8564 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -1175,6 +1175,7 @@ void locking_selftest(void) printk(" --------------------------------------------------------------------------\n"); +#ifndef CONFIG_PREEMPT_RT_FULL /* * irq-context testcases: */ @@ -1187,6 +1188,28 @@ void locking_selftest(void) DO_TESTCASE_6x2("irq read-recursion", irq_read_recursion); // DO_TESTCASE_6x2B("irq read-recursion #2", irq_read_recursion2); +#else + /* On -rt, we only do hardirq context test for raw spinlock */ + DO_TESTCASE_1B("hard-irqs-on + irq-safe-A", irqsafe1_hard_spin, 12); + DO_TESTCASE_1B("hard-irqs-on + irq-safe-A", irqsafe1_hard_spin, 21); + + DO_TESTCASE_1B("hard-safe-A + irqs-on", irqsafe2B_hard_spin, 12); + DO_TESTCASE_1B("hard-safe-A + irqs-on", irqsafe2B_hard_spin, 21); + + DO_TESTCASE_1B("hard-safe-A + unsafe-B #1", irqsafe3_hard_spin, 123); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #1", irqsafe3_hard_spin, 132); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #1", irqsafe3_hard_spin, 213); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #1", irqsafe3_hard_spin, 231); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #1", irqsafe3_hard_spin, 312); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #1", irqsafe3_hard_spin, 321); + + DO_TESTCASE_1B("hard-safe-A + unsafe-B #2", irqsafe4_hard_spin, 123); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #2", irqsafe4_hard_spin, 132); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #2", irqsafe4_hard_spin, 213); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #2", irqsafe4_hard_spin, 231); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #2", irqsafe4_hard_spin, 312); + DO_TESTCASE_1B("hard-safe-A + unsafe-B #2", irqsafe4_hard_spin, 321); +#endif if (unexpected_testcase_failures) { printk("-----------------------------------------------------------------\n"); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3 -rt] lockdep: selftest: save/restore migrate_disable count 2012-04-16 7:01 [PATCH 0/2 -rt] make locckdep selftest work on -rt Yong Zhang 2012-04-16 7:01 ` [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock Yong Zhang 2012-04-16 7:01 ` [PATCH 2/2 -rt] lockdep: selftest: Only do hardirq context test for " Yong Zhang @ 2012-04-17 7:23 ` Yong Zhang 2 siblings, 0 replies; 6+ messages in thread From: Yong Zhang @ 2012-04-17 7:23 UTC (permalink / raw) To: linux-rt-users, linux-kernel; +Cc: tglx, Yong Zhang From: Yong Zhang <yong.zhang@windriver.com> ->migrate_disable_atomic will corrupt when doing some case, such as double lock... ->migrate_disable will not be affected for now since we have preempt disabled when doing seft test. Just record it also for safe. Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> --- Found it when enable CONFIG_SCHED_DEBUG. lib/locking-selftest.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 23b8564..a9cb9e4 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -939,6 +939,12 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask) { unsigned long saved_preempt_count = preempt_count(); int expected_failure = 0; +#ifdef CONFIG_PREEMPT_RT_FULL + int saved_migrate_disable = current->migrate_disable; +# ifdef CONFIG_SCHED_DEBUG + int saved_migrate_disable_atomic = current->migrate_disable_atomic; +# endif +#endif WARN_ON(irqs_disabled()); @@ -980,6 +986,13 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask) * count, so restore it: */ preempt_count() = saved_preempt_count; +#ifdef CONFIG_PREEMPT_RT_FULL + current->migrate_disable = saved_migrate_disable; +# ifdef CONFIG_SCHED_DEBUG + current->migrate_disable_atomic = saved_migrate_disable_atomic; +# endif +#endif + #ifdef CONFIG_TRACE_IRQFLAGS if (softirq_count()) current->softirqs_enabled = 0; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-02-22 12:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-04-16 7:01 [PATCH 0/2 -rt] make locckdep selftest work on -rt Yong Zhang 2012-04-16 7:01 ` [PATCH 1/2 -rt] lockdep: selftest: convert spinlock to raw spinlock Yong Zhang 2013-02-14 17:58 ` [tip:core/locking] lockdep: Selftest: " tip-bot for Yong Zhang 2013-02-22 12:33 ` tip-bot for Yong Zhang 2012-04-16 7:01 ` [PATCH 2/2 -rt] lockdep: selftest: Only do hardirq context test for " Yong Zhang 2012-04-17 7:23 ` [PATCH 3/3 -rt] lockdep: selftest: save/restore migrate_disable count Yong Zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox