|
Jeff Moyer |
2c91dc |
From ca582b2003a2335eafac382e71afdf0a6caaef18 Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Sun, 23 Jan 2022 16:54:11 -0800
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 113/217] cxl/list: Add 'numa_node' to memdev listings
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
If the kernel exports a valid numa_node, >= 0, include it in memdev objects
|
|
Jeff Moyer |
2c91dc |
listings.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Link: https://lore.kernel.org/r/164298565156.3021641.14097226245654611710.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
Documentation/cxl/lib/libcxl.txt | 4 ++++
|
|
Jeff Moyer |
2c91dc |
cxl/json.c | 8 ++++++++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/libcxl.c | 11 +++++++++++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/libcxl.sym | 1 +
|
|
Jeff Moyer |
2c91dc |
cxl/lib/private.h | 1 +
|
|
Jeff Moyer |
2c91dc |
cxl/libcxl.h | 1 +
|
|
Jeff Moyer |
2c91dc |
6 files changed, 26 insertions(+)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
index b0253d7..de88d19 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
@@ -71,6 +71,7 @@ unsigned long long cxl_memdev_get_ram_size(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
int cxl_memdev_nvdimm_bridge_active(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
+int cxl_memdev_get_numa_node(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
----
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
A memdev is given a kernel device name of the form "mem%d" where an id
|
|
Jeff Moyer |
2c91dc |
@@ -89,6 +90,9 @@ The 'pmem_size' and 'ram_size' attributes return the current
|
|
Jeff Moyer |
2c91dc |
provisioning of DPA (Device Physical Address / local capacity) in the
|
|
Jeff Moyer |
2c91dc |
device.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+cxl_memdev_get_numa_node() returns the affinitized CPU node number if
|
|
Jeff Moyer |
2c91dc |
+available or -1 otherwise.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
=== MEMDEV: Commands
|
|
Jeff Moyer |
2c91dc |
----
|
|
Jeff Moyer |
2c91dc |
struct cxl_cmd *cxl_cmd_new_raw(struct cxl_memdev *memdev, int opcode);
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/json.c b/cxl/json.c
|
|
Jeff Moyer |
2c91dc |
index b809332..51918d6 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/json.c
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/json.c
|
|
Jeff Moyer |
2c91dc |
@@ -190,6 +190,7 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
|
|
Jeff Moyer |
2c91dc |
const char *devname = cxl_memdev_get_devname(memdev);
|
|
Jeff Moyer |
2c91dc |
struct json_object *jdev, *jobj;
|
|
Jeff Moyer |
2c91dc |
unsigned long long serial;
|
|
Jeff Moyer |
2c91dc |
+ int numa_node;
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
jdev = json_object_new_object();
|
|
Jeff Moyer |
2c91dc |
if (!jdev)
|
|
Jeff Moyer |
2c91dc |
@@ -220,6 +221,13 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
|
|
Jeff Moyer |
2c91dc |
json_object_object_add(jdev, "serial", jobj);
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+ numa_node = cxl_memdev_get_numa_node(memdev);
|
|
Jeff Moyer |
2c91dc |
+ if (numa_node >= 0) {
|
|
Jeff Moyer |
2c91dc |
+ jobj = json_object_new_int(numa_node);
|
|
Jeff Moyer |
2c91dc |
+ if (jobj)
|
|
Jeff Moyer |
2c91dc |
+ json_object_object_add(jdev, "numa_node", jobj);
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
jobj = json_object_new_string(cxl_memdev_get_host(memdev));
|
|
Jeff Moyer |
2c91dc |
if (jobj)
|
|
Jeff Moyer |
2c91dc |
json_object_object_add(jdev, "host", jobj);
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
index 0065f6b..14c7db8 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
@@ -348,6 +348,12 @@ static void *add_cxl_memdev(void *parent, int id, const char *cxlmem_base)
|
|
Jeff Moyer |
2c91dc |
else
|
|
Jeff Moyer |
2c91dc |
memdev->serial = strtoull(buf, NULL, 0);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+ sprintf(path, "%s/numa_node", cxlmem_base);
|
|
Jeff Moyer |
2c91dc |
+ if (sysfs_read_attr(ctx, path, buf) < 0)
|
|
Jeff Moyer |
2c91dc |
+ memdev->numa_node = -1;
|
|
Jeff Moyer |
2c91dc |
+ else
|
|
Jeff Moyer |
2c91dc |
+ memdev->numa_node = strtol(buf, NULL, 0);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
memdev->dev_path = strdup(cxlmem_base);
|
|
Jeff Moyer |
2c91dc |
if (!memdev->dev_path)
|
|
Jeff Moyer |
2c91dc |
goto err_read;
|
|
Jeff Moyer |
2c91dc |
@@ -445,6 +451,11 @@ CXL_EXPORT unsigned long long cxl_memdev_get_serial(struct cxl_memdev *memdev)
|
|
Jeff Moyer |
2c91dc |
return memdev->serial;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT int cxl_memdev_get_numa_node(struct cxl_memdev *memdev)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return memdev->numa_node;
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
CXL_EXPORT const char *cxl_memdev_get_devname(struct cxl_memdev *memdev)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
return devpath_to_devname(memdev->dev_path);
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
index 29f3498..b13a2d6 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
@@ -77,6 +77,7 @@ local:
|
|
Jeff Moyer |
2c91dc |
LIBCXL_2 {
|
|
Jeff Moyer |
2c91dc |
global:
|
|
Jeff Moyer |
2c91dc |
cxl_memdev_get_serial;
|
|
Jeff Moyer |
2c91dc |
+ cxl_memdev_get_numa_node;
|
|
Jeff Moyer |
2c91dc |
cxl_memdev_get_host;
|
|
Jeff Moyer |
2c91dc |
cxl_bus_get_first;
|
|
Jeff Moyer |
2c91dc |
cxl_bus_get_next;
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
|
|
Jeff Moyer |
2c91dc |
index b097bdf..c00bb36 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/private.h
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/private.h
|
|
Jeff Moyer |
2c91dc |
@@ -20,6 +20,7 @@ struct cxl_pmem {
|
|
Jeff Moyer |
2c91dc |
struct cxl_endpoint;
|
|
Jeff Moyer |
2c91dc |
struct cxl_memdev {
|
|
Jeff Moyer |
2c91dc |
int id, major, minor;
|
|
Jeff Moyer |
2c91dc |
+ int numa_node;
|
|
Jeff Moyer |
2c91dc |
void *dev_buf;
|
|
Jeff Moyer |
2c91dc |
size_t buf_len;
|
|
Jeff Moyer |
2c91dc |
char *host;
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
index e7b675e..be656ed 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
@@ -37,6 +37,7 @@ struct cxl_memdev *cxl_memdev_get_first(struct cxl_ctx *ctx);
|
|
Jeff Moyer |
2c91dc |
struct cxl_memdev *cxl_memdev_get_next(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
int cxl_memdev_get_id(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
unsigned long long cxl_memdev_get_serial(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
+int cxl_memdev_get_numa_node(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
const char *cxl_memdev_get_devname(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
const char *cxl_memdev_get_host(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
struct cxl_bus *cxl_memdev_get_bus(struct cxl_memdev *memdev);
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|