Re: [PATCH v2] cxl/region: Remove lock from memory notifier callback
From: Jonathan Cameron
Date: Tue Aug 27 2024 - 12:31:51 EST
On Wed, 14 Aug 2024 12:49:39 -0500
Ira Weiny <ira.weiny@xxxxxxxxx> wrote:
> In testing Dynamic Capacity Device (DCD) support, a lockdep splat
> revealed an ABBA issue between the memory notifiers and the DCD extent
> processing code.[0] Changing the lock ordering within DCD proved
> difficult because regions must be stable while searching for the proper
> region and then the device lock must be held to properly notify the DAX
> region driver of memory changes.
>
> Dan points out in the thread that notifiers should be able to trust that
> it is safe to access static data. Region data is static once the device
> is realized and until it's destruction. Thus it is better to manage the
> notifiers within the region driver.
>
> Remove the need for a lock by ensuring the notifiers are active only
> during the region's lifetime.
>
> Furthermore, remove cxl_region_nid() because resource can't be NULL
> while the region is stable.
>
> Link: https://lore.kernel.org/all/66b4cf539a79b_a36e829416@iweiny-mobl.notmuch/ [0]
> Cc: Huang, Ying <ying.huang@xxxxxxxxx>
> Suggested-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
Seems a sensible cleanup irrespective of the bug / future issue.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>