Re: [PATCH v1 7/7] cxl/region: Drop goto pattern of construct_region()
From: Li Ming
Date: Wed Feb 12 2025 - 23:15:51 EST
On 2/12/2025 5:24 AM, Dave Jiang wrote:
>
> On 2/11/25 10:36 AM, Jonathan Cameron wrote:
>> On Tue, 11 Feb 2025 15:57:27 +0800
>> Li Ming <ming.li@xxxxxxxxxxxx> wrote:
>>
>>> Some operations need to be procted by the cxl_region_rwsem in construct
>>> region(). Currently, construct_region() uses down_write() and up_write()
>>> for the cxl_region_rwsem, so there is a goto pattern after down_write()
>>> invoked to release cxl_region_rwsem.
>>>
>>> construct region() can be optimized to remove the goto pattern. The
>>> changes are creating a new function called __construct_region() which
>>> will include all checking and operations protected by the
>>> cxl_region_rwsem, and using guard(rwsem_write) to replace down_write()
>>> and up_write() in __construct_region().
>>>
>>> Signed-off-by: Li Ming <ming.li@xxxxxxxxxxxx>
>>> ---
>>> drivers/cxl/core/region.c | 71 +++++++++++++++++++++------------------
>>> 1 file changed, 39 insertions(+), 32 deletions(-)
>>>
>>> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
>>> index 36f3771818d3..170278bdcedc 100644
>>> --- a/drivers/cxl/core/region.c
>>> +++ b/drivers/cxl/core/region.c
>>> @@ -3217,49 +3217,31 @@ static int match_region_by_range(struct device *dev, const void *data)
>>> return rc;
>>> }
>>>
>>> -/* Establish an empty region covering the given HPA range */
>>> -static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd,
>>> - struct cxl_endpoint_decoder *cxled)
>>> +static int __construct_region(struct cxl_region *cxlr,
>> This is only factoring out part, so I'm not sure the naming makes sense.
>> I don't have a better name however as this is doing various different things...
>> setup_region() doesn't feel right either...
> setup_auto_region()? construct_auto_region()?
>
> DJ
Will use construct_auto_region() in V2 if no a better name, thanks for that.
Ming