Skip to content

Commit 49b04e4

Browse files
author
James Morse
committed
arm_mpam: resctrl: Update the rmid reallocation limit
resctrl's limbo code needs to be told when the data left in a cache is small enough for the partid+pmg value to be re-allocated. x86 uses the cache size divided by the number of rmid users the cache may have. Do the same, but for the smallest cache, and with the number of partid-and-pmg users. Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com> Tested-by: Jesse Chick <jessechick@os.amperecomputing.com> Reviewed-by: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Co-developed-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent fb56b29 commit 49b04e4

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

drivers/resctrl/mpam_resctrl.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,42 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
438438
closid, rmid, val);
439439
}
440440

441+
/*
442+
* The rmid realloc threshold should be for the smallest cache exposed to
443+
* resctrl.
444+
*/
445+
static int update_rmid_limits(struct mpam_class *class)
446+
{
447+
u32 num_unique_pmg = resctrl_arch_system_num_rmid_idx();
448+
struct mpam_props *cprops = &class->props;
449+
struct cacheinfo *ci;
450+
451+
lockdep_assert_cpus_held();
452+
453+
if (!mpam_has_feature(mpam_feat_msmon_csu, cprops))
454+
return 0;
455+
456+
/*
457+
* Assume cache levels are the same size for all CPUs...
458+
* The check just requires any online CPU and it can't go offline as we
459+
* hold the cpu lock.
460+
*/
461+
ci = get_cpu_cacheinfo_level(raw_smp_processor_id(), class->level);
462+
if (!ci || ci->size == 0) {
463+
pr_debug("Could not read cache size for class %u\n",
464+
class->level);
465+
return -EINVAL;
466+
}
467+
468+
if (!resctrl_rmid_realloc_limit ||
469+
ci->size < resctrl_rmid_realloc_limit) {
470+
resctrl_rmid_realloc_limit = ci->size;
471+
resctrl_rmid_realloc_threshold = ci->size / num_unique_pmg;
472+
}
473+
474+
return 0;
475+
}
476+
441477
static bool cache_has_usable_cpor(struct mpam_class *class)
442478
{
443479
struct mpam_props *cprops = &class->props;
@@ -850,6 +886,9 @@ static void mpam_resctrl_pick_counters(void)
850886
/* CSU counters only make sense on a cache. */
851887
switch (class->type) {
852888
case MPAM_CLASS_CACHE:
889+
if (update_rmid_limits(class))
890+
break;
891+
853892
counter_update_class(QOS_L3_OCCUP_EVENT_ID, class);
854893
break;
855894
default:

0 commit comments

Comments
 (0)