aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorWaiman Long <Waiman.Long@hp.com>2014-08-06 13:22:02 -0400
committerIngo Molnar <mingo@kernel.org>2014-08-13 04:33:35 -0400
commitae17ea0ec7d8fa64fbb773a52b2df5ba4766bcb8 (patch)
tree1ba62bb20fa9723c9a6af118dd96455d9f9109a4 /lib
parentf0bab73cb539fb803c4d419951e8d28aa4964f8f (diff)
locking/selftest: Support queued rwlock
The queued rwlock does not support the use of recursive read-lock in the process context. With changes in the lockdep code to check and disallow recursive read-lock, it is also necessary for the locking selftest to be updated to change the process context recursive read locking results from SUCCESS to FAILURE for rwlock. Signed-off-by: Waiman Long <Waiman.Long@hp.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com> Cc: Rik van Riel <riel@redhat.com> Cc: Scott J Norton <scott.norton@hp.com> Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/1407345722-61615-3-git-send-email-Waiman.Long@hp.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/locking-selftest.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 872a15a2a637..62af709b2083 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -267,19 +267,46 @@ GENERATE_TESTCASE(AA_rsem)
267#undef E 267#undef E
268 268
269/* 269/*
270 * Special-case for read-locking, they are 270 * Special-case for read-locking, they are not allowed to
271 * allowed to recurse on the same lock class: 271 * recurse on the same lock class except under interrupt context:
272 */ 272 */
273static void rlock_AA1(void) 273static void rlock_AA1(void)
274{ 274{
275 RL(X1); 275 RL(X1);
276 RL(X1); // this one should NOT fail 276 RL(X1); // this one should fail
277} 277}
278 278
279static void rlock_AA1B(void) 279static void rlock_AA1B(void)
280{ 280{
281 RL(X1); 281 RL(X1);
282 RL(X2); // this one should NOT fail 282 RL(X2); // this one should fail
283}
284
285static void rlock_AHA1(void)
286{
287 RL(X1);
288 HARDIRQ_ENTER();
289 RL(X1); // this one should NOT fail
290 HARDIRQ_EXIT();
291}
292
293static void rlock_AHA1B(void)
294{
295 RL(X1);
296 HARDIRQ_ENTER();
297 RL(X2); // this one should NOT fail
298 HARDIRQ_EXIT();
299}
300
301static void rlock_ASAHA1(void)
302{
303 RL(X1);
304 SOFTIRQ_ENTER();
305 RL(X1); // this one should NOT fail
306 HARDIRQ_ENTER();
307 RL(X1); // this one should NOT fail
308 HARDIRQ_EXIT();
309 SOFTIRQ_EXIT();
283} 310}
284 311
285static void rsem_AA1(void) 312static void rsem_AA1(void)
@@ -1069,7 +1096,7 @@ static inline void print_testname(const char *testname)
1069 print_testname(desc); \ 1096 print_testname(desc); \
1070 dotest(name##_spin, FAILURE, LOCKTYPE_SPIN); \ 1097 dotest(name##_spin, FAILURE, LOCKTYPE_SPIN); \
1071 dotest(name##_wlock, FAILURE, LOCKTYPE_RWLOCK); \ 1098 dotest(name##_wlock, FAILURE, LOCKTYPE_RWLOCK); \
1072 dotest(name##_rlock, SUCCESS, LOCKTYPE_RWLOCK); \ 1099 dotest(name##_rlock, FAILURE, LOCKTYPE_RWLOCK); \
1073 dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \ 1100 dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX); \
1074 dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \ 1101 dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
1075 dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \ 1102 dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
@@ -1830,14 +1857,14 @@ void locking_selftest(void)
1830 printk(" --------------------------------------------------------------------------\n"); 1857 printk(" --------------------------------------------------------------------------\n");
1831 print_testname("recursive read-lock"); 1858 print_testname("recursive read-lock");
1832 printk(" |"); 1859 printk(" |");
1833 dotest(rlock_AA1, SUCCESS, LOCKTYPE_RWLOCK); 1860 dotest(rlock_AA1, FAILURE, LOCKTYPE_RWLOCK);
1834 printk(" |"); 1861 printk(" |");
1835 dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM); 1862 dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM);
1836 printk("\n"); 1863 printk("\n");
1837 1864
1838 print_testname("recursive read-lock #2"); 1865 print_testname("recursive read-lock #2");
1839 printk(" |"); 1866 printk(" |");
1840 dotest(rlock_AA1B, SUCCESS, LOCKTYPE_RWLOCK); 1867 dotest(rlock_AA1B, FAILURE, LOCKTYPE_RWLOCK);
1841 printk(" |"); 1868 printk(" |");
1842 dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM); 1869 dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM);
1843 printk("\n"); 1870 printk("\n");
@@ -1856,6 +1883,21 @@ void locking_selftest(void)
1856 dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM); 1883 dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM);
1857 printk("\n"); 1884 printk("\n");
1858 1885
1886 print_testname("recursive rlock with interrupt");
1887 printk(" |");
1888 dotest(rlock_AHA1, SUCCESS, LOCKTYPE_RWLOCK);
1889 printk("\n");
1890
1891 print_testname("recursive rlock with interrupt #2");
1892 printk(" |");
1893 dotest(rlock_AHA1B, SUCCESS, LOCKTYPE_RWLOCK);
1894 printk("\n");
1895
1896 print_testname("recursive rlock with interrupt #3");
1897 printk(" |");
1898 dotest(rlock_ASAHA1, SUCCESS, LOCKTYPE_RWLOCK);
1899 printk("\n");
1900
1859 printk(" --------------------------------------------------------------------------\n"); 1901 printk(" --------------------------------------------------------------------------\n");
1860 1902
1861 /* 1903 /*