aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2014-09-11 23:40:20 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2014-09-16 16:41:05 -0400
commit1e6757a92189278c484799ea98fc69bdc528940e (patch)
tree434aee0cfb1b22a6900f152c4aba1be5127dde95 /kernel/locking
parentf095bfc0ea04829d6962edaf06a5c56e0c251f5b (diff)
locktorture: Make statistics generic
The statistics structure can serve well for both reader and writer locks, thus simply rename some fields that mention 'write' and leave the declaration of lwsa. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/locktorture.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index a6049fa2287e..de703a769c1d 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -78,11 +78,11 @@ static struct task_struct **writer_tasks;
78static int nrealwriters_stress; 78static int nrealwriters_stress;
79static bool lock_is_write_held; 79static bool lock_is_write_held;
80 80
81struct lock_writer_stress_stats { 81struct lock_stress_stats {
82 long n_write_lock_fail; 82 long n_lock_fail;
83 long n_write_lock_acquired; 83 long n_lock_acquired;
84}; 84};
85static struct lock_writer_stress_stats *lwsa; 85static struct lock_stress_stats *lwsa; /* writer statistics */
86 86
87#if defined(MODULE) 87#if defined(MODULE)
88#define LOCKTORTURE_RUNNABLE_INIT 1 88#define LOCKTORTURE_RUNNABLE_INIT 1
@@ -250,7 +250,7 @@ static struct lock_torture_ops mutex_lock_ops = {
250 */ 250 */
251static int lock_torture_writer(void *arg) 251static int lock_torture_writer(void *arg)
252{ 252{
253 struct lock_writer_stress_stats *lwsp = arg; 253 struct lock_stress_stats *lwsp = arg;
254 static DEFINE_TORTURE_RANDOM(rand); 254 static DEFINE_TORTURE_RANDOM(rand);
255 255
256 VERBOSE_TOROUT_STRING("lock_torture_writer task started"); 256 VERBOSE_TOROUT_STRING("lock_torture_writer task started");
@@ -261,9 +261,9 @@ static int lock_torture_writer(void *arg)
261 schedule_timeout_uninterruptible(1); 261 schedule_timeout_uninterruptible(1);
262 cur_ops->writelock(); 262 cur_ops->writelock();
263 if (WARN_ON_ONCE(lock_is_write_held)) 263 if (WARN_ON_ONCE(lock_is_write_held))
264 lwsp->n_write_lock_fail++; 264 lwsp->n_lock_fail++;
265 lock_is_write_held = 1; 265 lock_is_write_held = 1;
266 lwsp->n_write_lock_acquired++; 266 lwsp->n_lock_acquired++;
267 cur_ops->write_delay(&rand); 267 cur_ops->write_delay(&rand);
268 lock_is_write_held = 0; 268 lock_is_write_held = 0;
269 cur_ops->writeunlock(); 269 cur_ops->writeunlock();
@@ -281,17 +281,17 @@ static void lock_torture_printk(char *page)
281 bool fail = 0; 281 bool fail = 0;
282 int i; 282 int i;
283 long max = 0; 283 long max = 0;
284 long min = lwsa[0].n_write_lock_acquired; 284 long min = lwsa[0].n_lock_acquired;
285 long long sum = 0; 285 long long sum = 0;
286 286
287 for (i = 0; i < nrealwriters_stress; i++) { 287 for (i = 0; i < nrealwriters_stress; i++) {
288 if (lwsa[i].n_write_lock_fail) 288 if (lwsa[i].n_lock_fail)
289 fail = true; 289 fail = true;
290 sum += lwsa[i].n_write_lock_acquired; 290 sum += lwsa[i].n_lock_acquired;
291 if (max < lwsa[i].n_write_lock_fail) 291 if (max < lwsa[i].n_lock_fail)
292 max = lwsa[i].n_write_lock_fail; 292 max = lwsa[i].n_lock_fail;
293 if (min > lwsa[i].n_write_lock_fail) 293 if (min > lwsa[i].n_lock_fail)
294 min = lwsa[i].n_write_lock_fail; 294 min = lwsa[i].n_lock_fail;
295 } 295 }
296 page += sprintf(page, "%s%s ", torture_type, TORTURE_FLAG); 296 page += sprintf(page, "%s%s ", torture_type, TORTURE_FLAG);
297 page += sprintf(page, 297 page += sprintf(page,
@@ -441,8 +441,8 @@ static int __init lock_torture_init(void)
441 goto unwind; 441 goto unwind;
442 } 442 }
443 for (i = 0; i < nrealwriters_stress; i++) { 443 for (i = 0; i < nrealwriters_stress; i++) {
444 lwsa[i].n_write_lock_fail = 0; 444 lwsa[i].n_lock_fail = 0;
445 lwsa[i].n_write_lock_acquired = 0; 445 lwsa[i].n_lock_acquired = 0;
446 } 446 }
447 447
448 /* Start up the kthreads. */ 448 /* Start up the kthreads. */