locktorture: Count lock readers
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 2 Jun 2021 23:04:11 +0000 (16:04 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 27 Jul 2021 18:39:30 +0000 (11:39 -0700)
commitaf5f6e27d52cdb2cb3826df19a69a74e9d5eff5e
tree751ec15273f6780b99c1a1b0b199c5dcafbe7dc5
parent5b237d650eb8b0870b5d816fecc0be00237cbfff
locktorture: Count lock readers

Currently, the lock_is_read_held variable is bool, so that a reader sets
it to true just after lock acquisition and then to false just before
lock release.  This works in a rough statistical sense, but can result
in false negatives just after one of a pair of concurrent readers has
released the lock.  This approach does have low overhead, but at the
expense of the setting to true potentially never leaving the reader's
store buffer, thus resulting in an unconditional false negative.

This commit therefore converts this variable to atomic_t and makes
the reader use atomic_inc() just after acquisition and atomic_dec()
just before release.  This does increase overhead, but this increase is
negligible compared to the 10-microsecond lock hold time.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/locking/locktorture.c