From: Sage Weil Date: Thu, 3 Jan 2019 20:30:59 +0000 (-0600) Subject: common/blkdev: query numa info X-Git-Tag: v14.1.0~436^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8cddab4520b71c030311f33a3f1927d2a98e1c3f;p=ceph-ci.git common/blkdev: query numa info Signed-off-by: Sage Weil --- diff --git a/src/common/blkdev.cc b/src/common/blkdev.cc index 8f6a3a3f010..c32c7ba5d21 100644 --- a/src/common/blkdev.cc +++ b/src/common/blkdev.cc @@ -31,6 +31,7 @@ #include "include/uuid.h" #include "include/stringify.h" #include "blkdev.h" +#include "numa.h" #include "json_spirit/json_spirit_reader.h" @@ -108,6 +109,8 @@ static const char *blkdev_props2strings[] = { [BLKDEV_PROP_ROTATIONAL] = "queue/rotational", [BLKDEV_PROP_SERIAL] = "device/serial", [BLKDEV_PROP_VENDOR] = "device/device/vendor", + [BLKDEV_PROP_NUMA_NODE] = "device/device/numa_node", + [BLKDEV_PROP_NUMA_CPUS] = "device/device/local_cpulist", }; const char *BlkDev::sysfsdir() const { @@ -228,6 +231,15 @@ bool BlkDev::is_rotational() const return get_int_property(BLKDEV_PROP_ROTATIONAL) > 0; } +int BlkDev::get_numa_node(int *node) const +{ + int numa = get_int_property(BLKDEV_PROP_NUMA_NODE); + if (numa < 0) + return -1; + *node = numa; + return 0; +} + int BlkDev::dev(char *dev, size_t max) const { return get_string_property(BLKDEV_PROP_DEV, dev, max); diff --git a/src/common/blkdev.h b/src/common/blkdev.h index 7a29a1e39cd..4df433f76af 100644 --- a/src/common/blkdev.h +++ b/src/common/blkdev.h @@ -15,7 +15,9 @@ enum blkdev_prop_t { BLKDEV_PROP_ROTATIONAL, BLKDEV_PROP_SERIAL, BLKDEV_PROP_VENDOR, - BLKDEV_PROP_NUMPROPS + BLKDEV_PROP_NUMA_NODE, + BLKDEV_PROP_NUMA_CPUS, + BLKDEV_PROP_NUMPROPS, }; extern int get_device_by_path(const char *path, char* partition, char* device, size_t max); @@ -54,6 +56,7 @@ public: bool support_discard() const; bool is_nvme() const; bool is_rotational() const; + int get_numa_node(int *node) const; int dev(char *dev, size_t max) const; int vendor(char *vendor, size_t max) const; int model(char *model, size_t max) const;