Skip to content

Commit 064855a

Browse files
babumogersuryasaimadhu
authored andcommitted
x86/resctrl: Fix default monitoring groups reporting
Creating a new sub monitoring group in the root /sys/fs/resctrl leads to getting the "Unavailable" value for mbm_total_bytes and mbm_local_bytes on the entire filesystem. Steps to reproduce: 1. mount -t resctrl resctrl /sys/fs/resctrl/ 2. cd /sys/fs/resctrl/ 3. cat mon_data/mon_L3_00/mbm_total_bytes 23189832 4. Create sub monitor group: mkdir mon_groups/test1 5. cat mon_data/mon_L3_00/mbm_total_bytes Unavailable When a new monitoring group is created, a new RMID is assigned to the new group. But the RMID is not active yet. When the events are read on the new RMID, it is expected to report the status as "Unavailable". When the user reads the events on the default monitoring group with multiple subgroups, the events on all subgroups are consolidated together. Currently, if any of the RMID reads report as "Unavailable", then everything will be reported as "Unavailable". Fix the issue by discarding the "Unavailable" reads and reporting all the successful RMID reads. This is not a problem on Intel systems as Intel reports 0 on Inactive RMIDs. Fixes: d89b737 ("x86/intel_rdt/cqm: Add mon_data") Reported-by: Paweł Szulik <[email protected]> Signed-off-by: Babu Moger <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Reinette Chatre <[email protected]> Cc: [email protected] Link: https://bugzilla.kernel.org/show_bug.cgi?id=213311 Link: https://lkml.kernel.org/r/162793309296.9224.15871659871696482080.stgit@bmoger-ubuntu
1 parent 839ad22 commit 064855a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,14 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int width)
285285
return chunks >>= shift;
286286
}
287287

288-
static int __mon_event_count(u32 rmid, struct rmid_read *rr)
288+
static u64 __mon_event_count(u32 rmid, struct rmid_read *rr)
289289
{
290290
struct mbm_state *m;
291291
u64 chunks, tval;
292292

293293
tval = __rmid_read(rmid, rr->evtid);
294294
if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL)) {
295-
rr->val = tval;
296-
return -EINVAL;
295+
return tval;
297296
}
298297
switch (rr->evtid) {
299298
case QOS_L3_OCCUP_EVENT_ID:
@@ -305,12 +304,6 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr)
305304
case QOS_L3_MBM_LOCAL_EVENT_ID:
306305
m = &rr->d->mbm_local[rmid];
307306
break;
308-
default:
309-
/*
310-
* Code would never reach here because
311-
* an invalid event id would fail the __rmid_read.
312-
*/
313-
return -EINVAL;
314307
}
315308

316309
if (rr->first) {
@@ -361,23 +354,29 @@ void mon_event_count(void *info)
361354
struct rdtgroup *rdtgrp, *entry;
362355
struct rmid_read *rr = info;
363356
struct list_head *head;
357+
u64 ret_val;
364358

365359
rdtgrp = rr->rgrp;
366360

367-
if (__mon_event_count(rdtgrp->mon.rmid, rr))
368-
return;
361+
ret_val = __mon_event_count(rdtgrp->mon.rmid, rr);
369362

370363
/*
371-
* For Ctrl groups read data from child monitor groups.
364+
* For Ctrl groups read data from child monitor groups and
365+
* add them together. Count events which are read successfully.
366+
* Discard the rmid_read's reporting errors.
372367
*/
373368
head = &rdtgrp->mon.crdtgrp_list;
374369

375370
if (rdtgrp->type == RDTCTRL_GROUP) {
376371
list_for_each_entry(entry, head, mon.crdtgrp_list) {
377-
if (__mon_event_count(entry->mon.rmid, rr))
378-
return;
372+
if (__mon_event_count(entry->mon.rmid, rr) == 0)
373+
ret_val = 0;
379374
}
380375
}
376+
377+
/* Report error if none of rmid_reads are successful */
378+
if (ret_val)
379+
rr->val = ret_val;
381380
}
382381

383382
/*

0 commit comments

Comments
 (0)