test-ww_mutex: Report whether stress failures are isolated or mixed
PATCH RESEND 1/2 test-ww_mutex: Report whether stress failures are isolated or mixed
The stress tests can run an individual stress worker type in isolation or together with the other stress worker types.
Include this information in the error message so that failures can be distinguished between isolated and mixed workloads.
--- kernel/locking/test-ww_mutex.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
kernel/locking/test-ww_mutex.c +14 -6
@@ -408,6 +408,7 @@ struct stress {unsigned long timeout;int nlocks;int result; +bool run_in_isolation; };struct rnd_state rng;
@@ -449,6 +450,11 @@ static void dummy_load(struct stress *stress)usleep_range (1000 ,2000 ); } +static const char *in_isolation_or_mixed (bool in_isolation) +{ +return in_isolation ?"in isolation" :"mixed workload" ; +} +static void stress_inorder_work (struct work_struct *work) {struct stress *stress =container_of (work,typeof (*stress), work);
@@ -497,8 +503,8 @@ static void stress_inorder_work(struct work_struct *work)ww_acquire_fini (&ctx);if (err) { -pr_err_once ("stress (%s) failed with %d\n" , - __func__, err); +pr_err_once ("stress (%s; %s) failed with %d\n" , + __func__,in_isolation_or_mixed (stress->run_in_isolation), err);break ; } }while (!time_after (jiffies, stress->timeout));
@@ -551,8 +557,9 @@ static void stress_reorder_work(struct work_struct *work)ww_mutex_unlock (ln->lock);if (err != -EDEADLK ) { -pr_err_once ("stress (%s) failed with %d\n" , - __func__, err); +pr_err_once ("stress (%s; %s) failed with %d\n" , + __func__, +in_isolation_or_mixed (stress->run_in_isolation), err);break ; }
@@ -588,8 +595,8 @@ static void stress_one_work(struct work_struct *work)dummy_load (stress);ww_mutex_unlock (lock); }else { -pr_err_once ("stress (%s) failed with %d\n" , - __func__, err); +pr_err_once ("stress (%s; %s) failed with %d\n" , + __func__,in_isolation_or_mixed (stress->run_in_isolation), err);break ; } }while (!time_after (jiffies, stress->timeout));
@@ -653,6 +660,7 @@ static int stress(struct ww_class *class, int nlocks, int nthreads, unsigned int stress->locks = locks; stress->nlocks = nlocks; stress->timeout = jiffies +2 *HZ ; + stress->run_in_isolation = flags !=STRESS_ALL ;queue_work (wq, &stress->work); nthreads--;
--
2.43.5
PATCH RESEND 2/2 test-ww_mutex: Bound inorder stress test concurrency
The ww_mutex stress tests can have difficulty converging on systems with large CPU counts. In particular, as the number of workers increases, the inorder test may spend more time retrying after -EDEADLK, reducing the probability of converging within the allotted time.
The inorder stress has particularly poor convergence at high concurrency because repeated -EDEADLK handling causes workers to retry their complete lock acquisition sequences while competing with many other workers. On large systems this can prevent the test from making sufficient progress within the allotted time, resulting in false-negatives.
Add one cutoff for the inorder test when it runs in isolation and another when it runs concurrently with the other stress tests. When the latter is exceeded, remove STRESS_INORDER from the enabled stress tests.
Give the inorder -EDEADLK retry path its own extended deadline rather than using the general stress timeout. Also determine whether a worker runs in isolation from the number of enabled stress variants, since STRESS_ALL may now have variants removed dynamically.
In summary, for the inorder stress test:
* Cap the number of threads when running in isolation
* Cap the number of threads when running concurrently with other tests
* Extend the deadline when -EDEADLK is returned
This bounds inorder stress concurrency on large systems while reducing false-negatives and preserving coverage of the combined stress workload.
This has been tested on a 160 CPU Arm system and a 512 CPU AMD x86_64 system with the following four configurations:
PROVE_LOCKING=y, DEBUG_WW_MUTEX_SLOWPATH=y,
WW_MUTEX_SELFTEST=y
PROVE_LOCKING=y, DEBUG_WW_MUTEX_SLOWPATH=y,
WW_MUTEX_SELFTEST=m
PROVE_LOCKING=n, DEBUG_WW_MUTEX_SLOWPATH=n,
WW_MUTEX_SELFTEST=y
PROVE_LOCKING=n, DEBUG_WW_MUTEX_SLOWPATH=n,
WW_MUTEX_SELFTEST=m
All four configurations passed 1000 iterations on both test systems, with the following commits also included:
("test-ww_mutex: Fix deadlock in test_cycle_work") ("workqueue: Add missing EXPORT_SYMBOL_GPL for workqueue_set_min_active") ("test-ww_mutex: Handle transient -EDEADLK in test_cycle_work") ("test-ww_mutex: Report errors from stress workers") ("test-ww_mutex: Fix module cleanup")
---
Note to the maintainers: Since none of the above commits have been merged yet, I am happy to include them all in a single series if that is more convenient.
--- kernel/locking/test-ww_mutex.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
kernel/locking/test-ww_mutex.c +17 -3
@@ -406,6 +406,7 @@ struct stress {struct ww_mutex *locks;struct ww_class *class;unsigned long timeout; +unsigned long timeout_edeadlk_deadline;int nlocks;int result;bool run_in_isolation;
@@ -495,7 +496,7 @@ static void stress_inorder_work(struct work_struct *work)ww_mutex_unlock (&locks[order[n]]);if (err == -EDEADLK ) { -if (!time_after (jiffies, stress->timeout)) { +if (!time_after (jiffies, stress->timeout_edeadlk_deadline)) {ww_mutex_lock_slow (&locks[order[contended]], &ctx); goto retry; }
@@ -608,6 +609,8 @@ static void stress_one_work(struct work_struct *work)#define STRESS_REORDER BIT(1)#define STRESS_ONE BIT(2)#define STRESS_ALL (STRESS_INORDER | STRESS_REORDER | STRESS_ONE) +#define STRESS_ALL_NTHREADS_CUTOFF 64 +#define STRESS_INORDER_NTHREADS_CUTOFF 512static int stress (struct ww_class *class,int nlocks,int nthreads,unsigned int flags) {
@@ -630,6 +633,10 @@ static int stress(struct ww_class *class, int nlocks, int nthreads, unsigned intww_mutex_init (&locks[n], class); count =0 ; +/* Remove STRESS_INORDER from flags if nthreads is too high */ +if (flags ==STRESS_ALL && nthreads >STRESS_ALL_NTHREADS_CUTOFF ) + flags &= ~STRESS_INORDER ; +for (n =0 ; nthreads; n++) {struct stress *stress;void (*fn)(struct work_struct *work);
@@ -660,7 +667,8 @@ static int stress(struct ww_class *class, int nlocks, int nthreads, unsigned int stress->locks = locks; stress->nlocks = nlocks; stress->timeout = jiffies +2 *HZ ; - stress->run_in_isolation = flags !=STRESS_ALL ; + stress->timeout_edeadlk_deadline = stress->timeout +2 *HZ ; + stress->run_in_isolation =hweight32 (flags) ==1 ;queue_work (wq, &stress->work); nthreads--;
@@ -719,7 +727,7 @@ static int run_tests(struct ww_class *class)if (ret)return ret; - ret =stress (class,16 ,2 * ncpus,STRESS_INORDER ); + ret =stress (class,16 ,min (STRESS_INORDER_NTHREADS_CUTOFF ,2 * ncpus),STRESS_INORDER );if (ret)return ret;
@@ -727,6 +735,12 @@ static int run_tests(struct ww_class *class)if (ret)return ret; +if (hweight32 (STRESS_ALL ) * ncpus >STRESS_ALL_NTHREADS_CUTOFF ) { +/* Make sure we have a run with all tests running currently */ + ret =stress (class,2046 ,STRESS_ALL_NTHREADS_CUTOFF ,STRESS_ALL ); +if (ret) +return ret; + } ret =stress (class,2046 ,hweight32 (STRESS_ALL ) * ncpus,STRESS_ALL );if (ret)return ret;
--
2.43.5