Commit 57dd924e authored by Chris Wilson's avatar Chris Wilson Committed by Ingo Molnar

locking/ww-mutex: Limit stress test to 2 seconds

Use a timeout rather than a fixed number of loops to avoid running for
very long periods, such as under the kbuilder VMs.
Reported-by: default avatarkernel test robot <xiaolong.ye@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170310105733.6444-1-chris@chris-wilson.co.ukSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 44fe8445
...@@ -353,8 +353,8 @@ static int test_cycle(unsigned int ncpus) ...@@ -353,8 +353,8 @@ static int test_cycle(unsigned int ncpus)
struct stress { struct stress {
struct work_struct work; struct work_struct work;
struct ww_mutex *locks; struct ww_mutex *locks;
unsigned long timeout;
int nlocks; int nlocks;
int nloops;
}; };
static int *get_random_order(int count) static int *get_random_order(int count)
...@@ -434,7 +434,7 @@ static void stress_inorder_work(struct work_struct *work) ...@@ -434,7 +434,7 @@ static void stress_inorder_work(struct work_struct *work)
} }
ww_acquire_fini(&ctx); ww_acquire_fini(&ctx);
} while (--stress->nloops); } while (!time_after(jiffies, stress->timeout));
kfree(order); kfree(order);
kfree(stress); kfree(stress);
...@@ -496,7 +496,7 @@ static void stress_reorder_work(struct work_struct *work) ...@@ -496,7 +496,7 @@ static void stress_reorder_work(struct work_struct *work)
ww_mutex_unlock(ll->lock); ww_mutex_unlock(ll->lock);
ww_acquire_fini(&ctx); ww_acquire_fini(&ctx);
} while (--stress->nloops); } while (!time_after(jiffies, stress->timeout));
out: out:
list_for_each_entry_safe(ll, ln, &locks, link) list_for_each_entry_safe(ll, ln, &locks, link)
...@@ -522,7 +522,7 @@ static void stress_one_work(struct work_struct *work) ...@@ -522,7 +522,7 @@ static void stress_one_work(struct work_struct *work)
__func__, err); __func__, err);
break; break;
} }
} while (--stress->nloops); } while (!time_after(jiffies, stress->timeout));
kfree(stress); kfree(stress);
} }
...@@ -532,7 +532,7 @@ static void stress_one_work(struct work_struct *work) ...@@ -532,7 +532,7 @@ static void stress_one_work(struct work_struct *work)
#define STRESS_ONE BIT(2) #define STRESS_ONE BIT(2)
#define STRESS_ALL (STRESS_INORDER | STRESS_REORDER | STRESS_ONE) #define STRESS_ALL (STRESS_INORDER | STRESS_REORDER | STRESS_ONE)
static int stress(int nlocks, int nthreads, int nloops, unsigned int flags) static int stress(int nlocks, int nthreads, unsigned int flags)
{ {
struct ww_mutex *locks; struct ww_mutex *locks;
int n; int n;
...@@ -574,7 +574,7 @@ static int stress(int nlocks, int nthreads, int nloops, unsigned int flags) ...@@ -574,7 +574,7 @@ static int stress(int nlocks, int nthreads, int nloops, unsigned int flags)
INIT_WORK(&stress->work, fn); INIT_WORK(&stress->work, fn);
stress->locks = locks; stress->locks = locks;
stress->nlocks = nlocks; stress->nlocks = nlocks;
stress->nloops = nloops; stress->timeout = jiffies + 2*HZ;
queue_work(wq, &stress->work); queue_work(wq, &stress->work);
nthreads--; nthreads--;
...@@ -618,15 +618,15 @@ static int __init test_ww_mutex_init(void) ...@@ -618,15 +618,15 @@ static int __init test_ww_mutex_init(void)
if (ret) if (ret)
return ret; return ret;
ret = stress(16, 2*ncpus, 1<<10, STRESS_INORDER); ret = stress(16, 2*ncpus, STRESS_INORDER);
if (ret) if (ret)
return ret; return ret;
ret = stress(16, 2*ncpus, 1<<10, STRESS_REORDER); ret = stress(16, 2*ncpus, STRESS_REORDER);
if (ret) if (ret)
return ret; return ret;
ret = stress(4095, hweight32(STRESS_ALL)*ncpus, 1<<12, STRESS_ALL); ret = stress(4095, hweight32(STRESS_ALL)*ncpus, STRESS_ALL);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment