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