Re: [PATCH] fs/resctrl: Allocate the RMID array with kvzalloc
From: Ben Horgan
Date: Wed Nov 04 2026 - 05:56:09 EST
Hi Jinjie,
On 04/11/2026 10:20, Jinjie Ruan wrote:
> setup_rmid_lru_list() sizes rmid_ptrs[] by the whole RMID index space.
> On x86 the index is the RMID, so the array stays small. On MPAM the
> index space is the product of the PARTID and PMG ranges, and with a
> large range the array is megabytes in size.
>
> kzalloc() needs a high-order page allocation for it, which fails once
> memory is fragmented, and a size above KMALLOC_MAX_SIZE always fails.
> resctrl then fails to mount.
>
> Use kvzalloc(), which falls back to vmalloc().
Yep, I ran into this too when experimenting with large PARTID counts on the FVP model. I have the
same patch here [1] and plan to repost soon with some more related kmalloc to kvmalloc changes.
[1] https://lore.kernel.org/lkml/20260911160608.1091121-1-ben.horgan@xxxxxxx/
Thanks,
Ben
>
> Fixes: 6791e0ea3071 ("x86/resctrl: Access per-rmid structures by index")
> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx> # 7.1.x
> Cc: Tony Luck <tony.luck@xxxxxxxxx>
> Cc: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> Cc: Dave Martin <Dave.Martin@xxxxxxx>
> Cc: James Morse <james.morse@xxxxxxx>
> Cc: Babu Moger <babu.moger@xxxxxxx>
> ---
> fs/resctrl/monitor.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index f69dbf66f42e..7713aa5d3996 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -1029,7 +1029,7 @@ int setup_rmid_lru_list(void)
> return 0;
>
> idx_limit = resctrl_arch_system_num_rmid_idx();
> - rmid_ptrs = kzalloc_objs(struct rmid_entry, idx_limit);
> + rmid_ptrs = kvzalloc_objs(struct rmid_entry, idx_limit);
> if (!rmid_ptrs)
> return -ENOMEM;
>
> @@ -1125,7 +1125,7 @@ void free_rmid_lru_list(void)
> return;
>
> mutex_lock(&rdtgroup_mutex);
> - kfree(rmid_ptrs);
> + kvfree(rmid_ptrs);
> rmid_ptrs = NULL;
> mutex_unlock(&rdtgroup_mutex);
> }