From: Richard Cheng <icheng@nvidia.com>
To: tony.luck@intel.com, reinette.chatre@intel.com, shuah@kernel.org,
ben.horgan@arm.com, fenghuay@nvidia.com
Cc: x86@kernel.org, Dave.Martin@arm.com, james.morse@arm.com,
babu.moger@amd.com, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, kaihengf@nvidia.com,
kobak@nvidia.com, newtonl@nvidia.com, kristinc@nvidia.com,
Richard Cheng <icheng@nvidia.com>
Subject: [PATCH v6 1/2] selftests/resctrl: Fix CMT test failure when all cache bits are tested
Date: Sat, 14 Nov 2026 22:01:07 +0800 [thread overview]
Message-ID: <20261114140108.36954-2-icheng@nvidia.com> (raw)
In-Reply-To: <20261114140108.36954-1-icheng@nvidia.com>
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.
Fixes: 7a214b4ec1c9 ("selftests/resctrl: Improve accuracy of cache occupancy test")
Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
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);
--
2.43.0
next prev parent reply other threads:[~2026-11-14 14:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 14:01 [PATCH v6 0/2] selftests/resctrl: Check the effect of the CBM in CMT test Richard Cheng
2026-11-14 14:01 ` Richard Cheng [this message]
2026-11-14 14:01 ` [PATCH v6 2/2] selftests/resctrl: Check that CBM limits LLC occupancy " Richard Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261114140108.36954-2-icheng@nvidia.com \
--to=icheng@nvidia.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=kaihengf@nvidia.com \
--cc=kobak@nvidia.com \
--cc=kristinc@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=newtonl@nvidia.com \
--cc=reinette.chatre@intel.com \
--cc=shuah@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®