* [PATCH v3 0/3] fs/resctrl: Use kvzalloc_objs() for large allocations
@ 2026-11-25 16:47 Ben Horgan
2026-11-25 16:47 ` [PATCH v3 1/3] fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs() Ben Horgan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ben Horgan @ 2026-11-25 16:47 UTC (permalink / raw)
To: ben.horgan
Cc: tony.luck, reinette.chatre, x86, Dave.Martin, james.morse,
babu.moger, fenghuay, bp, linux-kernel
When running an MPAM model with lots of PARTIDs and PMGs I hit an allocation
failure in rmid_ptrs[]. Such failures are unlikely to be seen on a real system
but addressing them helps testing. Patch 3 open codes a kvzalloc_objs() based
allocation of a bitmap as I didn't think this was sufficient justification to
add the proper helpers in the bitmap code. Please let me know if this is the
right way to go. I made this the last patch so that it doesn't need to hold up
the other two patches.
Changes since v2:
Patch 1 unchanged
Pathes 2 and 3 are new to address other large allocations (Reinette)
v2: https://lore.kernel.org/lkml/20260911160608.1091121-1-ben.horgan@arm.com/
Ben Horgan (3):
fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs()
fs/resctrl: Allocate the arrays in struct rdt_l3_mon_domain using
kvzalloc_objs()
fs/resctrl: Allocate rdt_l3_mon_domain::rmid_busy_llc using
kvzalloc_objs()
fs/resctrl/monitor.c | 4 ++--
fs/resctrl/rdtgroup.c | 18 ++++++++----------
2 files changed, 10 insertions(+), 12 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/3] fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs()
2026-11-25 16:47 [PATCH v3 0/3] fs/resctrl: Use kvzalloc_objs() for large allocations Ben Horgan
@ 2026-11-25 16:47 ` Ben Horgan
2026-11-25 16:47 ` [PATCH v3 2/3] fs/resctrl: Allocate the arrays in struct rdt_l3_mon_domain " Ben Horgan
2026-11-25 16:47 ` [PATCH v3 3/3] fs/resctrl: Allocate rdt_l3_mon_domain::rmid_busy_llc " Ben Horgan
2 siblings, 0 replies; 4+ messages in thread
From: Ben Horgan @ 2026-11-25 16:47 UTC (permalink / raw)
To: ben.horgan
Cc: tony.luck, reinette.chatre, x86, Dave.Martin, james.morse,
babu.moger, fenghuay, bp, linux-kernel
On an MPAM system the number of entries in rmid_ptrs[] is the number of PARTIDs
multiplied by the number of PMGs. The maximum possible number of PARTIDs is
0x10000 and the maximum number of PMGs is 0x100. On a system pushing the limits
of the MPAM specification this can be large enough to consistently fail the
kzalloc_objs() allocation and hence fail to mount the resctrl filesystem.
Switch to allocating rmid_ptrs[] using kvzalloc_objs() so that large allocations
fall back to vmalloc().
Fixes: 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
I found this by testing the extremes of a software model and don't expect this
to effect real systems.
---
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 04e4ea612b7c..9c383abfbbe0 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -979,7 +979,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;
@@ -1010,7 +1010,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.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] fs/resctrl: Allocate the arrays in struct rdt_l3_mon_domain using kvzalloc_objs()
2026-11-25 16:47 [PATCH v3 0/3] fs/resctrl: Use kvzalloc_objs() for large allocations Ben Horgan
2026-11-25 16:47 ` [PATCH v3 1/3] fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs() Ben Horgan
@ 2026-11-25 16:47 ` Ben Horgan
2026-11-25 16:47 ` [PATCH v3 3/3] fs/resctrl: Allocate rdt_l3_mon_domain::rmid_busy_llc " Ben Horgan
2 siblings, 0 replies; 4+ messages in thread
From: Ben Horgan @ 2026-11-25 16:47 UTC (permalink / raw)
To: ben.horgan
Cc: tony.luck, reinette.chatre, x86, Dave.Martin, james.morse,
babu.moger, fenghuay, bp, linux-kernel
Each element of rdt_l3_mon_domain::mbm_states[] has
resctrl_arch_system_num_rmid_idx() entries. On an MPAM system this is the
number of PARTIDs multiplied by the number of PMGs. The maximum possible number
of PARTIDs is 0x10000 and the maximum number of PMGs is 0x100. On a system
approaching these limits the kmalloc() based allocation will consistently fail
and hence fail to bring the monitor domain online.
The number of entries of rdt_l3_mon_domain::cntr_cfg is equal to the number of
counters. On an MPAM system the maximum number of counters is 0x1000 and so
potentially larger than a 4K page. Allocations of this size can benefit from the
fallback to vmalloc() in kvmalloc().
Switch to allocating cntr_cfg and the elements of mbm_states[] using
kvzalloc_objs() so that large allocations fall back to vmalloc().
Fixes: 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
fs/resctrl/rdtgroup.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 57ab090072c2..c55f125ce9a1 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4502,10 +4502,10 @@ static void domain_destroy_l3_mon_state(struct rdt_l3_mon_domain *d)
{
int idx;
- kfree(d->cntr_cfg);
+ kvfree(d->cntr_cfg);
bitmap_free(d->rmid_busy_llc);
for_each_mbm_idx(idx) {
- kfree(d->mbm_states[idx]);
+ kvfree(d->mbm_states[idx]);
d->mbm_states[idx] = NULL;
}
}
@@ -4620,7 +4620,6 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *h
static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_domain *d)
{
u32 idx_limit = resctrl_arch_system_num_rmid_idx();
- size_t tsize = sizeof(*d->mbm_states[0]);
enum resctrl_event_id eventid;
int idx;
@@ -4634,14 +4633,13 @@ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_d
if (!resctrl_is_mon_event_enabled(eventid))
continue;
idx = MBM_STATE_IDX(eventid);
- d->mbm_states[idx] = kcalloc(idx_limit, tsize, GFP_KERNEL);
+ d->mbm_states[idx] = kvzalloc_objs(struct mbm_state, idx_limit);
if (!d->mbm_states[idx])
goto cleanup;
}
if (resctrl_is_mbm_enabled() && r->mon.mbm_cntr_assignable) {
- tsize = sizeof(*d->cntr_cfg);
- d->cntr_cfg = kcalloc(r->mon.num_mbm_cntrs, tsize, GFP_KERNEL);
+ d->cntr_cfg = kvzalloc_objs(struct mbm_cntr_cfg, r->mon.num_mbm_cntrs);
if (!d->cntr_cfg)
goto cleanup;
}
@@ -4650,7 +4648,7 @@ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_d
cleanup:
bitmap_free(d->rmid_busy_llc);
for_each_mbm_idx(idx) {
- kfree(d->mbm_states[idx]);
+ kvfree(d->mbm_states[idx]);
d->mbm_states[idx] = NULL;
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] fs/resctrl: Allocate rdt_l3_mon_domain::rmid_busy_llc using kvzalloc_objs()
2026-11-25 16:47 [PATCH v3 0/3] fs/resctrl: Use kvzalloc_objs() for large allocations Ben Horgan
2026-11-25 16:47 ` [PATCH v3 1/3] fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs() Ben Horgan
2026-11-25 16:47 ` [PATCH v3 2/3] fs/resctrl: Allocate the arrays in struct rdt_l3_mon_domain " Ben Horgan
@ 2026-11-25 16:47 ` Ben Horgan
2 siblings, 0 replies; 4+ messages in thread
From: Ben Horgan @ 2026-11-25 16:47 UTC (permalink / raw)
To: ben.horgan
Cc: tony.luck, reinette.chatre, x86, Dave.Martin, james.morse,
babu.moger, fenghuay, bp, linux-kernel
The bitmap rdt_l3_mon_domain::rmid_busy_llc has
resctrl_arch_system_num_rmid_idx() entries. On an MPAM system this is the
number of PARTIDs multiplied by the number of PMGs. The maximum possible number
of PARTIDs is 0x10000 and the maximum number of PMGs is 0x100. On a system
approaching these limits the kmalloc() based allocation will consistently fail
and hence fail to bring the monitor domain online.
As there is no equivalent to bitmap_zalloc() that uses kvmalloc() or vmalloc(),
open code the allocation of rmid_busy_llc using kvzalloc_objs() so that large
allocations fall back to vmalloc().
Fixes: 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
fs/resctrl/rdtgroup.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index c55f125ce9a1..a8eebb5a5c4b 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4503,7 +4503,7 @@ static void domain_destroy_l3_mon_state(struct rdt_l3_mon_domain *d)
int idx;
kvfree(d->cntr_cfg);
- bitmap_free(d->rmid_busy_llc);
+ kvfree(d->rmid_busy_llc);
for_each_mbm_idx(idx) {
kvfree(d->mbm_states[idx]);
d->mbm_states[idx] = NULL;
@@ -4624,7 +4624,7 @@ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_d
int idx;
if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) {
- d->rmid_busy_llc = bitmap_zalloc(idx_limit, GFP_KERNEL);
+ d->rmid_busy_llc = kvzalloc_objs(unsigned long, BITS_TO_LONGS(idx_limit));
if (!d->rmid_busy_llc)
return -ENOMEM;
}
@@ -4646,7 +4646,7 @@ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_d
return 0;
cleanup:
- bitmap_free(d->rmid_busy_llc);
+ kvfree(d->rmid_busy_llc);
for_each_mbm_idx(idx) {
kvfree(d->mbm_states[idx]);
d->mbm_states[idx] = NULL;
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-25 16:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 16:47 [PATCH v3 0/3] fs/resctrl: Use kvzalloc_objs() for large allocations Ben Horgan
2026-11-25 16:47 ` [PATCH v3 1/3] fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs() Ben Horgan
2026-11-25 16:47 ` [PATCH v3 2/3] fs/resctrl: Allocate the arrays in struct rdt_l3_mon_domain " Ben Horgan
2026-11-25 16:47 ` [PATCH v3 3/3] fs/resctrl: Allocate rdt_l3_mon_domain::rmid_busy_llc " 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®