[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b5bc883a-8a8a-4f07-a6ff-b1bd02ffc99d@redhat.com>
Date: Tue, 20 Feb 2024 17:00:46 +0100
From: David Hildenbrand <david@...hat.com>
To: James Morse <james.morse@....com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Cc: Fenghua Yu <fenghua.yu@...el.com>,
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
Subject: Re: [PATCH v9 09/24] x86/resctrl: Use __set_bit()/__clear_bit()
instead of open coding
On 13.02.24 19:44, James Morse wrote:
> The resctrl CLOSID allocator uses a single 32bit word to track which
> CLOSID are free. The setting and clearing of bits is open coded.
>
> Convert the existing open coded bit manipulations of closid_free_map
> to use __set_bit() and friends. These don't need to be atomic as this
> list is protected by the mutex.
>
> Signed-off-by: James Morse <james.morse@....com>
> Tested-by: Shaopeng Tan <tan.shaopeng@...itsu.com>
> Tested-by: Peter Newman <peternewman@...gle.com>
> Tested-by: Babu Moger <babu.moger@....com>
> Tested-by: Carl Worth <carl@...amperecomputing.com> # arm64
> Reviewed-by: Shaopeng Tan <tan.shaopeng@...itsu.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@...el.com>
> Reviewed-by: Babu Moger <babu.moger@....com>
> ---
> Changes since v6:
> * Use the __ inatomic helpers and add lockdep_assert_held() annotations to
> document how this is safe.
> * Fixed a resctrl_closid_is_free()/closid_allocated() rename in the commit
> message.
> * Use RESCTRL_RESERVED_CLOSID to improve readability.
>
> Changes since v7:
> * Removed paragraph explaining why this should be done now due to badword
> 'subsequent'.
> * Changed a comment to refer to RESCTRL_RESERVED_CLOSID.
> ---
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index dcffd1c4a476..bc6e0f83c847 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -111,7 +111,7 @@ void rdt_staged_configs_clear(void)
> * - Our choices on how to configure each resource become progressively more
> * limited as the number of resources grows.
> */
That comment talks about "free CLOSIDs in a single integer". Once could
think about rephrasing that to "free CLOSIDs in a simple bitmap."
> -static int closid_free_map;
> +static unsigned long closid_free_map;
> static int closid_free_map_len;
>
> int closids_supported(void)
> @@ -130,8 +130,8 @@ static void closid_init(void)
>
> closid_free_map = BIT_MASK(rdt_min_closid) - 1;
Now that we use "unsigned long", I was wondering for a second if we
should use "proper" bitmap functions here like
bitmap_fill(closid_free_map, rdt_min_closid);
and converting the alloc path (replace ffs() in closid_alloc()):
closid = find_first_bit(closid_free_map, closid_free_map_len);
if (closid == closid_free_map_len)
return -ENOSPC;
__clear_bit(closid, &closid_free_map);
(would get rid of the closid-- in closid_alloc())
Just a thought, so
Reviewed-by: David Hildenbrand <david@...hat.com>
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists