summaryrefslogtreecommitdiffstats
path: root/kernel/scftorture.c
Commit message (Collapse)AuthorAgeFilesLines
* scftorture: Pause testing after memory-allocation failurePaul E. McKenney2023-07-141-1/+5
| | | | | | | | | | | The scftorture test can quickly execute a large number of calls to no-wait smp_call_function(), each of which holds a block of memory until the corresponding handler is invoked. Especially when the longwait module parameter is specified, this can chew up an arbitrarily large amount of memory. This commit therefore blocks after each memory-allocation failure, with the duration a function of longwait. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Forgive memory-allocation failure if KASANPaul E. McKenney2023-07-141-2/+4
| | | | | | | | | | | Kernels built with CONFIG_KASAN=y quarantine newly freed memory in order to better detect use-after-free errors. However, this can exhaust memory more quickly in allocator-heavy tests, which can result in spurious scftorture failure. This commit therefore forgives memory-allocation failure in kernels built with CONFIG_KASAN=y, but continues counting the errors for use in detailed test-result analyses. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Fix distribution of short handler delaysPaul E. McKenney2022-04-111-2/+3
| | | | | | | | | | | | | | | The scftorture test module's scf_handler() function is supposed to provide three different distributions of short delays (including "no delay") and one distribution of long delays, if specified by the scftorture.longwait module parameter. However, the second of the two non-zero-wait short delays is disabled due to the first such delay's "goto out" not being enclosed in the "then" clause with the "udelay()". This commit therefore adjusts the code to provide the intended set of delays. Fixes: e9d338a0b179 ("scftorture: Add smp_call_function() torture test") Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Always log error messageLi Zhijian2021-12-071-5/+4
| | | | | | | | Unconditionally log messages corresponding to errors. Acked-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: Li Zhijian <zhijianx.li@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Remove unused SCFTORTOUTLi Zhijian2021-12-071-3/+0
| | | | | | | | There are no longer any users of SCFTORTOUT(), so this commit removes it. Acked-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: Li Zhijian <zhijianx.li@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add missing '\n' to flush messageLi Zhijian2021-12-071-3/+3
| | | | | | | | Add '\n' to macros to flush message for each call. Acked-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: Li Zhijian <zhijianx.li@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Warn on individual scf_torture_init() error conditionsPaul E. McKenney2021-09-161-5/+5
| | | | | | | | | | | When running scftorture as a module, any scf_torture_init() issues will be reflected in the error code from modprobe or insmod, as the case may be. However, these error codes are not available when running scftorture built-in, for example, when using the kvm.sh script. This commit therefore adds WARN_ON_ONCE() to allow distinguishing scf_torture_init() errors when running scftorture built-in. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Count reschedule IPIsPaul E. McKenney2021-09-161-0/+1
| | | | | | | | | | | | Currently, only those IPIs that invoke scftorture's scf_handler() IPI handler function are counted. This means that runs exercising only scftorture.weight_resched will look like they have made no forward progress, resulting in "GP HANG" complaints from the rcutorture scripting. This commit therefore increments the scf_invoked_count per-CPU counter immediately after calling resched_cpu(). Fixes: 1ac78b49d61d4 ("scftorture: Add an alternative IPI vector") Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Account for weight_resched when checking for all zeroesPaul E. McKenney2021-09-161-2/+2
| | | | | | | | | The "all zero weights makes no sense" error is emitted even when scftorture.weight_resched is non-zero because it was left out of the enclosing "if" condition. This commit adds it in. Fixes: 1ac78b49d61d4 ("scftorture: Add an alternative IPI vector") Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Shut down if nonsensical arguments givenPaul E. McKenney2021-09-161-0/+4
| | | | | | | | | | If (say) a 10-hour scftorture run is started, but the module parameters are so nonsensical that the run doesn't even start, then scftorture will wait the full ten hours when run built into a guest OS. This commit therefore shuts down the system in this case so that the error is reported immediately instead of ten hours hence. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Allow zero weight to exclude an smp_call_function*() categoryPaul E. McKenney2021-09-161-12/+12
| | | | | | | | | | | This commit reworks the weighting calculations to allow zero to be specified to disable a given weight. For example, specifying the scftorture.weight_resched=0 kernel boot parameter without specifying a non-zero value for any of the other scftorture.weight_* parameters would provide the default weights for the others, but would refrain from doing any resched-based IPIs. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Avoid NULL pointer exception on early exitPaul E. McKenney2021-07-271-1/+1
| | | | | | | | | | | | When scftorture finds an error in the module parameters controlling the relative frequencies of smp_call_function*() variants, it takes an early exit. So early that it has not allocated memory to track the kthreads running the test, which results in a segfault. This commit therefore checks for the existence of the memory before attempting to stop the kthreads that would otherwise have been recorded in that non-existent memory. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add RPC-like IPI testsPaul E. McKenney2021-07-271-13/+63
| | | | | | | | | | This commit adds the single_weight_rpc module parameter, which causes the IPI handler to awaken the IPI sender. In many scheduler configurations, this will result in an IPI back to the sender that is likely to be received at a time when the sender CPU is idle. The intent is to stress IPI reception during CPU busy-to-idle transitions. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Avoid false-positive warnings in scftorture_invoker()Paul E. McKenney2021-07-061-3/+3
| | | | | | | | | | | | | | | | | | | | If the call to set_cpus_allowed_ptr() in scftorture_invoker() fails, a later WARN_ONCE() complains. But with the advent of 570a752b7a9b ("lib/smp_processor_id: Use is_percpu_thread() instead of nr_cpus_allowed"), this complaint can be drowned out by complaints from smp_processor_id(). The rationale for this change is that scftorture's kthreads are not marked with PF_NO_SETAFFINITY, which means that a system administrator could change affinity at any time. However, scftorture is a torture test, and the system administrator might well have a valid test-the-test reason for changing affinity. This commit therefore changes to raw_smp_processor_id() in order to avoid the noise, and also adds a WARN_ON_ONCE() to the call to set_cpus_allowed_ptr() in order to directly detect immediate failure. There is no WARN_ON_ONCE() within the test loop, allowing human-reflex-based affinity resetting, if desired. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add debug output for wrong-CPU warningPaul E. McKenney2021-01-041-1/+5
| | | | | | | | This commit adds the desired CPU, the actual CPU, and nr_cpu_ids to the wrong-CPU warning in scftorture_invoker(), the better to help with debugging. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add full-test stutter capabilityPaul E. McKenney2020-11-061-3/+9
| | | | | | | | | | In virtual environments on systems with hardware assist, inter-processor interrupts must do very different things based on whether the target vCPU is running or not. This commit therefore enables torture-test stuttering to better test these running/not-running transitions. Suggested-by: Chris Mason <clm@fb.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add an alternative IPI vectorPaul E. McKenney2020-11-061-9/+32
| | | | | | | | | | | | | The scftorture tests currently use only smp_call_function() and friends, which means that these tests cannot locate bugs caused by interactions between different IPI vectors. This commit therefore adds the rescheduling IPI to the mix. Note that this commit permits resched_cpus() only when scftorture is built in. This is a workaround. Longer term, this will use real wakeups rather than resched_cpu(). Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add cond_resched() to test loopPaul E. McKenney2020-08-241-0/+1
| | | | | | | | | | Although the test loop does randomly delay, which would provide quiescent states and so forth, it is possible for there to be a series of long smp_call_function*() handler runtimes with no delays, which results in softlockup and RCU CPU stall warning messages. This commit therefore inserts a cond_resched() into the main test loop. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Adapt memory-ordering test to UP operationPaul E. McKenney2020-08-241-1/+2
| | | | | | | | On uniprocessor systems, smp_call_function() does nothing. This commit therefore avoids complaining about the lack of handler accesses in the single-CPU case where there is no handler. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Block scftorture_invoker() kthreads for offline CPUsPaul E. McKenney2020-08-241-1/+12
| | | | | | | | | | | Currently, CPU-hotplug operations might result in all but two of (say) 100 CPUs being offline, which in turn might result in false-positive diagnostics due to overload. This commit therefore causes scftorture_invoker() kthreads for offline CPUs to loop blocking for 200 milliseconds at a time, thus continuously adjusting the number of threads to match the number of online CPUs. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Check unexpected "switch" statement valuePaul E. McKenney2020-08-241-0/+4
| | | | | | | | | | This commit adds a "default" case to the switch statement in scftorture_invoke_one() which contains a WARN_ON_ONCE() and an assignment to ->scfc_out to suppress knock-on warnings. These knock-on warnings could otherwise cause the user to think that there was a memory-ordering problem in smp_call_function() instead of a bug in scftorture.c itself. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Make symbol 'scf_torture_rand' staticWei Yongjun2020-08-241-1/+1
| | | | | | | | | | | | | | The sparse tool complains as follows kernel/scftorture.c:124:1: warning: symbol '__pcpu_scope_scf_torture_rand' was not declared. Should it be static? And this per-CPU variable is not used outside of scftorture.c, so this commit marks it static. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Prevent compiler from reducing race probabilitiesPaul E. McKenney2020-08-241-2/+8
| | | | | | | | | | Detecting smp_call_function() memory misordering requires close timing, so it is necessary to have the checks immediately before and after the call to the smp_call_function*() function under test. This commit therefore inserts barrier() calls to prevent the compiler from optimizing memory-misordering detection down into the zone of extreme improbability. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Flag errors in torture-compatible mannerPaul E. McKenney2020-08-241-4/+10
| | | | | | | | | This commit prints error counts on the statistics line and also adds a "!!!" if any of the counters are non-zero. Allocation failures are (somewhat) forgiven, but all other errors result in a "FAILURE" print at the end of the test. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Consolidate scftorture_invoke_one() scf_check initializationPaul E. McKenney2020-08-241-13/+8
| | | | | | | | | This commit hoists much of the initialization of the scf_check structure out of the switch statement, thus saving a few lines of code. The initialization of the ->scfc_in field remains in each leg of the switch statement in order to more heavily stress memory ordering. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Consolidate scftorture_invoke_one() check and kfree()Paul E. McKenney2020-08-241-18/+8
| | | | | | | | This commit moves checking of the ->scfc_out field and the freeing of the scf_check structure down below the end of switch statement, thus saving a few lines of code. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add smp_call_function() memory-ordering checksPaul E. McKenney2020-08-241-8/+17
| | | | | | | | | | | | | | This commit adds checks for memory misordering across calls to and returns from smp_call_function() in the case where the caller waits. Misordering results in a splat. Note that in contrast to smp_call_function_single(), this code does not test memory ordering into the handler in the no-wait case because none of the handlers would be able to free the scf_check structure without introducing heavy synchronization to work out which was last. [ paulmck: s/GFP_KERNEL/GFP_ATOMIC/ per kernel test robot feedback. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add smp_call_function_many() memory-ordering checksPaul E. McKenney2020-08-241-3/+23
| | | | | | | | | | | | | | This commit adds checks for memory misordering across calls to and returns from smp_call_function_many() in the case where the caller waits. Misordering results in a splat. Note that in contrast to smp_call_function_single(), this code does not test memory ordering into the handler in the no-wait case because none of the handlers would be able to free the scf_check structure without introducing heavy synchronization to work out which was last. [ paulmck: s/GFP_KERNEL/GFP_ATOMIC/ per kernel test robot feedback. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add smp_call_function_single() memory-ordering checksPaul E. McKenney2020-08-241-8/+48
| | | | | | | | | This commit adds checks for memory misordering across calls to smp_call_function_single() and also across returns in the case where the caller waits. Misordering results in a splat. [ paulmck: s/GFP_KERNEL/GFP_ATOMIC/ per kernel test robot feedback. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Summarize per-thread statisticsPaul E. McKenney2020-08-241-4/+18
| | | | | | | | This commit summarizes the per-thread statistics, providing counts of the number of single, many, and all calls, both no-wait and wait, and, for the single case, the number where the target CPU was offline. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Implement weighted primitive selectionPaul E. McKenney2020-08-241-27/+155
| | | | | | | | | | | | | | This commit uses the scftorture.weight* kernel parameters to randomly chooses between smp_call_function_single(), smp_call_function_many(), and smp_call_function(). For each variant, it also randomly chooses whether to invoke it synchronously (wait=1) or asynchronously (wait=0). The percentage weighting for each option are dumped to the console log (search for "scf_sel_dump"). This accumulates statistics, which a later commit will dump out at the end of the run. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
* scftorture: Add smp_call_function() torture testPaul E. McKenney2020-08-241-0/+350
This commit adds an smp_call_function() torture test that repeatedly invokes this function and complains if things go badly awry. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>