[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aa3594fa-2fd6-432f-8ae4-b4e472639e37@arm.com>
Date: Thu, 24 Apr 2025 10:12:46 +0100
From: James Morse <james.morse@....com>
To: x86@...nel.org, linux-kernel@...r.kernel.org
Cc: Reinette Chatre <reinette.chatre@...el.com>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, H Peter Anvin <hpa@...or.com>,
Babu Moger <Babu.Moger@....com>, shameerali.kolothum.thodi@...wei.com,
D Scott Phillips OS <scott@...amperecomputing.com>,
carl@...amperecomputing.com, lcherian@...vell.com,
bobo.shaobowang@...wei.com, tan.shaopeng@...itsu.com,
baolin.wang@...ux.alibaba.com, Jamie Iles <quic_jiles@...cinc.com>,
Xin Hao <xhao@...ux.alibaba.com>, peternewman@...gle.com,
dfustini@...libre.com, amitsinght@...vell.com,
David Hildenbrand <david@...hat.com>, Rex Nie <rex.nie@...uarmicro.com>,
Dave Martin <dave.martin@....com>, Koba Ko <kobak@...dia.com>,
Shanker Donthineni <sdonthineni@...dia.com>, fenghuay@...dia.com,
Shaopeng Tan <tan.shaopeng@...fujitsu.com>
Subject: Re: [PATCH v8 02/21] x86/resctrl: Remove the limit on the number of
CLOSID
Hello!
On 11/04/2025 17:42, James Morse wrote:
> From: Amit Singh Tomar <amitsinght@...vell.com>
>
> Resctrl allocates and finds free CLOSID values using the bits of a u32.
> This restricts the number of control groups that can be created by
> user-space.
>
> MPAM has an architectural limit of 2^16 CLOSID values, Intel x86 could
> be extended beyond 32 values. There is at least one MPAM platform which
> supports more than 32 CLOSID values.
>
> Replace the fixed size bitmap with calls to the bitmap API to allocate
> an array of a sufficient size.
>
> ffs() returns '1' for bit 0, hence the existing code subtracts 1 from
> the index to get the CLOSID value. find_first_bit() returns the bit
> number which does not need adjusting.
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 776c8e347654..4e0308040c6e 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -152,20 +152,31 @@ int closids_supported(void)
> return closid_free_map_len;
> }
>
> -static void closid_init(void)
> +static int closid_init(void)
> {
> struct resctrl_schema *s;
> - u32 rdt_min_closid = 32;
> + u32 rdt_min_closid = ~0;
>
> /* Compute rdt_min_closid across all resources */
> list_for_each_entry(s, &resctrl_schema_all, list)
> rdt_min_closid = min(rdt_min_closid, s->num_closid);
Platforms that don't have any controls - only monitors - will still call closid_init().
Previously this initialised the fixed-sized bitmap, which was harmless as helpers like
closid_alloc() are never called.
With this change, rdt_min_closid keeps its dummy initialisation value of ~0, meaning this:
> - closid_free_map = BIT_MASK(rdt_min_closid) - 1;
> + closid_free_map = bitmap_alloc(rdt_min_closid, GFP_KERNEL);
Blows up with a greater than 'max order' error.
I've added a list_empty() check to the top of the function:
| /* Monitor only platforms still call closid_init() */
| if (list_empty(&resctrl_schema_all))
| return 0;
(list-empty as its clearer what goes wrong without the check).
I reckon this is minor, so I'll keep the existing tags.
I'm not aware of anyone building a monitor-only MPAM platform - I configured one by
accident with one of the software models!
Thanks,
James
Powered by blists - more mailing lists