mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs/resctrl: Allocate the RMID array with kvzalloc
@ 2026-11-04 10:20 Jinjie Ruan
  2026-11-04 10:51 ` Ben Horgan
  0 siblings, 1 reply; 2+ messages in thread
From: Jinjie Ruan @ 2026-11-04 10:20 UTC (permalink / raw)
  To: tony.luck, ben.horgan, reinette.chatre, Dave.Martin, james.morse,
	babu.moger, bp, tan.shaopeng, x86, linux-kernel
  Cc: ruanjinjie

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().

Fixes: 6791e0ea3071 ("x86/resctrl: Access per-rmid structures by index")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: <stable@vger.kernel.org> # 7.1.x
Cc: Tony Luck <tony.luck@intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Babu Moger <babu.moger@amd.com>
---
 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);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs/resctrl: Allocate the RMID array with kvzalloc
  2026-11-04 10:20 [PATCH] fs/resctrl: Allocate the RMID array with kvzalloc Jinjie Ruan
@ 2026-11-04 10:51 ` Ben Horgan
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Horgan @ 2026-11-04 10:51 UTC (permalink / raw)
  To: Jinjie Ruan, tony.luck, reinette.chatre, Dave.Martin,
	james.morse, babu.moger, bp, tan.shaopeng, x86, linux-kernel

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@arm.com/

Thanks,

Ben

> 
> Fixes: 6791e0ea3071 ("x86/resctrl: Access per-rmid structures by index")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Cc: <stable@vger.kernel.org> # 7.1.x
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Reinette Chatre <reinette.chatre@intel.com>
> Cc: Dave Martin <Dave.Martin@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Babu Moger <babu.moger@amd.com>
> ---
>  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);
>  }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-04 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 10:20 [PATCH] fs/resctrl: Allocate the RMID array with kvzalloc Jinjie Ruan
2026-11-04 10:51 ` Ben Horgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®