Le 08/04/2019 à 16:56, Dan Williams a écrit : > Yes, I agree with all of the above, but I think we need a way to fix > this independent of the HMAT data being present. The SLIT already > tells the kernel enough to let tooling figure out equidistant "local" > nodes. While the numa_node attribute will remain a singleton the > tooling needs to handle this case and can't assume the HMAT data will > be present.
So you want to export the part of SLIT that is currently hidden to userspace because the corresponding nodes aren't registered? With the patch below, I get 17 17 28 28 in dax0.0/node_distance which means it's close to node0 and node1. The code is pretty much a duplicate of read_node_distance() in drivers/base/node.c. Not sure it's worth factorizing such small functions? The name "node_distance" (instead of "distance" for NUMA nodes) is also subject to discussion. Brice commit 6488b6a5c942a972b97c2f28d566d89b9917ef1d Author: Brice Goglin <[email protected]> Date: Mon Apr 8 21:44:30 2019 +0200 device-dax: Add a 'node_distance' attribute This attribute is identical to the 'distance' attribute inside NUMA node directories. It lists the distance from the DAX device to each online NUMA node. Signed-off-by: Brice Goglin <[email protected]> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 2109cfe80219..35a80c852e0d 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -295,6 +295,28 @@ static ssize_t target_node_show(struct device *dev, } static DEVICE_ATTR_RO(target_node); +static ssize_t node_distance_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct dev_dax *dev_dax = to_dev_dax(dev); + int nid = dev_dax_target_node(dev_dax); + int len = 0; + int i; + + /* + * buf is currently PAGE_SIZE in length and each node needs 4 chars + * at the most (distance + space or newline). + */ + BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE); + + for_each_online_node(i) + len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i)); + + len += sprintf(buf + len, "\n"); + return len; +} +static DEVICE_ATTR(node_distance, S_IRUGO, node_distance_show, NULL); + static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -320,6 +342,7 @@ static struct attribute *dev_dax_attributes[] = { &dev_attr_modalias.attr, &dev_attr_size.attr, &dev_attr_target_node.attr, + &dev_attr_node_distance.attr, NULL, }; _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
