Skip to content

Commit 545a2db

Browse files
fyu1nvidia-bfigg
authored andcommitted
NVIDIA: SAUCE: arm_mpam: Fix mbm_total_bytes and MBM counter assignment
BugLink: https://bugs.launchpad.net/bugs/2157922 This patch fixes a few issues: 1. To enable MBW total bytes, continue MBWU counter selection after CSU setup. This follows upstream 7.1. 2. Use mbm_cntr_assignable for assignment enablement so occupancy and MBWU sharing a class do not break mbm_L3_assignments. This follows commit 4766d7e https://gitlab.arm.com/linux-arm/linux-bh.git mpam_abmc_v4 3. Always bind picked MBWU to mbm_total_bytes. This follows commit b2bbf3b https://gitlab.arm.com/linux-arm/linux-bh.git mpam_abmc_v4 4. Rebind mbm_total_bytes at monitor init to the resource that owns the MBWU class via resctrl_mon_event_set_resource(), so memory-level MSC platforms expose mbm_total_bytes under mon_MB_* and mbm_MB_assignments. This fix is necessary when only MBW total bytes (i.e. no MBW local bytes) is supported. Signed-off-by: Fenghua Yu <fenghuay@nvidia.com> Acked-by: Matthew R. Ochs <mochs@nvidia.com> Acked-by: Carol L Soto <csoto@nvidia.com> Signed-off-by: Brad Figg <bfigg@nvidia.com>
1 parent ffc85b4 commit 545a2db

3 files changed

Lines changed: 30 additions & 55 deletions

File tree

drivers/resctrl/mpam_resctrl.c

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,6 @@ static void resctrl_reset_task_closids(void)
179179
read_unlock(&tasklist_lock);
180180
}
181181

182-
static struct mpam_resctrl_mon *mpam_resctrl_mon_from_res(struct mpam_resctrl_res *res)
183-
{
184-
struct mpam_resctrl_mon *mon;
185-
enum resctrl_event_id eventid;
186-
187-
if (!res->class)
188-
return NULL;
189-
190-
for_each_mpam_resctrl_mon(mon, eventid) {
191-
if (mon->class == res->class)
192-
return mon;
193-
}
194-
return NULL;
195-
}
196-
197182
static struct mpam_resctrl_res *mpam_resctrl_res_from_mon(struct mpam_resctrl_mon *mon)
198183
{
199184
struct mpam_resctrl_res *res;
@@ -1337,7 +1322,7 @@ static void mpam_resctrl_pick_counters(void)
13371322
update_rmid_limits(cache_size);
13381323

13391324
counter_update_class(QOS_L3_OCCUP_EVENT_ID, class);
1340-
return;
1325+
break;
13411326
default:
13421327
return;
13431328
}
@@ -1350,25 +1335,7 @@ static void mpam_resctrl_pick_counters(void)
13501335
traffic_matches_l3(class)))) {
13511336
pr_debug("class %u has usable MBWU, and matches L3 topology", class->level);
13521337

1353-
/*
1354-
* MBWU counters may be 'local' or 'total' depending on
1355-
* where they are in the topology. Counters on caches
1356-
* are assumed to be local. If it's on the memory
1357-
* controller, its assumed to be global.
1358-
* TODO: check mbm_local matches NUMA boundaries...
1359-
*/
1360-
switch (class->type) {
1361-
case MPAM_CLASS_CACHE:
1362-
counter_update_class(QOS_L3_MBM_LOCAL_EVENT_ID,
1363-
class);
1364-
break;
1365-
case MPAM_CLASS_MEMORY:
1366-
counter_update_class(QOS_L3_MBM_TOTAL_EVENT_ID,
1367-
class);
1368-
break;
1369-
default:
1370-
break;
1371-
}
1338+
counter_update_class(QOS_L3_MBM_TOTAL_EVENT_ID, class);
13721339
}
13731340
}
13741341

@@ -1417,16 +1384,13 @@ void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_l3_mon_domain *
14171384

14181385
bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r)
14191386
{
1420-
struct mpam_resctrl_res *res;
1421-
struct mpam_resctrl_mon *mon;
1422-
1423-
res = container_of(r, struct mpam_resctrl_res, resctrl_res);
1424-
1425-
mon = mpam_resctrl_mon_from_res(res);
1426-
if (!mon)
1427-
return false;
1428-
1429-
return mon->assigned_counters ? true : false;
1387+
/*
1388+
* mbm_cntr_assignable is set only when ABMC is initialised on this
1389+
* resource. Multiple monitor events may share res->class (e.g.
1390+
* occupancy and MBWU), so assignment support must not be inferred
1391+
* from mon->assigned_counters via a class lookup on the wrong event.
1392+
*/
1393+
return r->mon.mbm_cntr_assignable;
14301394
}
14311395

14321396
int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable)
@@ -1641,19 +1605,18 @@ static int mpam_resctrl_monitor_init(struct mpam_resctrl_mon *mon,
16411605
*/
16421606
r->mon.num_rmid = resctrl_arch_system_num_rmid_idx();
16431607

1644-
if (resctrl_enable_mon_event(type, false, 0, NULL))
1645-
r->mon_capable = true;
1646-
1647-
switch (type) {
1648-
case QOS_L3_MBM_LOCAL_EVENT_ID:
1649-
case QOS_L3_MBM_TOTAL_EVENT_ID:
1608+
if (type == QOS_L3_MBM_TOTAL_EVENT_ID) {
16501609
mpam_resctrl_monitor_init_abmc(mon);
1651-
1652-
return 0;
1653-
default:
1654-
return 0;
1610+
/*
1611+
* Bind mbm_total_bytes to the resource backing this monitor
1612+
* (L3 or MBA) so mon_data, mbm_*_assignments, and events align.
1613+
*/
1614+
resctrl_mon_event_set_resource(type, r->rid);
16551615
}
16561616

1617+
if (resctrl_enable_mon_event(type, false, 0, NULL))
1618+
r->mon_capable = true;
1619+
16571620
return 0;
16581621
}
16591622

fs/resctrl/monitor.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,15 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] = {
10181018
MON_EVENT(PMT_EVENT_UOPS_RETIRED, "uops_retired", RDT_RESOURCE_PERF_PKG, false),
10191019
};
10201020

1021+
void resctrl_mon_event_set_resource(enum resctrl_event_id eventid,
1022+
enum resctrl_res_level rid)
1023+
{
1024+
if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >= QOS_NUM_EVENTS))
1025+
return;
1026+
1027+
mon_event_all[eventid].rid = rid;
1028+
}
1029+
10211030
bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,
10221031
unsigned int binary_bits, void *arch_priv)
10231032
{

include/linux/resctrl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
470470
bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,
471471
unsigned int binary_bits, void *arch_priv);
472472

473+
void resctrl_mon_event_set_resource(enum resctrl_event_id eventid,
474+
enum resctrl_res_level rid);
475+
473476
bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid);
474477

475478
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);

0 commit comments

Comments
 (0)