Re: [PATCH v3 4/4] selftests: kmod: Add tests for merging same-name module load requests

From: Luis Chamberlain
Date: Tue Oct 25 2022 - 19:02:04 EST


On Tue, Oct 25, 2022 at 10:51:14AM -0700, Luis Chamberlain wrote:
> On Sun, Oct 16, 2022 at 02:30:31PM +0200, Petr Pavlu wrote:
> > diff --git a/tools/testing/selftests/kmod/init_module.c b/tools/testing/selftests/kmod/init_module.c
> > @@ -525,6 +662,8 @@ list_tests()
> > echo "0011 x $(get_test_count 0011) - test completely disabling module autoloading"
> > echo "0012 x $(get_test_count 0012) - test /proc/modules address visibility under CAP_SYSLOG"
> > echo "0013 x $(get_test_count 0013) - test /sys/module/*/sections/* visibility under CAP_SYSLOG"
> > + echo "0014 x $(get_test_count 0014) - test handling of parallel loads, success case"
> > + echo "0015 x $(get_test_count 0015) - test handling of parallel loads, init returning error"
>
> Good stuff!
>
> So test 0015 mimics the error reported by Prarit Bhargava through
> commit 6e6de3dee51a ("kernel/module.c: Only return -EEXIST for modules
> that have finished loading")? If so it would be good to document that
> here.
>
> Also, this patch should go first, with the ALL_TESTS variable set to
> disable the tests which are known to fail, so to demonstrate the *new*
> issues as they are failing and then your fix first and then you enable
> that test afterwards.
>
> If 6e6de3dee51a introduced another regression which is not covered
> by the tests we'd add it, and fix on top of it as a stepping stone
> to prove / send to stable.

On second though, this could also be made into a self-contained C code
test within lib/test_kmod.c:

* You'd extend kmod_test_case with a new enum, say TEST_KMOD_INIT_RACES
* You could extend run_request() to run the series of tests required.
* request_module() does not allow you to specify module parameters,
but we could have optional support added, and make the existing
request_module() always pass that empty / NULL.

Kind of like lib/test_vmalloc.c which has an array of tests, you can peg
new tests to the TEST_KMOD_INIT_RACES for it.

Let me know what folks think.

Luis