Re: [PATCH 2/4] test-ww_mutex: Report errors from stress workers

From: John Stultz

Date: Wed Jul 08 2026 - 20:04:18 EST


On Thu, Jun 18, 2026 at 10:52 AM John Stultz <jstultz@xxxxxxxxxx> wrote:
> On Wed, Jun 17, 2026 at 5:13 AM Håkon Bugge <haakon.bugge@xxxxxxxxxx> wrote:
> >
> > If any of stress_one_work(), stress_reorder_work(), or
> > stress_inorder_work() fails, the error is not conveyed back to the
> > test harness function stress().
> >
> > We may then see in the log:
> >
> > stress (stress_inorder_work) failed with -35
> > Beginning ww (die) mutex selftests
> > All ww mutex selftests passed
> >
> > Besides being a contradiction by terms, the failure to return error
> > from said worker functions leads to false-positive results.
> >
> > We fix that by adding a *result* variable to *struct stress*, update
> > it in said worker functions, and finally, in stress(), scan the
> > *stress_array* and report the first error if any.
> >
> > Fixes: 2a0c11282881 ("locking/ww_mutex: Add kselftests for ww_mutex stress")
> > Signed-off-by: Håkon Bugge <haakon.bugge@xxxxxxxxxx>
>
> Acked-by: John Stultz <jstultz@xxxxxxxxxx>

I did catch one issue with this patch in testing. Where as without
this change, if there was a failure in the first run during
test_ww_mutex_init(), you could still run the test again manually via
the sysfs interface without unloading and reloading.

But with this change, since the error is reported, the module_init
function sees the error and bails out, removing the sysfs interface.
If its a module, you can just reload it, but if it is built-in then
its stuck and can't be rerun.

So we might want to tweak test_ww_mutex_init() with this patch and
include something like (whitespace corrupted, just for illustration
here):
ret = run_test_classes();
mutex_unlock(&run_lock);

- if (!ret)
+ if (!ret || IS_BUILTIN(CONFIG_WW_MUTEX_SELFTEST))
return 0;

sysfs_remove_group(test_ww_mutex_kobj, &attr_group);

?

thanks
-john