torture.c (0b962c8fe0e5c72a252b236814a6b6e9df799061) | torture.c (1afb95fee0342b8d9e05b0433e8e44a6dfd7c4a3) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Common functions for in-kernel torture tests. 4 * 5 * Copyright (C) IBM Corporation, 2014 6 * 7 * Author: Paul E. McKenney <paulmck@linux.ibm.com> 8 * Based on kernel/rcu/torture.c. --- 161 unchanged lines hidden (view full) --- 170static int min_offline = -1; 171static int max_offline; 172static long n_online_attempts; 173static long n_online_successes; 174static unsigned long sum_online; 175static int min_online = -1; 176static int max_online; 177 | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Common functions for in-kernel torture tests. 4 * 5 * Copyright (C) IBM Corporation, 2014 6 * 7 * Author: Paul E. McKenney <paulmck@linux.ibm.com> 8 * Based on kernel/rcu/torture.c. --- 161 unchanged lines hidden (view full) --- 170static int min_offline = -1; 171static int max_offline; 172static long n_online_attempts; 173static long n_online_successes; 174static unsigned long sum_online; 175static int min_online = -1; 176static int max_online; 177 |
178static int torture_online_cpus = NR_CPUS; 179 |
|
178/* | 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 191/* |
|
179 * 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 181 * caller can detect other failures by looking at the statistics. 182 */ 183bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, 184 unsigned long *sum_offl, int *min_offl, int *max_offl) 185{ 186 unsigned long delta; --- 37 unchanged lines hidden (view full) --- 224 if (*min_offl < 0) { 225 *min_offl = delta; 226 *max_offl = delta; 227 } 228 if (*min_offl > delta) 229 *min_offl = delta; 230 if (*max_offl < delta) 231 *max_offl = delta; | 192 * Attempt to take a CPU offline. Return false if the CPU is already 193 * offline or if it is not subject to CPU-hotplug operations. The 194 * caller can detect other failures by looking at the statistics. 195 */ 196bool torture_offline(int cpu, long *n_offl_attempts, long *n_offl_successes, 197 unsigned long *sum_offl, int *min_offl, int *max_offl) 198{ 199 unsigned long delta; --- 37 unchanged lines hidden (view full) --- 237 if (*min_offl < 0) { 238 *min_offl = delta; 239 *max_offl = delta; 240 } 241 if (*min_offl > delta) 242 *min_offl = delta; 243 if (*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 } 233 234 return true; 235} 236EXPORT_SYMBOL_GPL(torture_offline); 237 238/* 239 * Attempt to bring a CPU online. Return false if the CPU is already --- 40 unchanged lines hidden (view full) --- 280 if (*min_onl < 0) { 281 *min_onl = delta; 282 *max_onl = delta; 283 } 284 if (*min_onl > delta) 285 *min_onl = delta; 286 if (*max_onl < delta) 287 *max_onl = delta; | 247 } 248 249 return true; 250} 251EXPORT_SYMBOL_GPL(torture_offline); 252 253/* 254 * Attempt to bring a CPU online. Return false if the CPU is already --- 40 unchanged lines hidden (view full) --- 295 if (*min_onl < 0) { 296 *min_onl = delta; 297 *max_onl = delta; 298 } 299 if (*min_onl > delta) 300 *min_onl = delta; 301 if (*max_onl < delta) 302 *max_onl = delta; |
303 WRITE_ONCE(torture_online_cpus, torture_online_cpus + 1); |
|
288 } 289 290 return true; 291} 292EXPORT_SYMBOL_GPL(torture_online); 293 294/* 295 * Get everything online at the beginning and ends of tests. --- 645 unchanged lines hidden --- | 304 } 305 306 return true; 307} 308EXPORT_SYMBOL_GPL(torture_online); 309 310/* 311 * Get everything online at the beginning and ends of tests. --- 645 unchanged lines hidden --- |