]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
revocable: Add KUnit test for concurrent access
authorTzung-Bi Shih <tzungbi@kernel.org>
Thu, 29 Jan 2026 14:37:33 +0000 (14:37 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Feb 2026 11:30:43 +0000 (12:30 +0100)
commit988357628c2c84e891f5992c4f5cfb31fb3bd27b
tree1431b204be5980726d343582ac7074d828c50fe9
parent377563ce0653031de8d530e8b2f590d13349e29c
revocable: Add KUnit test for concurrent access

Add a test case to verify correct synchronization between concurrent
readers and a revocation.

The test setup involves:
1. Consumer 1 enters the critical section (SRCU read lock) and verifies
   access to the resource.
2. Provider attempts to revoke the resource.  This should block until
   Consumer 1 releases the lock.
3. Consumer 2 attempts to enter the critical section while revocation
   is pending.  It should see the resource as revoked (NULL).
4. Consumer 1 exits, allowing the revocation to complete.

This ensures that the SRCU mechanism correctly enforces grace periods
and that new readers are properly prevented from accessing the resource
once revocation has begun.

A way to run the test:
$ ./tools/testing/kunit/kunit.py run \
--kconfig_add CONFIG_REVOCABLE_KUNIT_TEST=y \
--kconfig_add CONFIG_PROVE_LOCKING=y \
--kconfig_add CONFIG_DEBUG_KERNEL=y \
--kconfig_add CONFIG_DEBUG_INFO=y \
--kconfig_add CONFIG_DEBUG_INFO_DWARF5=y \
--kconfig_add CONFIG_KASAN=y \
--kconfig_add CONFIG_DETECT_HUNG_TASK=y \
--kconfig_add CONFIG_DEFAULT_HUNG_TASK_TIMEOUT="10" \
--arch=x86_64 --raw_output=all \
revocable_test

Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260129143733.45618-5-tzungbi@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/revocable_test.c