Skip to content

Commit 4980c17

Browse files
committed
Merge tag 'x86_cache_for_6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 resctrl update from Dave Hansen: "Reduce redundant counter reads with resctrl refactoring" * tag 'x86_cache_for_6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/resctrl: Avoid redundant counter read in __mon_event_count()
2 parents 682f7bb + 322b72e commit 4980c17

1 file changed

Lines changed: 19 additions & 24 deletions

File tree

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

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -383,41 +383,36 @@ void free_rmid(u32 rmid)
383383
list_add_tail(&entry->list, &rmid_free_lru);
384384
}
385385

386+
static struct mbm_state *get_mbm_state(struct rdt_domain *d, u32 rmid,
387+
enum resctrl_event_id evtid)
388+
{
389+
switch (evtid) {
390+
case QOS_L3_MBM_TOTAL_EVENT_ID:
391+
return &d->mbm_total[rmid];
392+
case QOS_L3_MBM_LOCAL_EVENT_ID:
393+
return &d->mbm_local[rmid];
394+
default:
395+
return NULL;
396+
}
397+
}
398+
386399
static int __mon_event_count(u32 rmid, struct rmid_read *rr)
387400
{
388401
struct mbm_state *m;
389402
u64 tval = 0;
390403

391-
if (rr->first)
404+
if (rr->first) {
392405
resctrl_arch_reset_rmid(rr->r, rr->d, rmid, rr->evtid);
406+
m = get_mbm_state(rr->d, rmid, rr->evtid);
407+
if (m)
408+
memset(m, 0, sizeof(struct mbm_state));
409+
return 0;
410+
}
393411

394412
rr->err = resctrl_arch_rmid_read(rr->r, rr->d, rmid, rr->evtid, &tval);
395413
if (rr->err)
396414
return rr->err;
397415

398-
switch (rr->evtid) {
399-
case QOS_L3_OCCUP_EVENT_ID:
400-
rr->val += tval;
401-
return 0;
402-
case QOS_L3_MBM_TOTAL_EVENT_ID:
403-
m = &rr->d->mbm_total[rmid];
404-
break;
405-
case QOS_L3_MBM_LOCAL_EVENT_ID:
406-
m = &rr->d->mbm_local[rmid];
407-
break;
408-
default:
409-
/*
410-
* Code would never reach here because an invalid
411-
* event id would fail in resctrl_arch_rmid_read().
412-
*/
413-
return -EINVAL;
414-
}
415-
416-
if (rr->first) {
417-
memset(m, 0, sizeof(struct mbm_state));
418-
return 0;
419-
}
420-
421416
rr->val += tval;
422417

423418
return 0;

0 commit comments

Comments
 (0)