Skip to content

Commit 4dfa641

Browse files
committed
Merge branch 'for-6.18/cxl-update-access-coordinates' into cxl-for-next
Update the CXL memory hotplug notifier to update the NUMA node access coordinates directly rather than go through the HMAT memory hotplug notifier.
2 parents a414408 + e99ecbc commit 4dfa641

8 files changed

Lines changed: 61 additions & 71 deletions

File tree

drivers/acpi/numa/hmat.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ struct memory_target {
7474
struct node_cache_attrs cache_attrs;
7575
u8 gen_port_device_handle[ACPI_SRAT_DEVICE_HANDLE_SIZE];
7676
bool registered;
77-
bool ext_updated; /* externally updated */
7877
};
7978

8079
struct memory_initiator {
@@ -368,35 +367,6 @@ static void hmat_update_target_access(struct memory_target *target,
368367
}
369368
}
370369

371-
int hmat_update_target_coordinates(int nid, struct access_coordinate *coord,
372-
enum access_coordinate_class access)
373-
{
374-
struct memory_target *target;
375-
int pxm;
376-
377-
if (nid == NUMA_NO_NODE)
378-
return -EINVAL;
379-
380-
pxm = node_to_pxm(nid);
381-
guard(mutex)(&target_lock);
382-
target = find_mem_target(pxm);
383-
if (!target)
384-
return -ENODEV;
385-
386-
hmat_update_target_access(target, ACPI_HMAT_READ_LATENCY,
387-
coord->read_latency, access);
388-
hmat_update_target_access(target, ACPI_HMAT_WRITE_LATENCY,
389-
coord->write_latency, access);
390-
hmat_update_target_access(target, ACPI_HMAT_READ_BANDWIDTH,
391-
coord->read_bandwidth, access);
392-
hmat_update_target_access(target, ACPI_HMAT_WRITE_BANDWIDTH,
393-
coord->write_bandwidth, access);
394-
target->ext_updated = true;
395-
396-
return 0;
397-
}
398-
EXPORT_SYMBOL_GPL(hmat_update_target_coordinates);
399-
400370
static __init void hmat_add_locality(struct acpi_hmat_locality *hmat_loc)
401371
{
402372
struct memory_locality *loc;
@@ -773,10 +743,6 @@ static void hmat_update_target_attrs(struct memory_target *target,
773743
u32 best = 0;
774744
int i;
775745

776-
/* Don't update if an external agent has changed the data. */
777-
if (target->ext_updated)
778-
return;
779-
780746
/* Don't update for generic port if there's no device handle */
781747
if ((access == NODE_ACCESS_CLASS_GENPORT_SINK_LOCAL ||
782748
access == NODE_ACCESS_CLASS_GENPORT_SINK_CPU) &&

drivers/base/node.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,44 @@ void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
248248
}
249249
EXPORT_SYMBOL_GPL(node_set_perf_attrs);
250250

251+
/**
252+
* node_update_perf_attrs - Update the performance values for given access class
253+
* @nid: Node identifier to be updated
254+
* @coord: Heterogeneous memory performance coordinates
255+
* @access: The access class for the given attributes
256+
*/
257+
void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
258+
enum access_coordinate_class access)
259+
{
260+
struct node_access_nodes *access_node;
261+
struct node *node;
262+
int i;
263+
264+
if (WARN_ON_ONCE(!node_online(nid)))
265+
return;
266+
267+
node = node_devices[nid];
268+
list_for_each_entry(access_node, &node->access_list, list_node) {
269+
if (access_node->access != access)
270+
continue;
271+
272+
access_node->coord = *coord;
273+
for (i = 0; access_attrs[i]; i++) {
274+
sysfs_notify(&access_node->dev.kobj,
275+
NULL, access_attrs[i]->name);
276+
}
277+
break;
278+
}
279+
280+
/* When setting CPU access coordinates, update mempolicy */
281+
if (access != ACCESS_COORDINATE_CPU)
282+
return;
283+
284+
if (mempolicy_set_node_perf(nid, coord))
285+
pr_info("failed to set mempolicy attrs for node %d\n", nid);
286+
}
287+
EXPORT_SYMBOL_GPL(node_update_perf_attrs);
288+
251289
/**
252290
* struct node_cache_info - Internal tracking for memory node caches
253291
* @dev: Device represeting the cache level

drivers/cxl/core/cdat.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,14 +1075,3 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
10751075
cxlr->coord[i].write_bandwidth += perf->coord[i].write_bandwidth;
10761076
}
10771077
}
1078-
1079-
int cxl_update_hmat_access_coordinates(int nid, struct cxl_region *cxlr,
1080-
enum access_coordinate_class access)
1081-
{
1082-
return hmat_update_target_coordinates(nid, &cxlr->coord[access], access);
1083-
}
1084-
1085-
bool cxl_need_node_perf_attrs_update(int nid)
1086-
{
1087-
return !acpi_node_backed_by_real_pxm(nid);
1088-
}

drivers/cxl/core/core.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ bool cxl_memdev_has_poison_cmd(struct cxl_memdev *cxlmd,
141141

142142
long cxl_pci_get_latency(struct pci_dev *pdev);
143143
int cxl_pci_get_bandwidth(struct pci_dev *pdev, struct access_coordinate *c);
144-
int cxl_update_hmat_access_coordinates(int nid, struct cxl_region *cxlr,
145-
enum access_coordinate_class access);
146-
bool cxl_need_node_perf_attrs_update(int nid);
147144
int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port,
148145
struct access_coordinate *c);
149146

drivers/cxl/core/region.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
* 3. Decoder targets
3333
*/
3434

35+
/*
36+
* nodemask that sets per node when the access_coordinates for the node has
37+
* been updated by the CXL memory hotplug notifier.
38+
*/
39+
static nodemask_t nodemask_region_seen = NODE_MASK_NONE;
40+
3541
static struct cxl_region *to_cxl_region(struct device *dev);
3642

3743
#define __ACCESS_ATTR_RO(_level, _name) { \
@@ -2442,14 +2448,8 @@ static bool cxl_region_update_coordinates(struct cxl_region *cxlr, int nid)
24422448

24432449
for (int i = 0; i < ACCESS_COORDINATE_MAX; i++) {
24442450
if (cxlr->coord[i].read_bandwidth) {
2445-
rc = 0;
2446-
if (cxl_need_node_perf_attrs_update(nid))
2447-
node_set_perf_attrs(nid, &cxlr->coord[i], i);
2448-
else
2449-
rc = cxl_update_hmat_access_coordinates(nid, cxlr, i);
2450-
2451-
if (rc == 0)
2452-
cset++;
2451+
node_update_perf_attrs(nid, &cxlr->coord[i], i);
2452+
cset++;
24532453
}
24542454
}
24552455

@@ -2487,6 +2487,10 @@ static int cxl_region_perf_attrs_callback(struct notifier_block *nb,
24872487
if (nid != region_nid)
24882488
return NOTIFY_DONE;
24892489

2490+
/* No action needed if node bit already set */
2491+
if (node_test_and_set(nid, nodemask_region_seen))
2492+
return NOTIFY_DONE;
2493+
24902494
if (!cxl_region_update_coordinates(cxlr, nid))
24912495
return NOTIFY_DONE;
24922496

include/linux/acpi.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,18 +1595,6 @@ static inline void acpi_use_parent_companion(struct device *dev)
15951595
ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent));
15961596
}
15971597

