locktorture.c (b63343207da21179d82df933f42a1725a53b9a63) locktorture.c (3e5aeaf53422bdd79fecf89aa160f048114e013c)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Module-based torture test facility for locking
4 *
5 * Copyright (C) IBM Corporation, 2014
6 *
7 * Authors: Paul E. McKenney <paulmck@linux.ibm.com>
8 * Davidlohr Bueso <dave@stgolabs.net>

--- 356 unchanged lines hidden (view full) ---

365 .writeunlock = torture_rwlock_write_unlock_irq,
366 .readlock = torture_rwlock_read_lock_irq,
367 .read_delay = torture_rwlock_read_delay,
368 .readunlock = torture_rwlock_read_unlock_irq,
369 .name = "rw_lock_irq"
370};
371
372static DEFINE_MUTEX(torture_mutex);
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Module-based torture test facility for locking
4 *
5 * Copyright (C) IBM Corporation, 2014
6 *
7 * Authors: Paul E. McKenney <paulmck@linux.ibm.com>
8 * Davidlohr Bueso <dave@stgolabs.net>

--- 356 unchanged lines hidden (view full) ---

365 .writeunlock = torture_rwlock_write_unlock_irq,
366 .readlock = torture_rwlock_read_lock_irq,
367 .read_delay = torture_rwlock_read_delay,
368 .readunlock = torture_rwlock_read_unlock_irq,
369 .name = "rw_lock_irq"
370};
371
372static DEFINE_MUTEX(torture_mutex);
373static struct mutex torture_nested_mutexes[MAX_NESTED_LOCKS];
374static struct lock_class_key nested_mutex_keys[MAX_NESTED_LOCKS];
373
375
376static void torture_mutex_init(void)
377{
378 int i;
379
380 for (i = 0; i < MAX_NESTED_LOCKS; i++)
381 __mutex_init(&torture_nested_mutexes[i], __func__,
382 &nested_mutex_keys[i]);
383}
384
385static int torture_mutex_nested_lock(int tid __maybe_unused,
386 u32 lockset)
387{
388 int i;
389
390 for (i = 0; i < nested_locks; i++)
391 if (lockset & (1 << i))
392 mutex_lock(&torture_nested_mutexes[i]);
393 return 0;
394}
395
374static int torture_mutex_lock(int tid __maybe_unused)
375__acquires(torture_mutex)
376{
377 mutex_lock(&torture_mutex);
378 return 0;
379}
380
381static void torture_mutex_delay(struct torture_random_state *trsp)

--- 11 unchanged lines hidden (view full) ---

393}
394
395static void torture_mutex_unlock(int tid __maybe_unused)
396__releases(torture_mutex)
397{
398 mutex_unlock(&torture_mutex);
399}
400
396static int torture_mutex_lock(int tid __maybe_unused)
397__acquires(torture_mutex)
398{
399 mutex_lock(&torture_mutex);
400 return 0;
401}
402
403static void torture_mutex_delay(struct torture_random_state *trsp)

--- 11 unchanged lines hidden (view full) ---

415}
416
417static void torture_mutex_unlock(int tid __maybe_unused)
418__releases(torture_mutex)
419{
420 mutex_unlock(&torture_mutex);
421}
422
423static void torture_mutex_nested_unlock(int tid __maybe_unused,
424 u32 lockset)
425{
426 int i;
427
428 for (i = nested_locks - 1; i >= 0; i--)
429 if (lockset & (1 << i))
430 mutex_unlock(&torture_nested_mutexes[i]);
431}
432
401static struct lock_torture_ops mutex_lock_ops = {
433static struct lock_torture_ops mutex_lock_ops = {
434 .init = torture_mutex_init,
435 .nested_lock = torture_mutex_nested_lock,
402 .writelock = torture_mutex_lock,
403 .write_delay = torture_mutex_delay,
404 .task_boost = torture_rt_boost,
405 .writeunlock = torture_mutex_unlock,
436 .writelock = torture_mutex_lock,
437 .write_delay = torture_mutex_delay,
438 .task_boost = torture_rt_boost,
439 .writeunlock = torture_mutex_unlock,
440 .nested_unlock = torture_mutex_nested_unlock,
406 .readlock = NULL,
407 .read_delay = NULL,
408 .readunlock = NULL,
409 .name = "mutex_lock"
410};
411
412#include <linux/ww_mutex.h>
413/*

--- 734 unchanged lines hidden ---
441 .readlock = NULL,
442 .read_delay = NULL,
443 .readunlock = NULL,
444 .name = "mutex_lock"
445};
446
447#include <linux/ww_mutex.h>
448/*

--- 734 unchanged lines hidden ---