Re: [PATCH v6 1/2] selftests/resctrl: Fix CMT test failure when all cache bits are tested
From: Richard Cheng
Date: Fri Nov 20 2026 - 04:31:45 EST
On Mon, Nov 16, 2026 at 04:30:06PM +0800, Ben Horgan wrote:
> 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
>
Hi Ben,
No strong reason.
I was fixing the failed write and skipping it was the smallest change.
I think your way is better, it can keep the other tasks in one portion
instead of leaving them the whole cache.
I'll write the smallest mask the platform accepts min_cbm_bits in v7.
Best regards,
Richard Cheng.
> >
> > 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);
>