1598-
#ifdef CONFIG_ACPI_HMAT
1599-
int hmat_update_target_coordinates(int nid, struct access_coordinate *coord,
1600-
enum access_coordinate_class access);
1601-
#else
1602-
static inline int hmat_update_target_coordinates(int nid,
1603-
struct access_coordinate *coord,
1604-
enum access_coordinate_class access)
1605-
{
1606-
return -EOPNOTSUPP;
1607-
}
1608-
#endif
1609-
16101598
#ifdef CONFIG_ACPI_NUMA
16111599
bool acpi_node_backed_by_real_pxm(int nid);
16121600
#else

include/linux/memory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ struct notifier_block;
115115
struct mem_section;
116116

117117
/*
118-
* Priorities for the hotplug memory callback routines (stored in decreasing
119-
* order in the callback chain)
118+
* Priorities for the hotplug memory callback routines. Invoked from
119+
* high to low. Higher priorities correspond to higher numbers.
120120
*/
121121
#define DEFAULT_CALLBACK_PRI 0
122122
#define SLAB_CALLBACK_PRI 1
123-
#define HMAT_CALLBACK_PRI 2
124123
#define CXL_CALLBACK_PRI 5
124+
#define HMAT_CALLBACK_PRI 6
125125
#define MM_COMPUTE_BATCH_PRI 10
126126
#define CPUSET_CALLBACK_PRI 10
127127
#define MEMTIER_HOTPLUG_PRI 100

include/linux/node.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct node_cache_attrs {
8585
void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
8686
void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
8787
enum access_coordinate_class access);
88+
void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
89+
enum access_coordinate_class access);
8890
#else
8991
static inline void node_add_cache(unsigned int nid,
9092
struct node_cache_attrs *cache_attrs)
@@ -96,6 +98,12 @@ static inline void node_set_perf_attrs(unsigned int nid,
9698
enum access_coordinate_class access)
9799
{
98100
}
101+
102+
static inline void node_update_perf_attrs(unsigned int nid,
103+
struct access_coordinate *coord,
104+
enum access_coordinate_class access)
105+
{
106+
}
99107
#endif
100108

101109
struct node {

0 commit comments

Comments
 (0)