From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, laijs@cn.fujitsu.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de,
peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com,
edumazet@google.com, darren@dvhart.com, fweisbec@gmail.com,
oleg@redhat.com, sbw@mit.edu,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 20/55] rcutorture: Abstract torture_shutdown_absorb()
Date: Mon, 17 Feb 2014 14:12:24 -0800 [thread overview]
Message-ID: <1392675179-11560-20-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <1392675179-11560-1-git-send-email-paulmck@linux.vnet.ibm.com>
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Because handling races between rmmod and normal shutdown is not specific
to rcutorture, this commit renames rcutorture_shutdown_absorb() to
torture_shutdown_absorb() and pulls it out into then kernel/torture.c
module. This implies pulling the fullstop mechanism into kernel/torture.c
as well.
The exporting of fullstop and fullstop_mutex is ugly and must die.
And it does in fact die in later commits that introduce higher-level
APIs that encapsulate both of these variables.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
include/linux/torture.h | 11 +++++++++++
kernel/rcu/rcutorture.c | 49 ++++++++++++-------------------------------------
kernel/torture.c | 20 ++++++++++++++++++++
3 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/include/linux/torture.h b/include/linux/torture.h
index 8a4088f2f87b..c61b4ce18a13 100644
--- a/include/linux/torture.h
+++ b/include/linux/torture.h
@@ -41,6 +41,14 @@
module_param(name, type, 0444); \
MODULE_PARM_DESC(name, msg);
+/* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
+#define FULLSTOP_DONTSTOP 0 /* Normal operation. */
+#define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */
+#define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */
+extern int fullstop;
+/* Protect fullstop transitions and spawning of kthreads. */
+extern struct mutex fullstop_mutex;
+
#define TORTURE_FLAG "-torture:"
#define TOROUT_STRING(s) \
pr_alert("%s" TORTURE_FLAG s "\n", torture_type)
@@ -57,4 +65,7 @@ struct torture_random_state {
#define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 }
unsigned long torture_random(struct torture_random_state *trsp);
+/* Shutdown task absorption, for when the tasks cannot safely be killed. */
+void torture_shutdown_absorb(const char *title);
+
#endif /* __LINUX_TORTURE_H */
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 2bb3dcb67221..3687619b243a 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -199,17 +199,6 @@ static atomic_t barrier_cbs_invoked; /* Barrier callbacks invoked. */
static wait_queue_head_t *barrier_cbs_wq; /* Coordinate barrier testing. */
static DECLARE_WAIT_QUEUE_HEAD(barrier_wq);
-/* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
-
-#define FULLSTOP_DONTSTOP 0 /* Normal operation. */
-#define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */
-#define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */
-static int fullstop = FULLSTOP_RMMOD;
-/*
- * Protect fullstop transitions and spawning of kthreads.
- */
-static DEFINE_MUTEX(fullstop_mutex);
-
/* Forward reference. */
static void rcu_torture_cleanup(void);
@@ -231,20 +220,6 @@ rcutorture_shutdown_notify(struct notifier_block *unused1,
}
/*
- * Absorb kthreads into a kernel function that won't return, so that
- * they won't ever access module text or data again.
- */
-static void rcutorture_shutdown_absorb(const char *title)
-{
- if (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) {
- pr_notice(
- "rcutorture thread %s parking due to system shutdown\n",
- title);
- schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT);
- }
-}
-
-/*
* Allocate an element from the rcu_tortures pool.
*/
static struct rcu_torture *
@@ -285,7 +260,7 @@ rcu_stutter_wait(const char *title)
schedule_timeout_interruptible(1);
else
schedule_timeout_interruptible(round_jiffies_relative(HZ));
- rcutorture_shutdown_absorb(title);
+ torture_shutdown_absorb(title);
}
}
@@ -680,7 +655,7 @@ checkwait: rcu_stutter_wait("rcu_torture_boost");
/* Clean up and exit. */
VERBOSE_TOROUT_STRING("rcu_torture_boost task stopping");
- rcutorture_shutdown_absorb("rcu_torture_boost");
+ torture_shutdown_absorb("rcu_torture_boost");
while (!kthread_should_stop() || rbi.inflight)
schedule_timeout_uninterruptible(1);
smp_mb(); /* order accesses to ->inflight before stack-frame death. */
@@ -716,7 +691,7 @@ rcu_torture_fqs(void *arg)
rcu_stutter_wait("rcu_torture_fqs");
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_TOROUT_STRING("rcu_torture_fqs task stopping");
- rcutorture_shutdown_absorb("rcu_torture_fqs");
+ torture_shutdown_absorb("rcu_torture_fqs");
while (!kthread_should_stop())
schedule_timeout_uninterruptible(1);
return 0;
@@ -788,7 +763,7 @@ rcu_torture_writer(void *arg)
rcu_stutter_wait("rcu_torture_writer");
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_TOROUT_STRING("rcu_torture_writer task stopping");
- rcutorture_shutdown_absorb("rcu_torture_writer");
+ torture_shutdown_absorb("rcu_torture_writer");
while (!kthread_should_stop())
schedule_timeout_uninterruptible(1);
return 0;
@@ -826,7 +801,7 @@ rcu_torture_fakewriter(void *arg)
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_TOROUT_STRING("rcu_torture_fakewriter task stopping");
- rcutorture_shutdown_absorb("rcu_torture_fakewriter");
+ torture_shutdown_absorb("rcu_torture_fakewriter");
while (!kthread_should_stop())
schedule_timeout_uninterruptible(1);
return 0;
@@ -970,7 +945,7 @@ rcu_torture_reader(void *arg)
rcu_stutter_wait("rcu_torture_reader");
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_TOROUT_STRING("rcu_torture_reader task stopping");
- rcutorture_shutdown_absorb("rcu_torture_reader");
+ torture_shutdown_absorb("rcu_torture_reader");
if (irqreader && cur_ops->irq_capable)
del_timer_sync(&t);
while (!kthread_should_stop())
@@ -1094,7 +1069,7 @@ rcu_torture_stats(void *arg)
do {
schedule_timeout_interruptible(stat_interval * HZ);
rcu_torture_stats_print();
- rcutorture_shutdown_absorb("rcu_torture_stats");
+ torture_shutdown_absorb("rcu_torture_stats");
} while (!kthread_should_stop());
VERBOSE_TOROUT_STRING("rcu_torture_stats task stopping");
return 0;
@@ -1178,7 +1153,7 @@ rcu_torture_shuffle(void *arg)
do {
schedule_timeout_interruptible(shuffle_interval * HZ);
rcu_torture_shuffle_tasks();
- rcutorture_shutdown_absorb("rcu_torture_shuffle");
+ torture_shutdown_absorb("rcu_torture_shuffle");
} while (!kthread_should_stop());
VERBOSE_TOROUT_STRING("rcu_torture_shuffle task stopping");
return 0;
@@ -1197,7 +1172,7 @@ rcu_torture_stutter(void *arg)
if (!kthread_should_stop())
schedule_timeout_interruptible(stutter * HZ);
stutter_pause_test = 0;
- rcutorture_shutdown_absorb("rcu_torture_stutter");
+ torture_shutdown_absorb("rcu_torture_stutter");
} while (!kthread_should_stop());
VERBOSE_TOROUT_STRING("rcu_torture_stutter task stopping");
return 0;
@@ -1469,7 +1444,7 @@ static int rcu_torture_stall(void *args)
rcu_read_unlock();
pr_alert("rcu_torture_stall end.\n");
}
- rcutorture_shutdown_absorb("rcu_torture_stall");
+ torture_shutdown_absorb("rcu_torture_stall");
while (!kthread_should_stop())
schedule_timeout_interruptible(10 * HZ);
return 0;
@@ -1533,7 +1508,7 @@ static int rcu_torture_barrier_cbs(void *arg)
wake_up(&barrier_wq);
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_TOROUT_STRING("rcu_torture_barrier_cbs task stopping");
- rcutorture_shutdown_absorb("rcu_torture_barrier_cbs");
+ torture_shutdown_absorb("rcu_torture_barrier_cbs");
while (!kthread_should_stop())
schedule_timeout_interruptible(1);
cur_ops->cb_barrier();
@@ -1570,7 +1545,7 @@ static int rcu_torture_barrier(void *arg)
schedule_timeout_interruptible(HZ / 10);
} while (!kthread_should_stop() && fullstop == FULLSTOP_DONTSTOP);
VERBOSE_TOROUT_STRING("rcu_torture_barrier task stopping");
- rcutorture_shutdown_absorb("rcu_torture_barrier");
+ torture_shutdown_absorb("rcu_torture_barrier");
while (!kthread_should_stop())
schedule_timeout_interruptible(1);
return 0;
diff --git a/kernel/torture.c b/kernel/torture.c
index c82c70f7828e..f05042036ae8 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -49,6 +49,11 @@
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com>");
+int fullstop = FULLSTOP_RMMOD;
+EXPORT_SYMBOL_GPL(fullstop);
+DEFINE_MUTEX(fullstop_mutex);
+EXPORT_SYMBOL_GPL(fullstop_mutex);
+
#define TORTURE_RANDOM_MULT 39916801 /* prime */
#define TORTURE_RANDOM_ADD 479001701 /* prime */
#define TORTURE_RANDOM_REFRESH 10000
@@ -69,3 +74,18 @@ torture_random(struct torture_random_state *trsp)
return swahw32(trsp->trs_state);
}
EXPORT_SYMBOL_GPL(torture_random);
+
+/*
+ * Absorb kthreads into a kernel function that won't return, so that
+ * they won't ever access module text or data again.
+ */
+void torture_shutdown_absorb(const char *title)
+{
+ while (ACCESS_ONCE(fullstop) == FULLSTOP_SHUTDOWN) {
+ pr_notice(
+ "torture thread %s parking due to system shutdown\n",
+ title);
+ schedule_timeout_uninterruptible(MAX_SCHEDULE_TIMEOUT);
+ }
+}
+EXPORT_SYMBOL_GPL(torture_shutdown_absorb);
--
1.8.1.5
next prev parent reply other threads:[~2014-02-17 22:23 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 22:12 [PATCH tip/core/rcu 0/55] Torture-test changes for 3.15 Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 01/55] rcutorture: Print grace-period performance statistics Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 02/55] rcutorture: Print script and arguments to standard output Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 03/55] rcutorture: Move common boot flags to kvm-test-1-rcu.sh Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 04/55] rcutorture: Allow kvm-test-1-rcu.sh to pause after build Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 05/55] rcutorture: Move common qemu flags to kvm-test-1.sh Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 06/55] rcutorture: Reduce SRCU-N number of CPUs Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 07/55] rcutorture: Enable concurrent rcutorture runs Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 08/55] rcutorture: Fix results-directory error message Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 09/55] rcutorture: Add dryrun capability Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 10/55] rcutorture: Handle multiple runs of the same test Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 11/55] rcutorture: Do better bin packing Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 12/55] rcutorture: Add comments, especially on " Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 13/55] rcutorture: Flag tests requiring more CPUs than are available Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 14/55] rcutorture: Print results directory when dumping results Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 15/55] rcutorture: Abstract rcu_torture_random() Paul E. McKenney
2014-02-18 0:11 ` Josh Triplett
2014-02-18 0:22 ` Paul E. McKenney
2014-02-18 0:27 ` Josh Triplett
2014-02-18 21:33 ` Paul E. McKenney
2014-02-19 2:52 ` George Spelvin
2014-02-17 22:12 ` [PATCH tip/core/rcu 16/55] rcutorture: Don't create results directory for dryruns Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 17/55] rcutorture: Abstract torture_param() Paul E. McKenney
2014-02-18 0:23 ` Josh Triplett
2014-02-18 21:31 ` Paul E. McKenney
2014-02-18 23:53 ` josh
2014-02-23 16:48 ` Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 18/55] rcutorture: Rename PRINTK to TOROUT Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 19/55] rcutorture: Abstract TOROUT_STRING() and friends Paul E. McKenney
2014-02-18 0:26 ` Josh Triplett
2014-02-18 0:58 ` Paul E. McKenney
2014-02-18 1:23 ` Josh Triplett
2014-02-18 1:43 ` Paul E. McKenney
2014-02-18 3:36 ` Josh Triplett
2014-02-17 22:12 ` Paul E. McKenney [this message]
2014-02-17 22:12 ` [PATCH tip/core/rcu 21/55] rcutorture: Export torture_type and verbose module parameters Paul E. McKenney
2014-02-18 0:29 ` Josh Triplett
2014-02-18 1:01 ` Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 22/55] rcutorture: Abstract torture_shuffle() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 23/55] rcutorture: Abstract torture_onoff() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 24/55] rcutorture: Abstract torture-test initialization Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 25/55] rcutorture: Abstract torture-test cleanup Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 26/55] rcutorture: Print dates when doing parallel rcutorture runs Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 27/55] rcutorture: Abstract torture_shutdown_notify() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 28/55] rcutorture: Privatize fullstop Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 29/55] rcutorture: Add diagnostic for unscheduled system shutdown Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 30/55] rcutorture: Abstract stutter_wait() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 31/55] rcutorture: Apply ACCESS_ONCE() to racy fullstop accesses Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 32/55] rcutorture: Abstract torture_shutdown() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 33/55] rcutorture: Clean up rcu_torture_init() error checking Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 34/55] rcutorture: Announce task creation Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 35/55] rcutorture: Fix rcutorture shutdown races Paul E. McKenney
2014-02-18 0:32 ` Josh Triplett
2014-02-18 21:35 ` Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 36/55] rcutorture: Fix missing-return bug in rcu_torture_barrier_init() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 37/55] rcutorture: Abstract torture_create_kthread() Paul E. McKenney
2014-02-18 0:34 ` Josh Triplett
2014-02-18 21:36 ` Paul E. McKenney
2014-02-19 0:02 ` josh
2014-02-17 22:12 ` [PATCH tip/core/rcu 38/55] rcutorture: Abstract torture_stop_kthread() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 39/55] rcutorture: Stop generic kthreads in torture_cleanup() Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 40/55] rcutorture: Remove redundant module-alias directives Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 41/55] rcutorture: Abstract kvm-recheck.sh Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 42/55] locktorture: Add a lock-torture kernel module Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 43/55] rcutorture: Add an rcu_busted to test the test Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 44/55] rcutorture: Create config files for scripted test-the-test testing Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 45/55] rcutorture: Create CFcommon file for common Kconfig parameters Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 46/55] rcutorture: Remove RCU dependencies from ver_functions.sh API Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 47/55] rcutorture: Rename kvm-test-1-rcu.sh Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 48/55] rcutorture: Introduce "rcu" directory level underneath configs Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 49/55] locktorture: Add vestigial locktorture configuration Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 50/55] rcutorture: Gracefully handle NULL cleanup hooks Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 51/55] locktorture: Add kvm-recheck.sh plug-in for locktorture Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 52/55] rcutorture: Rename TREE_RCU-Kconfig.txt Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 53/55] rcutorture: Place kvm-test-1-run.sh output into res directory Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 54/55] rcutorture: Add a lock_busted to test the test Paul E. McKenney
2014-02-17 22:12 ` [PATCH tip/core/rcu 55/55] rcutorture: Save kvm.sh output to log Paul E. McKenney
2014-02-18 0:41 ` [PATCH tip/core/rcu 0/55] Torture-test changes for 3.15 Josh Triplett
2014-02-18 0:48 ` Josh Triplett
2014-02-18 1:18 ` Paul E. McKenney
2014-02-18 1:18 ` Paul E. McKenney
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=1392675179-11560-20-git-send-email-paulmck@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=darren@dvhart.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=niv@us.ibm.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sbw@mit.edu \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®