fs/resctrl: Allocate rmid_ptrs[] using kvzalloc_objs()
PATCH v2 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().
---
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
@@ -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); }
Signature · 1 line
2.43.0
I realised I forgot to include a changelog with this v2. The only change from v1 is an update to the fixes tag as suggested by Reinette.
Thanks,
Ben
Quoted 41 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
0x10000and the maximum number of PMGs is0x100. On a system pushing the limits of the MPAM specification this can be large enough to consistently fail thekzalloc_objs()allocation and hence fail to mount the resctrl filesystem.Switch to allocating rmid_ptrs[] using
kvzalloc_objs()so that large allocations fall back tovmalloc().Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")Signed-off-by Ben Horgan <[email protected]>Reviewed-by Tony Luck <[email protected]>---
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@@ -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); }
Reinette Chatre
maintainerHi Ben,
Quoted 24 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
0x10000and the maximum number of PMGs is0x100. On a system pushing the limits of the MPAM specification this can be large enough to consistently fail thekzalloc_objs()allocation and hence fail to mount the resctrl filesystem.Switch to allocating rmid_ptrs[] using
kvzalloc_objs()so that large allocations fall back tovmalloc().Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")Signed-off-by Ben Horgan <[email protected]>Reviewed-by Tony Luck <[email protected]>---
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 +0
-0
fs/resctrl/monitor.c int setup_rmid_lru_list(void) · line 985
Quoted 8 lines
fs/resctrl/monitor.c +1
-1@@ -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 ;
resctrl_arch_system_num_rmid_idx() that guides the rmid_ptrs[] allocation is also used to size the L3 monitoring state rdt_l3_mon_domain::rmid_busy_llc[] and rdt_l3_mon_domain::mbm_states[]. Each RMID is expected to have associated states in these structures so to fully support this their allocation needs to change also? I did a quick check and there does not seem to be a vmalloc variant for bitmap allocation though so that may need to be customized or created.
Reinette
Hi Reinette,
Quoted 29 lines · Reinette Chatre
Hi Ben,
Quoted 26 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
0x10000and the maximum number of PMGs is0x100. On a system pushing the limits of the MPAM specification this can be large enough to consistently fail thekzalloc_objs()allocation and hence fail to mount the resctrl filesystem.Switch to allocating rmid_ptrs[] using
kvzalloc_objs()so that large allocations fall back tovmalloc().Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")Signed-off-by Ben Horgan <[email protected]>Reviewed-by Tony Luck <[email protected]>---
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 +0
-0@@ -979,7 +979,7 @@ int setup_rmid_lru_list(void)return 0 ;
Quoted 12 lines
fs/resctrl/monitor.c int setup_rmid_lru_list(void) · line 985
Quoted 6 lines
fs/resctrl/monitor.c +1
-1idx_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 ;
resctrl_arch_system_num_rmid_idx()that guides the rmid_ptrs[] allocation is also used to size the L3 monitoring state rdt_l3_mon_domain::rmid_busy_llc[] and rdt_l3_mon_domain::mbm_states[]. Each RMID is expected to have associated states in these structures so to fully support this their allocation needs to change also?
At least, rdt_l3_mon_domain::mbm_states[] should use kvcalloc. I realise that I didn't hit this on the model I was using to test this didn't have memory bandwidth monitors.
For, rdt_l3_mon_domain::rmid_busy_llc[] the allocation will have succeeded on a model as there are cache occupancy counters. The allocation here is smaller than the others as it allocates a bit per RMID rather than multiple bytes per RMID like the other two allocations. This gives a limit here of 0x100 * 0x10000 / 0x8 = 0x200000 bytes, 2MB. My view here would be that, although this is quite big, it's not standing in the way of testing on a model and physical systems even approaching this size are not likely to ever be built and so doesn't justify either open coding the bitmap allocation and freeing or creating a new bitmap allocator. Does that make sense?
Quoted 3 lines
I did a quick check and there does not seem to be a vmalloc variant for bitmap allocation though so that may need to be customized or created.
Yeah, I don't see one either.
Thanks,
Ben>
Quoted 4 lines
Reinette
Reinette Chatre
maintainerHi Ben,
Quoted 44 lines · Ben Horgan
Quoted 27 lines · Reinette Chatre
Quoted 26 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
0x10000and the maximum number of PMGs is0x100. On a system pushing the limits of the MPAM specification this can be large enough to consistently fail thekzalloc_objs()allocation and hence fail to mount the resctrl filesystem.Switch to allocating rmid_ptrs[] using
kvzalloc_objs()so that large allocations fall back tovmalloc().Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")Signed-off-by Ben Horgan <[email protected]>Reviewed-by Tony Luck <[email protected]>---
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 +0
-0@@ -979,7 +979,7 @@ int setup_rmid_lru_list(void)return 0 ;Quoted 12 lines
fs/resctrl/monitor.c int setup_rmid_lru_list(void) · line 985
Quoted 6 lines
fs/resctrl/monitor.c +1
-1idx_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 ;
resctrl_arch_system_num_rmid_idx()that guides the rmid_ptrs[] allocation is also used to size the L3 monitoring state rdt_l3_mon_domain::rmid_busy_llc[] and rdt_l3_mon_domain::mbm_states[]. Each RMID is expected to have associated states in these structures so to fully support this their allocation needs to change also?At least, rdt_l3_mon_domain::mbm_states[] should use kvcalloc. I realise that I didn't hit this on the model I was using to test this didn't have memory bandwidth monitors.
Quoted 7 lines
For, rdt_l3_mon_domain::rmid_busy_llc[] the allocation will have succeeded on a model as there are cache occupancy counters. The allocation here is smaller than the others as it allocates a bit per RMID rather than multiple bytes per RMID like the other two allocations. This gives a limit here of
0x100*0x10000/0x8=0x200000bytes, 2MB. My view here would be that, although this is quite big, it's not standing in the way of testing on a model and physical systems even approaching this size are not likely to ever be built and so doesn't justify either open coding the bitmap allocation and freeing or creating a new bitmap allocator. Does that make sense?
I think this may still stand in the way of testing on a model since it depends on when that testing onlines the domains and how fragmented the memory is at that time. A simple "boot with all domains already online" may be ok but I am not sure.
Reinette