[PATCH v2 27/45] arm_mpam: resctrl: Add support for csu counters
Ben Horgan
ben.horgan at arm.com
Thu Jan 8 02:52:00 PST 2026
Hi Shaopeng,
On 1/8/26 10:44, Shaopeng Tan (Fujitsu) wrote:
> Hello Ben,
>
>> From: James Morse <james.morse at arm.com>
>>
>> resctrl exposes a counter via a file named llc_occupancy. This isn't really
>> a counter as its value goes up and down, this is a snapshot of the cache
>> storage usage monitor.
>>
>> Add some picking code to find a cache as close as possible to the L3 that
>> supports the CSU monitor.
>>
>> If there is an L3, but it doesn't have any controls, force the L3 resource
>> to exist. The existing topology_matches_l3() and
>> mpam_resctrl_domain_hdr_init() code will ensure this looks like the L3,
>> even if the class belongs to a later cache.
>>
>> Signed-off-by: James Morse <james.morse at arm.com>
>> Signed-off-by: Ben Horgan <ben.horgan at arm.com>
>> ---
>> Changes since rfc:
>> Allow csu counters however many partid or pmg there are
>> else if -> if
>> reduce scope of local variables
>> drop has_csu
>> ---
>> drivers/resctrl/mpam_internal.h | 6 ++
>> drivers/resctrl/mpam_resctrl.c | 148 ++++++++++++++++++++++++++++++++
>> 2 files changed, 154 insertions(+)
[...]
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>> index f8d8c241797a..5fde610cc9d7 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
[...]
>>
>> +static void mpam_resctrl_monitor_init(struct mpam_resctrl_mon *mon,
>> + enum resctrl_event_id type)
>> +{
>> + struct mpam_resctrl_res *res = &mpam_resctrl_controls[RDT_RESOURCE_L3];
>> + struct rdt_resource *l3 = &res->resctrl_res;
>> +
>> + lockdep_assert_cpus_held();
>> +
>> + /* There also needs to be an L3 cache present */
>> + if (get_cpu_cacheinfo_id(smp_processor_id(), 3) == -1)
>> + return;
>> +
>> + /*
>> + * If there are no MPAM resources on L3, force it into existence.
>> + * topology_matches_l3() already ensures this looks like the L3.
>> + * The domain-ids will be fixed up by mpam_resctrl_domain_hdr_init().
>> + */
>> + if (!res->class) {
>> + pr_warn_once("Faking L3 MSC to enable counters.\n");
>> + res->class = mpam_resctrl_counters[type].class;
>> + }
>> +
>> + /* Called multiple times!, once per event type */
>> + if (exposed_mon_capable) {
>> + l3->mon_capable = true;
>> +
>> + /* Setting name is necessary on monitor only platforms */
>> + l3->name = "L3";
>> + l3->mon_scope = RESCTRL_L3_CACHE;
>> +
>> + resctrl_enable_mon_event(type);
>> +
>> + /*
>> + * Unfortunately, num_rmid doesn't mean anything for
>> + * mpam, and its exposed to user-space!
>> + * num-rmid is supposed to mean the number of groups
>> + * that can be created, both control or monitor groups.
>> + * For mpam, each control group has its own pmg/rmid
>> + * space.
>> + */
>> + l3->mon.num_rmid = 1;
>> + }
>> +}
>
> Dave posted the following patch, Will you apply it?
> https://lore.kernel.org/lkml/20250820131621.54983-1-Dave.Martin@arm.com/
Thanks for the reminder. I'll squash that into this patch.
>
> Best regards,
> Shaopeng TAN
>
>
Thanks,
Ben
More information about the linux-arm-kernel
mailing list