mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
locktorture: Add nested locking to mutex torture tests
This patch adds randomized nested locking to the mutex torture tests, as well as new LOCK08 config files for testing mutexes with nested locking Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: "Paul E. McKenney" <paulmck@kernel.org> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Joel Fernandes <joel@joelfernandes.org> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Valentin Schneider <vschneid@redhat.com> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> Cc: kernel-team@android.com Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Co-developed-by: Connor O'Brien <connoro@google.com> Signed-off-by: Connor O'Brien <connoro@google.com> Signed-off-by: John Stultz <jstultz@google.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
b63343207d
commit
3e5aeaf534
4 changed files with 43 additions and 0 deletions
|
@ -370,6 +370,28 @@ static struct lock_torture_ops rw_lock_irq_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static DEFINE_MUTEX(torture_mutex);
|
static DEFINE_MUTEX(torture_mutex);
|
||||||
|
static struct mutex torture_nested_mutexes[MAX_NESTED_LOCKS];
|
||||||
|
static struct lock_class_key nested_mutex_keys[MAX_NESTED_LOCKS];
|
||||||
|
|
||||||
|
static void torture_mutex_init(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_NESTED_LOCKS; i++)
|
||||||
|
__mutex_init(&torture_nested_mutexes[i], __func__,
|
||||||
|
&nested_mutex_keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int torture_mutex_nested_lock(int tid __maybe_unused,
|
||||||
|
u32 lockset)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < nested_locks; i++)
|
||||||
|
if (lockset & (1 << i))
|
||||||
|
mutex_lock(&torture_nested_mutexes[i]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int torture_mutex_lock(int tid __maybe_unused)
|
static int torture_mutex_lock(int tid __maybe_unused)
|
||||||
__acquires(torture_mutex)
|
__acquires(torture_mutex)
|
||||||
|
@ -398,11 +420,24 @@ __releases(torture_mutex)
|
||||||
mutex_unlock(&torture_mutex);
|
mutex_unlock(&torture_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void torture_mutex_nested_unlock(int tid __maybe_unused,
|
||||||
|
u32 lockset)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = nested_locks - 1; i >= 0; i--)
|
||||||
|
if (lockset & (1 << i))
|
||||||
|
mutex_unlock(&torture_nested_mutexes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
static struct lock_torture_ops mutex_lock_ops = {
|
static struct lock_torture_ops mutex_lock_ops = {
|
||||||
|
.init = torture_mutex_init,
|
||||||
|
.nested_lock = torture_mutex_nested_lock,
|
||||||
.writelock = torture_mutex_lock,
|
.writelock = torture_mutex_lock,
|
||||||
.write_delay = torture_mutex_delay,
|
.write_delay = torture_mutex_delay,
|
||||||
.task_boost = torture_rt_boost,
|
.task_boost = torture_rt_boost,
|
||||||
.writeunlock = torture_mutex_unlock,
|
.writeunlock = torture_mutex_unlock,
|
||||||
|
.nested_unlock = torture_mutex_nested_unlock,
|
||||||
.readlock = NULL,
|
.readlock = NULL,
|
||||||
.read_delay = NULL,
|
.read_delay = NULL,
|
||||||
.readunlock = NULL,
|
.readunlock = NULL,
|
||||||
|
|
|
@ -5,3 +5,4 @@ LOCK04
|
||||||
LOCK05
|
LOCK05
|
||||||
LOCK06
|
LOCK06
|
||||||
LOCK07
|
LOCK07
|
||||||
|
LOCK08
|
||||||
|
|
6
tools/testing/selftests/rcutorture/configs/lock/LOCK08
Normal file
6
tools/testing/selftests/rcutorture/configs/lock/LOCK08
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
CONFIG_SMP=y
|
||||||
|
CONFIG_NR_CPUS=4
|
||||||
|
CONFIG_HOTPLUG_CPU=y
|
||||||
|
CONFIG_PREEMPT_NONE=n
|
||||||
|
CONFIG_PREEMPT_VOLUNTARY=n
|
||||||
|
CONFIG_PREEMPT=y
|
|
@ -0,0 +1 @@
|
||||||
|
locktorture.torture_type=mutex_lock locktorture.nested_locks=8
|
Loading…
Add table
Reference in a new issue