torture: Convert torture_shutdown() to hrtimer
Upcoming changes to the timer wheel introduce significant inaccuracy and possibly also an ultimate limit on timeout duration. This is a problem for the current implementation of torture_shutdown() because (1) shutdown times are user-specified, and can therefore be quite long, and (2) the torture scripting will kill a test instance that runs for more than a few minutes longer than scheduled. This commit therefore converts the torture_shutdown() timed waits to an hrtimer, thus avoiding too-short torture test runs as well as death by scripting. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
parent
29b4817d40
commit
31257c3c8b
@ -43,6 +43,7 @@
|
|||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/trace_clock.h>
|
#include <linux/trace_clock.h>
|
||||||
|
#include <linux/ktime.h>
|
||||||
#include <asm/byteorder.h>
|
#include <asm/byteorder.h>
|
||||||
#include <linux/torture.h>
|
#include <linux/torture.h>
|
||||||
|
|
||||||
@ -446,9 +447,8 @@ EXPORT_SYMBOL_GPL(torture_shuffle_cleanup);
|
|||||||
* Variables for auto-shutdown. This allows "lights out" torture runs
|
* Variables for auto-shutdown. This allows "lights out" torture runs
|
||||||
* to be fully scripted.
|
* to be fully scripted.
|
||||||
*/
|
*/
|
||||||
static int shutdown_secs; /* desired test duration in seconds. */
|
|
||||||
static struct task_struct *shutdown_task;
|
static struct task_struct *shutdown_task;
|
||||||
static unsigned long shutdown_time; /* jiffies to system shutdown. */
|
static ktime_t shutdown_time; /* time to system shutdown. */
|
||||||
static void (*torture_shutdown_hook)(void);
|
static void (*torture_shutdown_hook)(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -471,20 +471,20 @@ EXPORT_SYMBOL_GPL(torture_shutdown_absorb);
|
|||||||
*/
|
*/
|
||||||
static int torture_shutdown(void *arg)
|
static int torture_shutdown(void *arg)
|
||||||
{
|
{
|
||||||
long delta;
|
ktime_t ktime_snap;
|
||||||
unsigned long jiffies_snap;
|
|
||||||
|
|
||||||
VERBOSE_TOROUT_STRING("torture_shutdown task started");
|
VERBOSE_TOROUT_STRING("torture_shutdown task started");
|
||||||
jiffies_snap = jiffies;
|
ktime_snap = ktime_get();
|
||||||
while (ULONG_CMP_LT(jiffies_snap, shutdown_time) &&
|
while (ktime_before(ktime_snap, shutdown_time) &&
|
||||||
!torture_must_stop()) {
|
!torture_must_stop()) {
|
||||||
delta = shutdown_time - jiffies_snap;
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
pr_alert("%s" TORTURE_FLAG
|
pr_alert("%s" TORTURE_FLAG
|
||||||
"torture_shutdown task: %lu jiffies remaining\n",
|
"torture_shutdown task: %llu ms remaining\n",
|
||||||
torture_type, delta);
|
torture_type,
|
||||||
schedule_timeout_interruptible(delta);
|
ktime_ms_delta(shutdown_time, ktime_snap));
|
||||||
jiffies_snap = jiffies;
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
|
schedule_hrtimeout(&shutdown_time, HRTIMER_MODE_ABS);
|
||||||
|
ktime_snap = ktime_get();
|
||||||
}
|
}
|
||||||
if (torture_must_stop()) {
|
if (torture_must_stop()) {
|
||||||
torture_kthread_stopping("torture_shutdown");
|
torture_kthread_stopping("torture_shutdown");
|
||||||
@ -511,10 +511,9 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
shutdown_secs = ssecs;
|
|
||||||
torture_shutdown_hook = cleanup;
|
torture_shutdown_hook = cleanup;
|
||||||
if (shutdown_secs > 0) {
|
if (ssecs > 0) {
|
||||||
shutdown_time = jiffies + shutdown_secs * HZ;
|
shutdown_time = ktime_add(ktime_get(), ktime_set(ssecs, 0));
|
||||||
ret = torture_create_kthread(torture_shutdown, NULL,
|
ret = torture_create_kthread(torture_shutdown, NULL,
|
||||||
shutdown_task);
|
shutdown_task);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user