Skip to content

Commit bf7b3ac

Browse files
Peter Zijlstraingomolnar
authored andcommitted
locking/ww_mutex: Improve test to cover acquire context changes
Currently each thread starts an acquire context only once, and performs all its loop iterations under it. This means that the Wound/Wait relations between threads are fixed. To make things a little more realistic and cover more of the functionality with the test, open a new acquire context for each loop. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 383776f commit bf7b3ac

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

‎kernel/locking/test-ww_mutex.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,11 @@ static void stress_inorder_work(struct work_struct *work)
398398
if (!order)
399399
return;
400400

401-
ww_acquire_init(&ctx, &ww_class);
402-
403401
do {
404402
int contended = -1;
405403
int n, err;
406404

405+
ww_acquire_init(&ctx, &ww_class);
407406
retry:
408407
err = 0;
409408
for (n = 0; n < nlocks; n++) {
@@ -433,9 +432,9 @@ static void stress_inorder_work(struct work_struct *work)
433432
__func__, err);
434433
break;
435434
}
436-
} while (--stress->nloops);
437435

438-
ww_acquire_fini(&ctx);
436+
ww_acquire_fini(&ctx);
437+
} while (--stress->nloops);
439438

440439
kfree(order);
441440
kfree(stress);
@@ -470,9 +469,9 @@ static void stress_reorder_work(struct work_struct *work)
470469
kfree(order);
471470
order = NULL;
472471

473-
ww_acquire_init(&ctx, &ww_class);
474-
475472
do {
473+
ww_acquire_init(&ctx, &ww_class);
474+
476475
list_for_each_entry(ll, &locks, link) {
477476
err = ww_mutex_lock(ll->lock, &ctx);
478477
if (!err)
@@ -495,9 +494,9 @@ static void stress_reorder_work(struct work_struct *work)
495494
dummy_load(stress);
496495
list_for_each_entry(ll, &locks, link)
497496
ww_mutex_unlock(ll->lock);
498-
} while (--stress->nloops);
499497

500-
ww_acquire_fini(&ctx);
498+
ww_acquire_fini(&ctx);
499+
} while (--stress->nloops);
501500

502501
out:
503502
list_for_each_entry_safe(ll, ln, &locks, link)

0 commit comments

Comments
 (0)