Skip to content

Commit c8c7d3d

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Fill out rmid_read structure for smp_call*() to read a counter
mon_event_read() fills out most fields of the struct rmid_read that is passed via an smp_call*() function to a CPU that is part of the correct domain to read the monitor counters. With Sub-NUMA Cluster (SNC) mode there are now two cases to handle: 1) Reading a file that returns a value for a single domain. + Choose the CPU to execute from the domain cpu_mask 2) Reading a file that must sum across domains sharing an L3 cache instance. + Indicate to called code that a sum is needed by passing a NULL rdt_mon_domain pointer. + Choose the CPU from the L3 shared_cpu_map. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Tested-by: Babu Moger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6b48b80 commit c8c7d3d

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ static int smp_mon_event_count(void *arg)
515515

516516
void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
517517
struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
518-
int evtid, int first)
518+
cpumask_t *cpumask, int evtid, int first)
519519
{
520520
int cpu;
521521

@@ -536,7 +536,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
536536
return;
537537
}
538538

539-
cpu = cpumask_any_housekeeping(&d->hdr.cpu_mask, RESCTRL_PICK_ANY_CPU);
539+
cpu = cpumask_any_housekeeping(cpumask, RESCTRL_PICK_ANY_CPU);
540540

541541
/*
542542
* cpumask_any_housekeeping() prefers housekeeping CPUs, but
@@ -545,7 +545,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
545545
* counters on some platforms if its called in IRQ context.
546546
*/
547547
if (tick_nohz_full_cpu(cpu))
548-
smp_call_function_any(&d->hdr.cpu_mask, mon_event_count, rr, 1);
548+
smp_call_function_any(cpumask, mon_event_count, rr, 1);
549549
else
550550
smp_call_on_cpu(cpu, smp_mon_event_count, rr, false);
551551

@@ -574,16 +574,40 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
574574
resid = md.u.rid;
575575
domid = md.u.domid;
576576
evtid = md.u.evtid;
577-
578577
r = &rdt_resources_all[resid].r_resctrl;
579-
hdr = rdt_find_domain(&r->mon_domains, domid, NULL);
580-
if (!hdr || WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN)) {
578+
579+
if (md.u.sum) {
580+
/*
581+
* This file requires summing across all domains that share
582+
* the L3 cache id that was provided in the "domid" field of the
583+
* mon_data_bits union. Search all domains in the resource for
584+
* one that matches this cache id.
585+
*/
586+
list_for_each_entry(d, &r->mon_domains, hdr.list) {
587+
if (d->ci->id == domid) {
588+
rr.ci = d->ci;
589+
mon_event_read(&rr, r, NULL, rdtgrp,
590+
&d->ci->shared_cpu_map, evtid, false);
591+
goto checkresult;
592+
}
593+
}
581594
ret = -ENOENT;
582595
goto out;
596+
} else {
597+
/*
598+
* This file provides data from a single domain. Search
599+
* the resource to find the domain with "domid".
600+
*/
601+
hdr = rdt_find_domain(&r->mon_domains, domid, NULL);
602+
if (!hdr || WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN)) {
603+
ret = -ENOENT;
604+
goto out;
605+
}
606+
d = container_of(hdr, struct rdt_mon_domain, hdr);
607+
mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false);
583608
}
584-
d = container_of(hdr, struct rdt_mon_domain, hdr);
585609

586-
mon_event_read(&rr, r, d, rdtgrp, evtid, false);
610+
checkresult:
587611

588612
if (rr.err == -EIO)
589613
seq_puts(m, "Error\n");

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ void mon_event_count(void *info);
632632
int rdtgroup_mondata_show(struct seq_file *m, void *arg);
633633
void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
634634
struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
635-
int evtid, int first);
635+
cpumask_t *cpumask, int evtid, int first);
636636
void mbm_setup_overflow_handler(struct rdt_mon_domain *dom,
637637
unsigned long delay_ms,
638638
int exclude_cpu);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3070,7 +3070,7 @@ static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,
30703070
return ret;
30713071

30723072
if (!do_sum && is_mbm_event(mevt->evtid))
3073-
mon_event_read(&rr, r, d, prgrp, mevt->evtid, true);
3073+
mon_event_read(&rr, r, d, prgrp, &d->hdr.cpu_mask, mevt->evtid, true);
30743074
}
30753075

30763076
return 0;

0 commit comments

Comments
 (0)