Commit d95f5ba9 authored by Paul E. McKenney's avatar Paul E. McKenney

torture: Break online and offline functions out of torture_onoff()

This commit breaks torture_online() and torture_offline() out of
torture_onoff() in preparation for allowing waketorture finer-grained
control of its CPU-hotplug workload.
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent 6e8c66c8
...@@ -50,6 +50,10 @@ ...@@ -50,6 +50,10 @@
do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0) do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0)
/* Definitions for online/offline exerciser. */ /* Definitions for online/offline exerciser. */
bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes,
unsigned long *sum_offl, int *min_onl, int *max_onl);
bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes,
unsigned long *sum_onl, int *min_onl, int *max_onl);
int torture_onoff_init(long ooholdoff, long oointerval); int torture_onoff_init(long ooholdoff, long oointerval);
void torture_onoff_stats(void); void torture_onoff_stats(void);
bool torture_onoff_failures(void); bool torture_onoff_failures(void);
......
...@@ -82,37 +82,26 @@ static int min_online = -1; ...@@ -82,37 +82,26 @@ static int min_online = -1;
static int max_online; static int max_online;
/* /*
* Execute random CPU-hotplug operations at the interval specified * Attempt to take a CPU offline. Return false if the CPU is already
* by the onoff_interval. * offline or if it is not subject to CPU-hotplug operations. The
* caller can detect other failures by looking at the statistics.
*/ */
static int bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes,
torture_onoff(void *arg) unsigned long *sum_offl, int *min_offl, int *max_offl)
{ {
int cpu;
unsigned long delta; unsigned long delta;
int maxcpu = -1;
DEFINE_TORTURE_RANDOM(rand);
int ret; int ret;
unsigned long starttime; unsigned long starttime;
VERBOSE_TOROUT_STRING("torture_onoff task started"); if (!cpu_online(cpu) || !cpu_is_hotpluggable(cpu))
for_each_online_cpu(cpu) return false;
maxcpu = cpu;
WARN_ON(maxcpu < 0);
if (onoff_holdoff > 0) {
VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
schedule_timeout_interruptible(onoff_holdoff);
VERBOSE_TOROUT_STRING("torture_onoff end holdoff");
}
while (!torture_must_stop()) {
cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
if (cpu_online(cpu) && cpu_is_hotpluggable(cpu)) {
if (verbose) if (verbose)
pr_alert("%s" TORTURE_FLAG pr_alert("%s" TORTURE_FLAG
"torture_onoff task: offlining %d\n", "torture_onoff task: offlining %d\n",
torture_type, cpu); torture_type, cpu);
starttime = jiffies; starttime = jiffies;
n_offline_attempts++; (*n_offl_attempts)++;
ret = cpu_down(cpu); ret = cpu_down(cpu);
if (ret) { if (ret) {
if (verbose) if (verbose)
...@@ -124,25 +113,44 @@ torture_onoff(void *arg) ...@@ -124,25 +113,44 @@ torture_onoff(void *arg)
pr_alert("%s" TORTURE_FLAG pr_alert("%s" TORTURE_FLAG
"torture_onoff task: offlined %d\n", "torture_onoff task: offlined %d\n",
torture_type, cpu); torture_type, cpu);
n_offline_successes++; (*n_offl_successes)++;
delta = jiffies - starttime; delta = jiffies - starttime;
sum_offline += delta; sum_offl += delta;
if (min_offline < 0) { if (*min_offl < 0) {
min_offline = delta; *min_offl = delta;
max_offline = delta; *max_offl = delta;
} }
if (min_offline > delta) if (*min_offl > delta)
min_offline = delta; *min_offl = delta;
if (max_offline < delta) if (*max_offl < delta)
max_offline = delta; *max_offl = delta;
} }
} else if (cpu_is_hotpluggable(cpu)) {
return true;
}
EXPORT_SYMBOL_GPL(torture_offline);
/*
* Attempt to bring a CPU online. Return false if the CPU is already
* online or if it is not subject to CPU-hotplug operations. The
* caller can detect other failures by looking at the statistics.
*/
bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes,
unsigned long *sum_onl, int *min_onl, int *max_onl)
{
unsigned long delta;
int ret;
unsigned long starttime;
if (cpu_online(cpu) || !cpu_is_hotpluggable(cpu))
return false;
if (verbose) if (verbose)
pr_alert("%s" TORTURE_FLAG pr_alert("%s" TORTURE_FLAG
"torture_onoff task: onlining %d\n", "torture_onoff task: onlining %d\n",
torture_type, cpu); torture_type, cpu);
starttime = jiffies; starttime = jiffies;
n_online_attempts++; (*n_onl_attempts)++;
ret = cpu_up(cpu); ret = cpu_up(cpu);
if (ret) { if (ret) {
if (verbose) if (verbose)
...@@ -154,19 +162,51 @@ torture_onoff(void *arg) ...@@ -154,19 +162,51 @@ torture_onoff(void *arg)
pr_alert("%s" TORTURE_FLAG pr_alert("%s" TORTURE_FLAG
"torture_onoff task: onlined %d\n", "torture_onoff task: onlined %d\n",
torture_type, cpu); torture_type, cpu);
n_online_successes++; (*n_onl_successes)++;
delta = jiffies - starttime; delta = jiffies - starttime;
sum_online += delta; *sum_onl += delta;
if (min_online < 0) { if (*min_onl < 0) {
min_online = delta; *min_onl = delta;
max_online = delta; *max_onl = delta;
} }
if (min_online > delta) if (*min_onl > delta)
min_online = delta; *min_onl = delta;
if (max_online < delta) if (*max_onl < delta)
max_online = delta; *max_onl = delta;
} }
return true;
}
EXPORT_SYMBOL_GPL(torture_online);
/*
* Execute random CPU-hotplug operations at the interval specified
* by the onoff_interval.
*/
static int
torture_onoff(void *arg)
{
int cpu;
int maxcpu = -1;
DEFINE_TORTURE_RANDOM(rand);
VERBOSE_TOROUT_STRING("torture_onoff task started");
for_each_online_cpu(cpu)
maxcpu = cpu;
WARN_ON(maxcpu < 0);
if (onoff_holdoff > 0) {
VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
schedule_timeout_interruptible(onoff_holdoff);
VERBOSE_TOROUT_STRING("torture_onoff end holdoff");
} }
while (!torture_must_stop()) {
cpu = (torture_random(&rand) >> 4) % (maxcpu + 1);
if (!torture_offline(cpu,
&n_offline_attempts, &n_offline_successes,
&sum_offline, &min_offline, &max_offline))
torture_online(cpu,
&n_online_attempts, &n_online_successes,
&sum_online, &min_online, &max_online);
schedule_timeout_interruptible(onoff_interval); schedule_timeout_interruptible(onoff_interval);
} }
torture_kthread_stopping("torture_onoff"); torture_kthread_stopping("torture_onoff");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment