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.
Showing the changes to kernel (2 of 3 files). Show all
Unified · Split
| @@ -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()); |
| @@ -175,6 +175,19 @@ static unsigned long sum_online; · 174 unmodified lines | |||
| 175 | static int min_online = -1; | 175 | static int min_online = -1; |
| 176 | static int max_online; | 176 | static int max_online; |
| 177 | 177 | ||
| 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 | |||
| 178 | /* | 191 | /* |
| 179 | * Attempt to take a CPU offline. Return false if the CPU is already | 192 | * 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. The | 193 | * 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; |