Re: [PATCH v4 5/7] cxl/region: Introduce SOFT RESERVED resource removal on region teardown

From: Jonathan Cameron
Date: Tue Jun 10 2025 - 05:37:22 EST


Hi Smita,

> >> +/*
> >> + * normalize_resource
> >> + *
> >> + * The walk_iomem_res_desc() returns a copy of a resource, not a reference
> >> + * to the actual resource in the iomem_resource tree. As a result,
> >> + * __release_resource() which relies on pointer equality will fail.
> >
> > Probably want some statement on why nothing can race with this give
> > the resource_lock is not being held.
>
> Hmm, probably you are right that normalize_resource() is accessing the
> resource tree without holding resource_lock, which could lead to races.
>
> I will update the function to take a read_lock(&resource_lock) before
> walking res->parent->child..
>
> Let me know if you'd prefer this locking be handled before calling
> normalize_resource() instead..
I don't mind either way - see what looks better to you.