[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <daa69e3a-29c0-4c21-a4ae-43b2c7b8f8e6@arm.com>
Date: Thu, 8 Jan 2026 14:33:27 +0000
From: Ben Horgan <ben.horgan@....com>
To: Jonathan Cameron <jonathan.cameron@...wei.com>
Cc: amitsinght@...vell.com, baisheng.gao@...soc.com,
baolin.wang@...ux.alibaba.com, carl@...amperecomputing.com,
dave.martin@....com, david@...nel.org, dfustini@...libre.com,
fenghuay@...dia.com, gshan@...hat.com, james.morse@....com,
kobak@...dia.com, lcherian@...vell.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
peternewman@...gle.com, punit.agrawal@....qualcomm.com,
quic_jiles@...cinc.com, reinette.chatre@...el.com, rohit.mathew@....com,
scott@...amperecomputing.com, sdonthineni@...dia.com,
tan.shaopeng@...itsu.com, xhao@...ux.alibaba.com, catalin.marinas@....com,
will@...nel.org, corbet@....net, maz@...nel.org, oupton@...nel.org,
joey.gouly@....com, suzuki.poulose@....com, kvmarm@...ts.linux.dev
Subject: Re: [PATCH v2 30/45] arm_mpam: resctrl: Pre-allocate assignable
monitors
Hi Jonathan,
On 1/6/26 14:29, Jonathan Cameron wrote:
> On Fri, 19 Dec 2025 18:11:32 +0000
> Ben Horgan <ben.horgan@....com> wrote:
>
>> From: James Morse <james.morse@....com>
>>
>> When there are not enough monitors, MPAM is able to emulate ABMC by making
>> a smaller number of monitors assignable. These monitors still need to be
>> allocated from the driver, and mapped to whichever control/monitor group
>> resctrl wants to use them with.
>>
>> Add a second array to hold the monitor values indexed by resctrl's cntr_id.
>>
>> When CDP is in use, two monitors are needed so the available number of
>> counters halves. Platforms with one monitor will have zero monitors when
>> CDP is in use.
>>
>> Signed-off-by: James Morse <james.morse@....com>
>> Signed-off-by: Ben Horgan <ben.horgan@....com>
>> ---
>> Changes since rfc:
>> Move __free
>> kmalloc -> kcalloc
>>
>
> Trivial comments only,
> Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>
>
>> static inline int mpam_alloc_csu_mon(struct mpam_class *class)
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>> index bea16bc096f7..e96d320c219c 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
>
>> +/*
>> + * This must run after all event counters have been picked so that any free
>> + * running counters have already been allocated.
>> + */
>> +static int mpam_resctrl_monitor_init_abmc(struct mpam_resctrl_mon *mon)
>> +{
>> + struct mpam_resctrl_res *res = &mpam_resctrl_controls[RDT_RESOURCE_L3];
>> + struct rdt_resource *l3 = &res->resctrl_res;
>> + struct mpam_class *class = mon->class;
>> + u16 num_mbwu_mon;
>> +
>> + if (mon->mbwu_idx_to_mon) {
>> + pr_debug("monitors free running\n");
>> + return 0;
>> + }
>> +
>> + int *rmid_array __free(kfree) =
>> + kcalloc(resctrl_arch_system_num_rmid_idx(), sizeof(int), GFP_KERNEL);
>
> It's a long line, but I'd prefer sizeof(*rmid_array).
> could use kmalloc_array to avoid zeroing just before you fill it with -1.
Nice, I hadn't found kmalloc_array().
>
>> +
>> + if (!rmid_array) {
>> + pr_debug("Failed to allocate RMID array\n");
>> + return -ENOMEM;
>> + }
>> + memset(rmid_array, -1, resctrl_arch_system_num_rmid_idx() * sizeof(int));
>> +
>> + num_mbwu_mon = class->props.num_mbwu_mon;
>> + mon->assigned_counters = __alloc_mbwu_array(mon->class, num_mbwu_mon);
>> + if (IS_ERR(mon->assigned_counters))
>> + return PTR_ERR(mon->assigned_counters);
>> + mon->mbwu_idx_to_mon = no_free_ptr(rmid_array);
>> +
>> + mpam_resctrl_monitor_sync_abmc_vals(l3);
>> +
>> + return 0;
>> +}
>
>
Thanks,
Ben
Powered by blists - more mailing lists