Skip to contentSkip to conversation

fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs()

PATCH Superseded Ben Horgan 3 participants 5 messages Jul 10 – Sep 11 RDT - resource allocation

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ben Horgan

author
#0 lore raw

PATCH 1/1 fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs()

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 7168ae330e81 ("x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl")

---
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(-)
fs/resctrl/monitor.c +2 -2
index a932a1fea818..b0c588f21de8 100644
@@ -930,7 +930,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;
 
@@ -961,7 +961,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);
 }
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines

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.

Wow!. 16 million RMIDs * 32 byte per structure = 512MB

I generally don't sweat "big" allocations on servers that have hundreds of Gbytes of memory. But that seems like a lot. Probably 99.99% of it never used (unless users regularly use resctrl to create tens of thousands of mon_data directories).

Your fix is fine. So

But maybe at some point resctrl needs some sparse, or on-demand, allocator for RMIDs? Or is this a theoretical issue and nobody is likely to build a system that implements that many PARTIDs and/or PMGs?

-Tony

author
#2 lore raw

Hi Tony,

Quoted 8 lines · Tony
Quoted 5 lines

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.

Wow!. 16 million RMIDs * 32 byte per structure = 512MB

Quoted 7 lines

I generally don't sweat "big" allocations on servers that have hundreds of Gbytes of memory. But that seems like a lot. Probably 99.99% of it never used (unless users regularly use resctrl to create tens of thousands of mon_data directories).

Your fix is fine. So

Thanks!

Quoted 4 lines

But maybe at some point resctrl needs some sparse, or on-demand, allocator for RMIDs? Or is this a theoretical issue and nobody is likely to build a system that implements that many PARTIDs and/or PMGs?

It's a theoretical issue; I don't think anyone will build anything even close to the maximum of 'PMG x PARTID'. Until the latest version, systems using CHI were limited to 1 bit of PMG. I was just checking some of the extremes of the MPAM driver with a software model.

Ben

Quoted 2 lines

-Tony

maintainer
#3 lore raw
In reply to Ben Horgan

Hi Ben,

Quoted 10 lines · Ben Horgan

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 7168ae330e81 ("x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl")

This is not the patch that added the original allocation but it is the patch that made it possible for MPAM architecture code to be added. At this point there is no MPAM support though, could commit 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate") perhaps be more accurate to present when this change may theoretically be needed?

Quoted 2 lines

---

Reinette

author
#4 lore raw

Hi Reinette,

Quoted 12 lines · Reinette Chatre

Hi Ben,

Quoted 9 lines · Ben Horgan

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

Quoted 7 lines
Quoted 1 line
Fixes 7168ae330e81 ("x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl")

This is not the patch that added the original allocation but it is the patch that made it possible for MPAM architecture code to be added. At this point there is no MPAM support though, could commit 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate") perhaps be more accurate to present when this change may theoretically be needed?

Ok, I can go with that as it's just a potential problem on MPAM.

Thanks,

Ben

Quoted 4 lines
Quoted 3 lines

---

Reinette