Re: [PATCH v6 1/2] selftests/resctrl: Fix CMT test failure when all cache bits are tested
From: Ben Horgan
Date: Mon Nov 16 2026 - 11:30:13 EST
Hi Richard,
On 14/11/2026 14:01, Richard Cheng wrote:
> The CMT test accepts any number of bits from 1 to the length of the full
> cache bit mask via "-n". Since cmt_init() gives the default resource
> group the inverse of the tested mask to keep other tasks out of the
> tested cache portion.
>
> When all bits are tested the inverse mask is empty. resctrl rejects an
> empty mask with "Mask out of range" on systems that require at least one
> bit to be set, cmt_init() fails and the test fails before taking any
> measurement.
>
> Only write the schemata of the default resource group when there're bits
> left for it. When all bits are tested the default resource group keeps
> its allocation.
Why did you choose this policy? For instance, why not just set a single bit?
Thanks,
Ben
>
> Fixes: 7a214b4ec1c9 ("selftests/resctrl: Improve accuracy of cache occupancy test")
> Signed-off-by: Richard Cheng <icheng@xxxxxxxxxx>
> ---
> tools/testing/selftests/resctrl/cmt_test.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c
> index ccb6fe881a94..5d0bb27b7817 100644
> --- a/tools/testing/selftests/resctrl/cmt_test.c
> +++ b/tools/testing/selftests/resctrl/cmt_test.c
> @@ -42,10 +42,13 @@ static int cmt_init(const struct resctrl_test *test,
> if (ret)
> return ret;
>
> - snprintf(schemata, sizeof(schemata), "%lx", ~param->mask & full_mask);
> - ret = write_schemata("", schemata, uparams->cpu, test->resource);
> - if (ret)
> - return ret;
> + /* No bits are left for the default group when all bits are tested. */
> + if (~param->mask & full_mask) {
> + snprintf(schemata, sizeof(schemata), "%lx", ~param->mask & full_mask);
> + ret = write_schemata("", schemata, uparams->cpu, test->resource);
> + if (ret)
> + return ret;
> + }
>
> snprintf(schemata, sizeof(schemata), "%lx", param->mask);
> ret = write_schemata(param->ctrlgrp, schemata, uparams->cpu, test->resource);