From: John Ogness <john.ogness@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 4/5] locking/selftest: use pr_cont_t for cont messages
Date: Thu, 20 Aug 2020 01:32:31 +0206 [thread overview]
Message-ID: <20200819232632.13418-5-john.ogness@linutronix.de> (raw)
In-Reply-To: <20200819232632.13418-1-john.ogness@linutronix.de>
Use the new pr_cont_t mechanism.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
lib/locking-selftest.c | 85 ++++++++++++++++++++++--------------------
1 file changed, 44 insertions(+), 41 deletions(-)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 14f44f59e733..3131c517ae62 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -52,6 +52,7 @@ __setup("debug_locks_verbose=", setup_debug_locks_verbose);
static struct ww_acquire_ctx t, t2;
static struct ww_mutex o, o2, o3;
+static pr_cont_t c;
/*
* Normal standalone locks, for the circular and irq-context
@@ -1147,22 +1148,24 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
#ifndef CONFIG_PROVE_LOCKING
if (expected == FAILURE && debug_locks) {
expected_testcase_failures++;
- pr_cont("failed|");
+ pr_cont_append(&c, "failed|");
}
else
#endif
if (debug_locks != expected) {
unexpected_testcase_failures++;
- pr_cont("FAILED|");
+ pr_cont_append(&c, "FAILED|");
} else {
testcase_successes++;
- pr_cont(" ok |");
+ pr_cont_append(&c, " ok |");
}
testcase_total++;
- if (debug_locks_verbose)
- pr_cont(" lockclass mask: %x, debug_locks: %d, expected: %d\n",
+ if (debug_locks_verbose) {
+ pr_cont_append(&c, " lockclass mask: %x, debug_locks: %d, expected: %d",
lockclass_mask, debug_locks, expected);
+ pr_cont_flush(&c);
+ }
/*
* Some tests (e.g. double-unlock) might corrupt the preemption
* count, so restore it:
@@ -1186,32 +1189,32 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
static inline void print_testname(const char *testname)
{
- printk("%33s:", testname);
+ pr_cont_begin(&c, "%33s:", testname);
}
#define DO_TESTCASE_1(desc, name, nr) \
print_testname(desc"/"#nr); \
dotest(name##_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
- pr_cont("\n");
+ pr_cont_end(&c);
#define DO_TESTCASE_1B(desc, name, nr) \
print_testname(desc"/"#nr); \
dotest(name##_##nr, FAILURE, LOCKTYPE_RWLOCK); \
- pr_cont("\n");
+ pr_cont_end(&c);
#define DO_TESTCASE_3(desc, name, nr) \
print_testname(desc"/"#nr); \
dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN); \
dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \
dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
- pr_cont("\n");
+ pr_cont_end(&c);
#define DO_TESTCASE_3RW(desc, name, nr) \
print_testname(desc"/"#nr); \
dotest(name##_spin_##nr, FAILURE, LOCKTYPE_SPIN|LOCKTYPE_RWLOCK);\
dotest(name##_wlock_##nr, FAILURE, LOCKTYPE_RWLOCK); \
dotest(name##_rlock_##nr, SUCCESS, LOCKTYPE_RWLOCK); \
- pr_cont("\n");
+ pr_cont_end(&c);
#define DO_TESTCASE_6(desc, name) \
print_testname(desc); \
@@ -1222,7 +1225,7 @@ static inline void print_testname(const char *testname)
dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
dotest_rt(name##_rtmutex, FAILURE, LOCKTYPE_RTMUTEX); \
- pr_cont("\n");
+ pr_cont_end(&c);
#define DO_TESTCASE_6_SUCCESS(desc, name) \
print_testname(desc); \
@@ -1233,7 +1236,7 @@ static inline void print_testname(const char *testname)
dotest(name##_wsem, SUCCESS, LOCKTYPE_RWSEM); \
dotest(name##_rsem, SUCCESS, LOCKTYPE_RWSEM); \
dotest_rt(name##_rtmutex, SUCCESS, LOCKTYPE_RTMUTEX); \
- pr_cont("\n");
+ pr_cont_end(&c);
/*
* 'read' variant: rlocks must not trigger.
@@ -1247,7 +1250,7 @@ static inline void print_testname(const char *testname)
dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM); \
dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM); \
dotest_rt(name##_rtmutex, FAILURE, LOCKTYPE_RTMUTEX); \
- pr_cont("\n");
+ pr_cont_end(&c);
#define DO_TESTCASE_2I(desc, name, nr) \
DO_TESTCASE_1("hard-"desc, name##_hard, nr); \
@@ -1900,25 +1903,25 @@ static void ww_tests(void)
dotest(ww_test_fail_acquire, SUCCESS, LOCKTYPE_WW);
dotest(ww_test_normal, SUCCESS, LOCKTYPE_WW);
dotest(ww_test_unneeded_slow, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("ww contexts mixing");
dotest(ww_test_two_contexts, FAILURE, LOCKTYPE_WW);
dotest(ww_test_diff_class, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("finishing ww context");
dotest(ww_test_context_done_twice, FAILURE, LOCKTYPE_WW);
dotest(ww_test_context_unlock_twice, FAILURE, LOCKTYPE_WW);
dotest(ww_test_context_fini_early, FAILURE, LOCKTYPE_WW);
dotest(ww_test_context_lock_after_done, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("locking mismatches");
dotest(ww_test_object_unlock_twice, FAILURE, LOCKTYPE_WW);
dotest(ww_test_object_lock_unbalanced, FAILURE, LOCKTYPE_WW);
dotest(ww_test_object_lock_stale_context, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("EDEADLK handling");
dotest(ww_test_edeadlk_normal, SUCCESS, LOCKTYPE_WW);
@@ -1931,11 +1934,11 @@ static void ww_tests(void)
dotest(ww_test_edeadlk_acquire_more_edeadlk_slow, FAILURE, LOCKTYPE_WW);
dotest(ww_test_edeadlk_acquire_wrong, FAILURE, LOCKTYPE_WW);
dotest(ww_test_edeadlk_acquire_wrong_slow, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("spinlock nest unlocked");
dotest(ww_test_spin_nest_unlocked, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
printk(" -----------------------------------------------------\n");
printk(" |block | try |context|\n");
@@ -1945,25 +1948,25 @@ static void ww_tests(void)
dotest(ww_test_context_block, FAILURE, LOCKTYPE_WW);
dotest(ww_test_context_try, SUCCESS, LOCKTYPE_WW);
dotest(ww_test_context_context, SUCCESS, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("try");
dotest(ww_test_try_block, FAILURE, LOCKTYPE_WW);
dotest(ww_test_try_try, SUCCESS, LOCKTYPE_WW);
dotest(ww_test_try_context, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("block");
dotest(ww_test_block_block, FAILURE, LOCKTYPE_WW);
dotest(ww_test_block_try, SUCCESS, LOCKTYPE_WW);
dotest(ww_test_block_context, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("spinlock");
dotest(ww_test_spin_block, FAILURE, LOCKTYPE_WW);
dotest(ww_test_spin_try, SUCCESS, LOCKTYPE_WW);
dotest(ww_test_spin_context, FAILURE, LOCKTYPE_WW);
- pr_cont("\n");
+ pr_cont_end(&c);
}
void locking_selftest(void)
@@ -2003,35 +2006,35 @@ void locking_selftest(void)
printk(" --------------------------------------------------------------------------\n");
print_testname("recursive read-lock");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_AA1, SUCCESS, LOCKTYPE_RWLOCK);
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("recursive read-lock #2");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_AA1B, SUCCESS, LOCKTYPE_RWLOCK);
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("mixed read-write-lock");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_AA2, FAILURE, LOCKTYPE_RWLOCK);
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rsem_AA2, FAILURE, LOCKTYPE_RWSEM);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("mixed write-read-lock");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_AA3, FAILURE, LOCKTYPE_RWLOCK);
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM);
- pr_cont("\n");
+ pr_cont_end(&c);
print_testname("mixed read-lock/lock-write ABBA");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK);
#ifdef CONFIG_PROVE_LOCKING
/*
@@ -2041,19 +2044,19 @@ void locking_selftest(void)
unexpected_testcase_failures--;
#endif
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM);
print_testname("mixed read-lock/lock-read ABBA");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_ABBA2, SUCCESS, LOCKTYPE_RWLOCK);
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rwsem_ABBA2, FAILURE, LOCKTYPE_RWSEM);
print_testname("mixed write-lock/lock-write ABBA");
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rlock_ABBA3, FAILURE, LOCKTYPE_RWLOCK);
- pr_cont(" |");
+ pr_cont_append(&c, " |");
dotest(rwsem_ABBA3, FAILURE, LOCKTYPE_RWSEM);
printk(" --------------------------------------------------------------------------\n");
--
2.20.1
next prev parent reply other threads:[~2020-08-19 23:26 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 23:26 [RFC PATCH 0/5] printk: new log_cont implementation John Ogness
2020-08-19 23:26 ` [RFC PATCH 1/5] printk: implement pr_cont_t John Ogness
2020-08-20 0:33 ` Joe Perches
2020-08-20 7:44 ` David Laight
2020-08-20 7:59 ` Joe Perches
2020-08-20 8:49 ` David Laight
2020-08-20 9:18 ` John Ogness
2020-08-20 16:03 ` Joe Perches
2020-08-20 10:16 ` Petr Mladek
2020-08-20 12:33 ` David Laight
2020-08-25 13:10 ` Petr Mladek
2020-08-25 13:38 ` David Laight
2020-08-25 15:32 ` Petr Mladek
2020-08-24 2:08 ` Sergey Senozhatsky
2020-08-24 5:37 ` Sergey Senozhatsky
2020-08-19 23:26 ` [RFC PATCH 2/5] sysrq: use pr_cont_t for cont messages John Ogness
2020-08-20 1:03 ` Linus Torvalds
2020-08-20 17:48 ` Joe Perches
2020-08-20 17:53 ` Linus Torvalds
2020-08-20 22:11 ` John Ogness
2020-08-20 22:36 ` Joe Perches
2020-08-19 23:26 ` [RFC PATCH 3/5] workqueue: " John Ogness
2020-08-19 23:26 ` John Ogness [this message]
2020-08-19 23:26 ` [RFC PATCH 5/5] lockdep: " John Ogness
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200819232632.13418-5-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).