Re: [PATCH v2] cxl/region: Remove lock from memory notifier callback

From: Huang, Ying
Date: Tue Sep 03 2024 - 22:18:26 EST


Hi, Ira,

Ira Weiny <ira.weiny@xxxxxxxxx> writes:

[snip]

> @@ -2391,18 +2389,6 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
> return true;
> }
>
> -static int cxl_region_nid(struct cxl_region *cxlr)
> -{
> - struct cxl_region_params *p = &cxlr->params;
> - struct resource *res;
> -
> - guard(rwsem_read)(&cxl_region_rwsem);
> - res = p->res;
> - if (!res)
> - return NUMA_NO_NODE;
> - return phys_to_target_node(res->start);
> -}
> -
> static int cxl_region_perf_attrs_callback(struct notifier_block *nb,
> unsigned long action, void *arg)
> {
> @@ -2415,7 +2401,7 @@ static int cxl_region_perf_attrs_callback(struct notifier_block *nb,
> if (nid == NUMA_NO_NODE || action != MEM_ONLINE)
> return NOTIFY_DONE;
>
> - region_nid = cxl_region_nid(cxlr);
> + region_nid = phys_to_target_node(cxlr->params.res->start);

Better to add some comments about why we don't need to hold
cxl_region_rwsem to access cxlr->params.res here?

Otherwise, LGTM, Thanks! Feel free to add

Reviewed-by: "Huang, Ying" <ying.huang@xxxxxxxxx>

in the future versions.

> if (nid != region_nid)
> return NOTIFY_DONE;
>
> @@ -2434,7 +2420,7 @@ static int cxl_region_calculate_adistance(struct notifier_block *nb,
> int *adist = data;
> int region_nid;
>
> - region_nid = cxl_region_nid(cxlr);
> + region_nid = phys_to_target_node(cxlr->params.res->start);
> if (nid != region_nid)
> return NOTIFY_OK;
>

[snip]

--
Best Regards,
Huang, Ying