History

torture: Maintain torture-specific set of CPUs-online books

The TREE01 rcutorture scenario intentionally creates confusion as to the number of available CPUs by specifying the "maxcpus=8 nr_cpus=43" kernel boot parameters. This can disable rcutorture's load shedding, which currently uses num_online_cpus(), which would count the extra 35 CPUs. However, the rcutorture guest OS will be provisioned with only 8 CPUs, which means that rcutorture will present full load even when all but one of the original 8 CPUs are offline. This can result in spurious errors due to extreme overloading of that single remaining CPU. This commit therefore keeps a separate set of books on the number of usable online CPUs, so that torture_num_online_cpus() is used for load shedding instead of num_online_cpus(). Note that initial sizing must use num_online_cpus() because torture_num_online_cpus() will return NR_CPUS until shortly after torture_onoff_init() is invoked.

Paul E. McKenney committed 5 years ago

Commit 1afb95f1 parent 0b962c83 files · +23 −2Browse files

Unified · Split

3 files
  1. include/linux/torture.h +5 −0
  2. kernel/rcu/rcutorture.c +2 −2
  3. kernel/torture.c +16 −0
include/linux/torture.h+5−0
@@ -48,6 +48,11 @@ do { \ · 47 unmodified lines
48void verbose_torout_sleep(void);48void verbose_torout_sleep(void);
49 49
50/* Definitions for online/offline exerciser. */50/* Definitions for online/offline exerciser. */
51#ifdef CONFIG_HOTPLUG_CPU
52int torture_num_online_cpus(void);
53#else /* #ifdef CONFIG_HOTPLUG_CPU */
54static inline int torture_num_online_cpus(void) { return 1; }
55#endif /* #else #ifdef CONFIG_HOTPLUG_CPU */
51typedef void torture_ofl_func(void);56typedef void torture_ofl_func(void);
52bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes,57bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes,
53 unsigned long *sum_offl, int *min_onl, int *max_onl);58 unsigned long *sum_offl, int *min_onl, int *max_onl);
kernel/rcu/rcutorture.c+2−2
@@ -1338,7 +1338,7 @@ static void rcu_torture_reader_do_mbchk(long myid, struct rcu_torture *rtp, · 1337 unmodified lines
1338 struct torture_random_state *trsp)1338 struct torture_random_state *trsp)
1339{1339{
1340 unsigned long loops;1340 unsigned long loops;
1341 int noc = num_online_cpus();1341 int noc = torture_num_online_cpus();
1342 int rdrchked;1342 int rdrchked;
1343 int rdrchker;1343 int rdrchker;
1344 struct rcu_torture_reader_check *rtrcp; // Me.1344 struct rcu_torture_reader_check *rtrcp; // Me.
@@ -1658,7 +1658,7 @@ rcu_torture_reader(void *arg) · 313 unmodified lines
1658 torture_hrtimeout_us(500, 1000, &rand);1658 torture_hrtimeout_us(500, 1000, &rand);
1659 lastsleep = jiffies + 10;1659 lastsleep = jiffies + 10;
1660 }1660 }
1661 while (num_online_cpus() < mynumonline && !torture_must_stop())1661 while (torture_num_online_cpus() < mynumonline && !torture_must_stop())
1662 schedule_timeout_interruptible(HZ / 5);1662 schedule_timeout_interruptible(HZ / 5);
1663 stutter_wait("rcu_torture_reader");1663 stutter_wait("rcu_torture_reader");
1664 } while (!torture_must_stop());1664 } while (!torture_must_stop());
kernel/torture.c+16−0
@@ -175,6 +175,19 @@ static unsigned long sum_online; · 174 unmodified lines
175static int min_online = -1;175static int min_online = -1;
176static int max_online;176static int max_online;
177 177
178static int torture_online_cpus = NR_CPUS;
179
180/*
181 * Some torture testing leverages confusion as to the number of online
182 * CPUs. This function returns the torture-testing view of this number,
183 * which allows torture tests to load-balance appropriately.
184 */
185int torture_num_online_cpus(void)
186{
187 return READ_ONCE(torture_online_cpus);
188}
189EXPORT_SYMBOL_GPL(torture_num_online_cpus);
190
178/*191/*
179 * Attempt to take a CPU offline. Return false if the CPU is already192 * Attempt to take a CPU offline. Return false if the CPU is already
180 * offline or if it is not subject to CPU-hotplug operations. The193 * offline or if it is not subject to CPU-hotplug operations. The
@@ -229,6 +242,8 @@ bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, · 48 unmodified lines
229 *min_offl = delta;242 *min_offl = delta;
230 if (*max_offl < delta)243 if (*max_offl < delta)
231 *max_offl = delta;244 *max_offl = delta;
245 WRITE_ONCE(torture_online_cpus, torture_online_cpus - 1);
246 WARN_ON_ONCE(torture_online_cpus <= 0);
232 }247 }
233 248
234 return true;249 return true;
@@ -285,6 +300,7 @@ bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, · 50 unmodified lines
285 *min_onl = delta;300 *min_onl = delta;
286 if (*max_onl < delta)301 if (*max_onl < delta)
287 *max_onl = delta;302 *max_onl = delta;
303 WRITE_ONCE(torture_online_cpus, torture_online_cpus + 1);
288 }304 }
289 305
290 return true;306 return true;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t