From: Jonathan Perry <yonch@yonch.com>
To: Tony Luck <tony.luck@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
linux-kernel@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org,
Jonathan Corbet <corbet@lwn.net>,
James Morse <james.morse@arm.com>,
Roman Storozhenko <romeusmeister@gmail.com>,
Jonathan Perry <yonch@yonch.com>
Subject: [PATCH 5/8] resctrl: Propagate CPU mask validation error via rr->err
Date: Thu, 16 Oct 2025 09:46:53 -0500 [thread overview]
Message-ID: <20251016144656.74928-6-yonch@yonch.com> (raw)
In-Reply-To: <20251016144656.74928-1-yonch@yonch.com>
When __mon_event_count() rejects a CPU because it is not in the
domain's mask (or does not match the cacheinfo domain), it returned
-EINVAL but did not set rr->err. mon_event_count() then discarded the
return value, which made failures harder to diagnose.
Set rr->err = -EINVAL before returning in both validation checks so
the error is visible to callers and can trigger WARN_ONCE() in the
PMU .read path.
Signed-off-by: Jonathan Perry <yonch@yonch.com>
---
fs/resctrl/monitor.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 4076336fbba6..4d19c2ec823f 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -445,8 +445,10 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr)
if (rr->d) {
/* Reading a single domain, must be on a CPU in that domain. */
- if (!cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask))
+ if (!cpumask_test_cpu(cpu, &rr->d->hdr.cpu_mask)) {
+ rr->err = -EINVAL;
return -EINVAL;
+ }
if (rr->is_mbm_cntr)
rr->err = resctrl_arch_cntr_read(rr->r, rr->d, closid, rmid, cntr_id,
rr->evtid, &tval);
@@ -462,8 +464,10 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr)
}
/* Summing domains that share a cache, must be on a CPU for that cache. */
- if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map))
+ if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map)) {
+ rr->err = -EINVAL;
return -EINVAL;
+ }
/*
* Legacy files must report the sum of an event across all
next prev parent reply other threads:[~2025-10-16 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 14:46 [PATCH 0/8] resctrl: Add perf PMU for resctrl monitoring Jonathan Perry
2025-10-16 14:46 ` [PATCH 1/8] resctrl: Pin rdtgroup for mon_data file lifetime Jonathan Perry
2025-10-16 14:46 ` [PATCH 2/8] resctrl/mon: Split RMID read init from execution Jonathan Perry
2025-10-16 14:46 ` [PATCH 3/8] resctrl/mon: Select cpumask before invoking mon_event_read() Jonathan Perry
2025-10-16 14:46 ` [PATCH 4/8] resctrl/mon: Create mon_event_setup_read() helper Jonathan Perry
2025-10-16 14:46 ` Jonathan Perry [this message]
2025-10-16 14:46 ` [PATCH 6/8] resctrl/pmu: Introduce skeleton PMU and selftests Jonathan Perry
2025-10-16 14:46 ` [PATCH 7/8] resctrl/pmu: Use mon_event_setup_read() and validate CPU Jonathan Perry
2025-10-16 14:46 ` [PATCH 8/8] resctrl/pmu: Implement .read via direct RMID read; add LLC selftest Jonathan Perry
2025-10-16 21:25 ` [PATCH 0/8] resctrl: Add perf PMU for resctrl monitoring Luck, Tony
2025-10-16 21:51 ` Luck, Tony
2025-10-17 18:17 ` Jonathan Perry
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=20251016144656.74928-6-yonch@yonch.com \
--to=yonch@yonch.com \
--cc=corbet@lwn.net \
--cc=james.morse@arm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=romeusmeister@gmail.com \
--cc=tony.luck@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).