Re: [PATCH v7 04/24] x86/resctrl: Move rmid allocation out of mkdir_rdt_prepare()

From: Moger, Babu
Date: Thu Nov 09 2023 - 15:30:09 EST


Hi James,

On 10/25/23 13:03, James Morse wrote:
> RMID are allocated for each monitor or control group directory, because
> each of these needs its own RMID. For control groups,
> rdtgroup_mkdir_ctrl_mon() later goes on to allocate the CLOSID.
>
> MPAM's equivalent of RMID is not an independent number, so can't be
> allocated until the CLOSID is known. An RMID allocation for one CLOSID
> may fail, whereas another may succeed depending on how many monitor
> groups a control group has.
>
> The RMID allocation needs to move to be after the CLOSID has been
> allocated.
>
> Move the RMID allocation out of mkdir_rdt_prepare() to occur in its caller,
> after the mkdir_rdt_prepare() call. This allows the RMID allocator to
> know the CLOSID.
>
> Tested-by: Shaopeng Tan <tan.shaopeng@xxxxxxxxxxx>
> Tested-by: Peter Newman <peternewman@xxxxxxxxxx>
> Reviewed-by: Shaopeng Tan <tan.shaopeng@xxxxxxxxxxx>
> Reviewed-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> Signed-off-by: James Morse <james.morse@xxxxxxx>
> ---
> Changes since v2:
> * Moved kernfs_activate() later to preserve atomicity of files being visible
>
> Changes since v5:
> * Renamed out_id_free as out_closid_free.
>
> No changes since v6
> ---
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 35 +++++++++++++++++++-------
> 1 file changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 1eb3a3075093..8fb0f56f64be 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -3317,6 +3317,12 @@ static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
> return 0;
> }
>
> +static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp)
> +{
> + if (rdt_mon_capable)
> + free_rmid(rgrp->mon.rmid);
> +}

The check if (rdt_mon_capable) is extra here. Not required. Otherwise
looks good.

Reviewed-by: Babu Moger <babu.moger@xxxxxxx>