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

From: James Morse
Date: Thu Aug 24 2023 - 12:53:09 EST


Hi Fenghua,

On 15/08/2023 01:50, Fenghua Yu wrote:
> On 7/28/23 09:42, 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.

>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index e7178bbbd30f..7c5cfb373d03 100644
>> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> @@ -3336,10 +3344,17 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
>>       ret = 0;
>>         rdtgrp->closid = closid;
>> -    ret = rdtgroup_init_alloc(rdtgrp);
>> -    if (ret < 0)
>> +
>> +    ret = mkdir_rdt_prepare_rmid_alloc(rdtgrp);
>> +    if (ret)
>>           goto out_id_free;
>
> Is it better to change "out_id_free" to "out_closid_free"?
> It's not confused to name it "out_id_free" because only closid is freed.
> But this patch introduces new "rmid" free. So it's better to rename the label to
> "out_closid_free" and it matches the following "out_rmid_free" as well.

Yup, makes sense. I only left the existing code alone to avoid too much churn. This way is
much more readable.


Thanks,

James