Skip to content

Commit 21c7576

Browse files
committed
device-dax: Add a 'target_node' attribute
The target-node attribute is the Linux numa-node that a device-dax instance may create when it is online. Prior to being online the device's 'numa_node' property reflects the closest online cpu node which is the typical expectation of a device 'numa_node'. Once it is online it becomes its own distinct numa node, i.e. 'target_node'. Export the 'target_node' property to give userspace tooling the ability to predict the effective numa-node from a device-dax instance configured to provide 'System RAM' capacity. Cc: Vishal Verma <vishal.l.verma@intel.com> Reported-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 664525b commit 21c7576

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/dax/bus.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,41 @@ static ssize_t size_show(struct device *dev,
279279
}
280280
static DEVICE_ATTR_RO(size);
281281

282+
static int dev_dax_target_node(struct dev_dax *dev_dax)
283+
{
284+
struct dax_region *dax_region = dev_dax->region;
285+
286+
return dax_region->target_node;
287+
}
288+
289+
static ssize_t target_node_show(struct device *dev,
290+
struct device_attribute *attr, char *buf)
291+
{
292+
struct dev_dax *dev_dax = to_dev_dax(dev);
293+
294+
return sprintf(buf, "%d\n", dev_dax_target_node(dev_dax));
295+
}
296+
static DEVICE_ATTR_RO(target_node);
297+
298+
static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, int n)
299+
{
300+
struct device *dev = container_of(kobj, struct device, kobj);
301+
struct dev_dax *dev_dax = to_dev_dax(dev);
302+
303+
if (a == &dev_attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
304+
return 0;
305+
return a->mode;
306+
}
307+
282308
static struct attribute *dev_dax_attributes[] = {
283309
&dev_attr_size.attr,
310+
&dev_attr_target_node.attr,
284311
NULL,
285312
};
286313

287314
static const struct attribute_group dev_dax_attribute_group = {
288315
.attrs = dev_dax_attributes,
316+
.is_visible = dev_dax_visible,
289317
};
290318

291319
static const struct attribute_group *dax_attribute_groups[] = {

0 commit comments

Comments
 (0)