Hi James, On 8/16/24 11:29, James Morse wrote: > Hi Babu, > > On 06/08/2024 23:00, Babu Moger wrote: >> Hardware provides a set of counters when mbm_cntr_assignable feature is >> supported. These counters are used for assigning the events in resctrl >> group when the feature is enabled. >> >> Introduce mbm_cntrs_free_map bitmap to track available and free counters >> and set of routines to allocate and free the counters. > > >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index ab4fab3b7cf1..c818965e36c9 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -185,6 +185,37 @@ bool closid_allocated(unsigned int closid) >> return !test_bit(closid, &closid_free_map); >> } >> >> +/* >> + * Counter bitmap for tracking the available counters. >> + * ABMC feature provides set of hardware counters for enabling events. >> + * Each event takes one hardware counter. Kernel needs to keep track >> + * of number of available counters. >> + */ >> +static DECLARE_BITMAP(mbm_cntrs_free_map, 64); > > Please make this resctrl limit of '64' a define in linux/resctrl.h so the arch code knows > what the limit is! > > MPAM platforms may have more than this - and really bad things happen if mbm_cntrs_init() > passes bitmap_fill() a value greater than 64. > > Even better - could we dynamically allocate this bitmap using the size advertised by the > architecture code? Yes. Actually, I was thinking about allocating it dynamically. It needs few other changes as well. Will do it. -- Thanks Babu Moger