On Fri, 29 Aug 2025 15:29:06 -0700 Dave Jiang <dave.jiang@xxxxxxxxx> wrote: > The current implementation of CXL memory hotplug notifier gets called > before the HMAT memory hotplug notifier. The CXL driver calculates the > access coordinates (bandwidth and latency values) for the CXL end to > end path (i.e. CPU to endpoint). When the CXL region is onlined, the CXL > memory hotplug notifier writes the access coordinates to the HMAT target > structs. Then the HMAT memory hotplug notifier is called and it creates > the access coordinates for the node sysfs attributes. > > During testing on an Intel platform, it was found that although the > newly calculated coordinates were pushed to sysfs, the sysfs attributes for > the access coordinates showed up with the wrong initiator. The system has > 4 nodes (0, 1, 2, 3) where node 0 and 1 are CPU nodes and node 2 and 3 are > CXL nodes. The expectation is that node 2 would show up as a target to node > 0: > /sys/devices/system/node/node2/access0/initiators/node0 > > However it was observed that node 2 showed up as a target under node 1: > /sys/devices/system/node/node2/access0/initiators/node1 > > The original intent of the 'ext_updated' flag in HMAT handling code was to > stop HMAT memory hotplug callback from clobbering the access coordinates > after CXL has injected its calculated coordinates and replaced the generic > target access coordinates provided by the HMAT table in the HMAT target > structs. However the flag is hacky at best and blocks the updates from > other CXL regions that are onlined in the same node later on. Remove the > 'ext_updated' flag usage and just update the access coordinates for the > nodes directly without touching HMAT target data. > > The hotplug memory callback ordering is changed. Instead of changing CXL, > move HMAT back so there's room for the levels rather than have CXL share > the same level as SLAB_CALLBACK_PRI. The change will resulting in the CXL > callback to be executed after the HMAT callback. > > With the change, the CXL hotplug memory notifier runs after the HMAT > callback. The HMAT callback will create the node sysfs attributes for > access coordinates. The CXL callback will write the access coordinates to > the now created node sysfs attributes directly and will not pollute the > HMAT target values. > > A nodemask is introduced to keep track if a node has been updated and > prevents further updates. > > Fixes: 067353a46d8c ("cxl/region: Add memory hotplug notifier for cxl region") > Cc: stable@xxxxxxxxxxxxxxx > Tested-by: Marc Herbert <marc.herbert@xxxxxxxxxxxxxxx> > Reviewed-by: Dan Williams <dan.j.williams@xxxxxxxxx> > Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxx>