Re: [PATCH v6 5/9] dax: Track all dax_region allocations under a global resource tree

Koralahalli Channabasappa, Smita
2026-03-12T21:31:51Z

On 3/11/2026 5:27 PM, Dan Williams wrote:
> Smita Koralahalli wrote:
>> Introduce a global "DAX Regions" resource root and register each
>> dax_region->res under it via request_resource(). Release the resource on
>> dax_region teardown.
>>
>> By enforcing a single global namespace for dax_region allocations, this
>> ensures only one of dax_hmem or dax_cxl can successfully register a
>> dax_region for a given range.
>>
>> Co-developed-by: Dan Williams <dan.j.williams@intel.com>
>
> Did I send any code for this? If I suggested the locking below,
> apologies, otherwise Suggested-by is expected unless code is adopted
> from another patch.

No sorry the locking was added by me. I will make the changes and drop
the locking.

>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com>
>> ---
>> drivers/dax/bus.c | 23 ++++++++++++++++++++---
>> 1 file changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
>> index fde29e0ad68b..5f387feb95f0 100644
>> --- a/drivers/dax/bus.c
>> +++ b/drivers/dax/bus.c
>> @@ -10,6 +10,7 @@
>> #include "dax-private.h"
>> #include "bus.h"
>>
>> +static struct resource dax_regions = DEFINE_RES_MEM_NAMED(0, -1, "DAX Regions");
>> static DEFINE_MUTEX(dax_bus_lock);
>>
>> /*
>> @@ -625,6 +626,8 @@ static void dax_region_unregister(void *region)
>> {
>> struct dax_region *dax_region = region;
>>
>> + scoped_guard(rwsem_write, &dax_region_rwsem)
>> + release_resource(&dax_region->res);
>
> I continue to dislike what scoped_guard() does to indentation. Often
> scoped_guard() usage can just be replaced by "helper that uses guard()"
>
> However, dax_region_rwsem protects subdivision of a dax_region, not
> coordination across regions.
>
> Also, release_resource() and request_resource() are already protected by
> the resource_lock, why is a new lock needed?

You are right. I will remove

Thanks
Smita
>