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
4848 void verbose_torout_sleep(void);
4949
5050 /* Definitions for online/offline exerciser. */
51+#ifdef CONFIG_HOTPLUG_CPU
52+int torture_num_online_cpus(void);
53+#else /* #ifdef CONFIG_HOTPLUG_CPU */
54+static inline int torture_num_online_cpus(void) { return 1; }
55+#endif /* #else #ifdef CONFIG_HOTPLUG_CPU */
5156 typedef void torture_ofl_func(void);
5257 bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes,
5358 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
13381338 struct torture_random_state *trsp)
13391339 {
13401340 unsigned long loops;
1341− int noc = num_online_cpus();
1341+ int noc = torture_num_online_cpus();
13421342 int rdrchked;
13431343 int rdrchker;
13441344 struct rcu_torture_reader_check *rtrcp; // Me.
@@ -1658,7 +1658,7 @@ rcu_torture_reader(void *arg) · 313 unmodified lines
16581658 torture_hrtimeout_us(500, 1000, &rand);
16591659 lastsleep = jiffies + 10;
16601660 }
1661− while (num_online_cpus() < mynumonline && !torture_must_stop())
1661+ while (torture_num_online_cpus() < mynumonline && !torture_must_stop())
16621662 schedule_timeout_interruptible(HZ / 5);
16631663 stutter_wait("rcu_torture_reader");
16641664 } while (!torture_must_stop());
kernel/torture.c+16−0
@@ -175,6 +175,19 @@ static unsigned long sum_online; · 174 unmodified lines
175175 static int min_online = -1;
176176 static int max_online;
177177
178+static 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+ */
185+int torture_num_online_cpus(void)
186+{
187+ return READ_ONCE(torture_online_cpus);
188+}
189+EXPORT_SYMBOL_GPL(torture_num_online_cpus);
190+
178191 /*
179192 * Attempt to take a CPU offline. Return false if the CPU is already
180193 * 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
229242 *min_offl = delta;
230243 if (*max_offl < delta)
231244 *max_offl = delta;
245+ WRITE_ONCE(torture_online_cpus, torture_online_cpus - 1);
246+ WARN_ON_ONCE(torture_online_cpus <= 0);
232247 }
233248
234249 return true;
@@ -285,6 +300,7 @@ bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, · 50 unmodified lines
285300 *min_onl = delta;
286301 if (*max_onl < delta)
287302 *max_onl = delta;
303+ WRITE_ONCE(torture_online_cpus, torture_online_cpus + 1);
288304 }
289305
290306 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