locking/locktorture: Fix incorrect use of ww_acquire_ctx in ww_mutex test
authorWaiman Long <longman@redhat.com>
Thu, 18 Mar 2021 17:28:14 +0000 (13:28 -0400)
committerIngo Molnar <mingo@kernel.org>
Fri, 19 Mar 2021 11:13:10 +0000 (12:13 +0100)
commit8c52cca04f97a4c09ec2f0bd8fe6d0cdf49834e4
tree75d00f8605bfc8e41c1e9e298a7bc7414e56bcac
parentaa3a5f31877e5dc131cc286ce707413d441c8375
locking/locktorture: Fix incorrect use of ww_acquire_ctx in ww_mutex test

The ww_acquire_ctx structure for ww_mutex needs to persist for a complete
lock/unlock cycle. In the ww_mutex test in locktorture, however, both
ww_acquire_init() and ww_acquire_fini() are called within the lock
function only. This causes a lockdep splat of "WARNING: Nested lock
was not taken" when lockdep is enabled in the kernel.

To fix this problem, we need to move the ww_acquire_fini() after
the ww_mutex_unlock() in torture_ww_mutex_unlock(). This is done by
allocating a global array of ww_acquire_ctx structures. Each locking
thread is associated with its own ww_acquire_ctx via the unique thread
id it has so that both the lock and unlock functions can access the
same ww_acquire_ctx structure.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210318172814.4400-6-longman@redhat.com
kernel/locking/locktorture.c