Skip to contentSkip to conversation

daxctl: Support for sub-dividing soft-reserved regions

PATCH In review Joao Martins 2 participants 16 messages Jul 13, 2020 – Dec 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover daxctl: Support for sub-dividing soft-reserved regions

Changes since v1:

* Add a Documentation/daxctl/ entry for each patch that adds commands or new option.

* Fix functional test suite to only change region 0 and not touch others

* Fix reconfigure-device -s changes (third patch) for better bisection.

v1: https://lore.kernel.org/linux-nvdimm/[email protected]/

---

This series introduces the daxctl support for sub-dividing soft-reserved regions created by EFI/HMAT/efi_fake_mem. It's the userspace counterpart of this recent patch series [0].

These new 'dynamic' regions can be partitioned into multiple different devices which its subdivisions can consist of one or more ranges. This
is in contrast to static dax regions -- created with ndctl-create-namespace
-m devdax -- which can't be subdivided neither discontiguous. See also cover-letter of [0].

The daxctl changes in these patches are depicted as:

* {create,destroy,disable,enable}-device:

These orchestrate/manage the sub-division devices. It mimmics the same as namespaces equivalent commands.

* Allow reconfigure-device to change the size of an existing *dynamic* dax device.

* Add test coverage (Tried to cover all range allocation code paths). v2 of kernel patches now passes this test suite.

* Documentation regarding the new command additions.

[0] "device-dax: Support sub-dividing soft-reserved ranges",
https://lore.kernel.org/linux-nvdimm/159457116473.754248.7879464730875147365.stgit@dwillia2-desk3.amr.corp.intel.com/

Dan Williams (1):
daxctl: Cleanup whitespace

Joao Martins (9):
libdaxctl: add daxctl_dev_set_size()
daxctl: add resize support in reconfigure-device
daxctl: add command to disable devdax device
daxctl: add command to enable devdax device
libdaxctl: add daxctl_region_create_dev()
daxctl: add command to create device
libdaxctl: add daxctl_region_destroy_dev()
daxctl: add command to destroy device daxctl/test: Add tests for dynamic dax regions

 Documentation/daxctl/Makefile.am                   |   6 +-
 Documentation/daxctl/daxctl-create-device.txt      | 105 +++++++
 Documentation/daxctl/daxctl-destroy-device.txt     |  63 +++++
 Documentation/daxctl/daxctl-disable-device.txt     |  58 ++++
 Documentation/daxctl/daxctl-enable-device.txt      |  59 ++++
 Documentation/daxctl/daxctl-reconfigure-device.txt |  16 ++
 daxctl/builtin.h                                   |   4 +
 daxctl/daxctl.c                                    |   4 +
 daxctl/device.c                                    | 310 ++++++++++++++++++++-
 daxctl/lib/libdaxctl.c                             |  67 +++++
 daxctl/lib/libdaxctl.sym                           |   7 +
 daxctl/libdaxctl.h                                 |   3 +
 test/Makefile.am                                   |   1 +
 test/daxctl-create.sh                              | 294 +++++++++++++++++++
 util/filter.c                                      |   2 +-
 15 files changed, 993 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/daxctl/daxctl-create-device.txt
 create mode 100644 Documentation/daxctl/daxctl-destroy-device.txt
 create mode 100644 Documentation/daxctl/daxctl-disable-device.txt
 create mode 100644 Documentation/daxctl/daxctl-enable-device.txt
 create mode 100755 test/daxctl-create.sh
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#1 lore raw

PATCH v2 1/10 daxctl: Cleanup whitespace

From: Dan Williams <[email protected]>

Re-indent util_daxctl_region_filter() to match expectations.

---
 util/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/filter.c +1 -1
index af72793929e2..7d0159f8cef6 100644
@@ -344,7 +344,7 @@ struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
 		return region;
 
 	if ((sscanf(ident, "%d", &region_id) == 1
-       || sscanf(ident, "region%d", &region_id) == 1)
+				|| sscanf(ident, "region%d", &region_id) == 1)
 			&& daxctl_region_get_id(region) == region_id)
 		return region;
 
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#2 lore raw

PATCH v2 2/10 libdaxctl: add daxctl_dev_set_size()

In reply to Joao Martins

Add an API for setting the size of a dax device.

This sysfs attribute is only writeable for a dynamic dax device such as the one exported by hmem.

---
 daxctl/lib/libdaxctl.c   | 24 ++++++++++++++++++++++++
 daxctl/lib/libdaxctl.sym |  5 +++++
 daxctl/libdaxctl.h       |  1 +
 3 files changed, 30 insertions(+)
daxctl/lib/libdaxctl.c +24 -0
index ee4a069eb463..00d5f7fe61ad 100644
@@ -1019,6 +1019,30 @@ DAXCTL_EXPORT unsigned long long daxctl_dev_get_size(struct daxctl_dev *dev)
 	return dev->size;
 }
 
+DAXCTL_EXPORT int daxctl_dev_set_size(struct daxctl_dev *dev, unsigned long long size)
+{
+	struct daxctl_ctx *ctx = daxctl_dev_get_ctx(dev);
+	char buf[SYSFS_ATTR_SIZE];
+	char *path = dev->dev_buf;
+	int len = dev->buf_len;
+
+	if (snprintf(path, len, "%s/size", dev->dev_path) >= len) {
+		err(ctx, "%s: buffer too small!\n",
+				daxctl_dev_get_devname(dev));
+		return -ENXIO;
+	}
+
+	sprintf(buf, "%#llx\n", size);
+	if (sysfs_write_attr(ctx, path, buf) < 0) {
+		err(ctx, "%s: failed to set size\n",
+				daxctl_dev_get_devname(dev));
+		return -ENXIO;
+	}
+
+	dev->size = size;
+	return 0;
+}
+
 DAXCTL_EXPORT int daxctl_dev_get_target_node(struct daxctl_dev *dev)
 {
 	return dev->target_node;
daxctl/lib/libdaxctl.sym +5 -0
index 87d02366a917..d8b4137c76b7 100644
@@ -75,3 +75,8 @@ global:
 	daxctl_memory_is_movable;
 	daxctl_memory_online_no_movable;
 } LIBDAXCTL_6;
+
+LIBDAXCTL_8 {
+global:
+	daxctl_dev_set_size;
+} LIBDAXCTL_7;
daxctl/libdaxctl.h +1 -0
index 6c545e1f3055..e3d482743cc6 100644
@@ -68,6 +68,7 @@ int daxctl_dev_get_major(struct daxctl_dev *dev);
 int daxctl_dev_get_minor(struct daxctl_dev *dev);
 unsigned long long daxctl_dev_get_resource(struct daxctl_dev *dev);
 unsigned long long daxctl_dev_get_size(struct daxctl_dev *dev);
+int daxctl_dev_set_size(struct daxctl_dev *dev, unsigned long long size);
 struct daxctl_ctx *daxctl_dev_get_ctx(struct daxctl_dev *dev);
 int daxctl_dev_is_enabled(struct daxctl_dev *dev);
 int daxctl_dev_disable(struct daxctl_dev *dev);
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#3 lore raw

PATCH v2 3/10 daxctl: add resize support in reconfigure-device

In reply to Joao Martins

Add the ability to change the size of an inactive dax device. Uses of this includes adjusting existing devices or enterily freeing the region device to make the space available.

	$ daxctl disable-device dax0.0
	disabled 1 device
	$ daxctl reconfigure-device -s 0 dax0.0
	reconfigured 1 device
	$ daxctl reconfigure-device -s 4G dax0.0
	reconfigured 1 device

@size (-s) and @mode (-m) are mutually exclusive as the latter relates to assigning memory to System-RAM through kmem as opposed to reconfiguring dynamic dax devices.

---
 Documentation/daxctl/daxctl-reconfigure-device.txt | 16 +++++++++++
 daxctl/device.c                                    | 32 ++++++++++++++++++++--
 2 files changed, 45 insertions(+), 3 deletions(-)
Documentation/daxctl/daxctl-reconfigure-device.txt +16 -0
index cb28fed24e52..8caae436faae 100644
@@ -75,6 +75,14 @@ daxctl_dev_get_target_node() or 'daxctl list')
 # numactl --cpunodebind=0-1 --membind=2 -- some-service --opt1 --opt2
 ----
 
+* Change the size of a dax device
+----
+# daxctl reconfigure-device dax0.1 -s 16G
+reconfigured 1 device
+# daxctl reconfigure-device dax0.1 -s 0
+reconfigured 1 device
+----
+
 DESCRIPTION
 -----------
 
@@ -120,6 +128,14 @@ OPTIONS
 	more /dev/daxX.Y devices, where X is the region id and Y is the device
 	instance id.
 
+-s::
+--size=::
+	For regions that support dax device creation, change the device size
+	in bytes. This option supports the suffixes "k" or "K" for KiB, "m" or
+	"M" for MiB, "g" or "G" for GiB and "t" or "T" for TiB.
+
+	The size must be a multiple of the region alignment.
+
 -m::
 --mode=::
 	Specify the mode to which the dax device(s) should be reconfigured.
daxctl/device.c +29 -3
index 705f1f8ff7f6..033e098eafe0 100644
@@ -9,6 +9,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/sysmacros.h>
+#include <util/size.h>
 #include <util/json.h>
 #include <util/filter.h>
 #include <json-c/json.h>
@@ -20,6 +21,7 @@ static struct {
 	const char *dev;
 	const char *mode;
 	const char *region;
+	const char *size;
 	bool no_online;
 	bool no_movable;
 	bool force;
@@ -34,6 +36,7 @@ enum dev_mode {
 };
 
 static enum dev_mode reconfig_mode = DAXCTL_DEV_MODE_UNKNOWN;
+static long long size = -1;
 static unsigned long flags;
 
 enum memory_zone {
@@ -60,12 +63,16 @@ OPT_BOOLEAN('N', "no-online", &param.no_online, \
 OPT_BOOLEAN('f', "force", &param.force, \
 		"attempt to offline memory sections before reconfiguration")
 
+#define CREATE_OPTIONS() \
+OPT_STRING('s', "size", &param.size, "size", "size to switch the device to")
+
 #define ZONE_OPTIONS() \
 OPT_BOOLEAN('\0', "no-movable", &param.no_movable, \
 		"online memory in ZONE_NORMAL")
 
 static const struct option reconfig_options[] = {
 	BASE_OPTIONS(),
+	CREATE_OPTIONS(),
 	RECONFIG_OPTIONS(),
 	ZONE_OPTIONS(),
 	OPT_END(),
@@ -90,6 +97,7 @@ static const char *parse_device_options(int argc, const char **argv,
 		usage,
 		NULL
 	};
+	unsigned long long units = 1;
 	int i, rc = 0;
 
 	argc = parse_options(argc, argv, options, u, 0);
@@ -135,12 +143,14 @@ static const char *parse_device_options(int argc, const char **argv,
 	/* Handle action-specific options */
 	switch (action) {
 	case ACTION_RECONFIG:
-		if (!param.mode) {
-			fprintf(stderr, "error: a 'mode' option is required\n");
+		if (!param.size && !param.mode) {
+			fprintf(stderr, "error: a 'mode' or 'size' option is required\n");
 			usage_with_options(u, reconfig_options);
 			rc = -EINVAL;
 		}
-		if (strcmp(param.mode, "system-ram") == 0) {
+		if (param.size) {
+			size = __parse_size64(param.size, &units);
+		} else if (strcmp(param.mode, "system-ram") == 0) {
 			reconfig_mode = DAXCTL_DEV_MODE_RAM;
 			if (param.no_movable)
 				mem_zone = MEM_ZONE_NORMAL;
@@ -309,6 +319,17 @@ static int dev_offline_memory(struct daxctl_dev *dev)
 	return 0;
 }
 
+static int dev_resize(struct daxctl_dev *dev, unsigned long long val)
+{
+	int rc;
+
+	rc = daxctl_dev_set_size(dev, val);
+	if (rc < 0)
+		return rc;
+
+	return 0;
+}
+
 static int disable_devdax_device(struct daxctl_dev *dev)
 {
 	struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
@@ -418,6 +439,11 @@ static int do_reconfig(struct daxctl_dev *dev, enum dev_mode mode,
 	struct json_object *jdev;
 	int rc = 0;
 
+	if (size >= 0) {
+		rc = dev_resize(dev, size);
+		return rc;
+	}
+
 	switch (mode) {
 	case DAXCTL_DEV_MODE_RAM:
 		rc = reconfig_mode_system_ram(dev);
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#4 lore raw

PATCH v2 4/10 daxctl: add command to disable devdax device

In reply to Joao Martins

Add a 'disable-device' command, required prior to
reconfiguration or destruction of the dax device.

Mimmics the same functionality as seen in
ndctl-disable-namespace.

---
 Documentation/daxctl/Makefile.am               |  3 +-
 Documentation/daxctl/daxctl-disable-device.txt | 58 ++++++++++++++++++++++++
 daxctl/builtin.h                               |  1 +
 daxctl/daxctl.c                                |  1 +
 daxctl/device.c                                | 61 ++++++++++++++++++++++++++
 5 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/daxctl/daxctl-disable-device.txt
Documentation/daxctl/Makefile.am +2 -1
index 7696e23cc9c0..1f070771cd95 100644
@@ -31,7 +31,8 @@ man1_MANS = \
 	daxctl-migrate-device-model.1 \
 	daxctl-reconfigure-device.1 \
 	daxctl-online-memory.1 \
-	daxctl-offline-memory.1
+	daxctl-offline-memory.1 \
+	daxctl-disable-device.1
 
 EXTRA_DIST = $(man1_MANS)
 
Documentation/daxctl/daxctl-disable-device.txt new file +58 -0

58 lines not on this page · raw message

daxctl/builtin.h +1 -0
index f5a0147f0e11..c9848953bbd8 100644
@@ -7,6 +7,7 @@ struct daxctl_ctx;
 int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_migrate(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_reconfig_device(int argc, const char **argv, struct daxctl_ctx *ctx);
+int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_offline_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
 #endif /* _DAXCTL_BUILTIN_H_ */
daxctl/daxctl.c +1 -0
index 1ab073200313..1707a9ff0791 100644
@@ -74,6 +74,7 @@ static struct cmd_struct commands[] = {
 	{ "reconfigure-device", .d_fn = cmd_reconfig_device },
 	{ "online-memory", .d_fn = cmd_online_memory },
 	{ "offline-memory", .d_fn = cmd_offline_memory },
+	{ "disable-device", .d_fn = cmd_disable_device },
 };
 
 int main(int argc, const char **argv)
daxctl/device.c +61 -0

103 lines not on this page · raw message

Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#5 lore raw

PATCH v2 5/10 daxctl: add command to enable devdax device

In reply to Joao Martins

Add a 'enable-device' command, required prior to
reconfiguration of the dax device.

Mimics the same functionality as seen in
ndctl-enable-namespace.

---
 Documentation/daxctl/Makefile.am              |  3 +-
 Documentation/daxctl/daxctl-enable-device.txt | 59 +++++++++++++++++++++++++++
 daxctl/builtin.h                              |  1 +
 daxctl/daxctl.c                               |  1 +
 daxctl/device.c                               | 40 ++++++++++++++++++
 5 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/daxctl/daxctl-enable-device.txt
Documentation/daxctl/Makefile.am +2 -1
index 1f070771cd95..e43d34183142 100644
@@ -32,7 +32,8 @@ man1_MANS = \
 	daxctl-reconfigure-device.1 \
 	daxctl-online-memory.1 \
 	daxctl-offline-memory.1 \
-	daxctl-disable-device.1
+	daxctl-disable-device.1 \
+	daxctl-enable-device.1
 
 EXTRA_DIST = $(man1_MANS)
 
Documentation/daxctl/daxctl-enable-device.txt new file +59 -0

59 lines not on this page · raw message

daxctl/builtin.h +1 -0
index c9848953bbd8..8f344f86ad20 100644
@@ -8,6 +8,7 @@ int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_migrate(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_reconfig_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
+int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_offline_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
 #endif /* _DAXCTL_BUILTIN_H_ */
daxctl/daxctl.c +1 -0
index 1707a9ff0791..a4699b3780bd 100644
@@ -75,6 +75,7 @@ static struct cmd_struct commands[] = {
 	{ "online-memory", .d_fn = cmd_online_memory },
 	{ "offline-memory", .d_fn = cmd_offline_memory },
 	{ "disable-device", .d_fn = cmd_disable_device },
+	{ "enable-device", .d_fn = cmd_enable_device },
 };
 
 int main(int argc, const char **argv)
daxctl/device.c +40 -0
index 20df2b844774..05a9247ecfde 100644
@@ -50,6 +50,7 @@ enum device_action {
 	ACTION_ONLINE,
 	ACTION_OFFLINE,
 	ACTION_DISABLE,
+	ACTION_ENABLE,
 };
 
 #define BASE_OPTIONS() \
@@ -95,6 +96,11 @@ static const struct option disable_options[] = {
 	OPT_END(),
 };
 
+static const struct option enable_options[] = {
+	BASE_OPTIONS(),
+	OPT_END(),
+};
+
 static const char *parse_device_options(int argc, const char **argv,
 		enum device_action action, const struct option *options,
 		const char *usage, struct daxctl_ctx *ctx)
@@ -125,6 +131,9 @@ static const char *parse_device_options(int argc, const char **argv,
 		case ACTION_DISABLE:
 			action_string = "disable";
 			break;
+		case ACTION_ENABLE:
+			action_string = "enable";
+			break;
 		default:
 			action_string = "<>";
 			break;
@@ -178,6 +187,7 @@ static const char *parse_device_options(int argc, const char **argv,
 		/* fall through */
 	case ACTION_OFFLINE:
 	case ACTION_DISABLE:
+	case ACTION_ENABLE:
 		/* nothing special */
 		break;
 	}
@@ -521,6 +531,14 @@ static int do_xble(struct daxctl_dev *dev, enum device_action action)
 	}
 
 	switch (action) {
+	case ACTION_ENABLE:
+		rc = daxctl_dev_enable_devdax(dev);
+		if (rc) {
+			fprintf(stderr, "%s: enable failed: %s\n",
+				daxctl_dev_get_devname(dev), strerror(-rc));
+			return rc;
+		}
+		break;
 	case ACTION_DISABLE:
 		rc = daxctl_dev_disable(dev);
 		if (rc) {
@@ -570,6 +588,11 @@ static int do_xaction_device(const char *device, enum device_action action,
 				if (rc == 0)
 					(*processed)++;
 				break;
+			case ACTION_ENABLE:
+				rc = do_xble(dev, action);
+				if (rc == 0)
+					(*processed)++;
+				break;
 			case ACTION_DISABLE:
 				rc = do_xble(dev, action);
 				if (rc == 0)
@@ -627,6 +650,23 @@ int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx)
 	return rc;
 }
 
+int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx)
+{
+	char *usage = "daxctl enable-device <device>";
+	const char *device = parse_device_options(argc, argv, ACTION_DISABLE,
+			enable_options, usage, ctx);
+	int processed, rc;
+
+	rc = do_xaction_device(device, ACTION_ENABLE, ctx, &processed);
+	if (rc < 0)
+		fprintf(stderr, "error enabling device: %s\n",
+				strerror(-rc));
+
+	fprintf(stderr, "enabled %d device%s\n", processed,
+			processed == 1 ? "" : "s");
+	return rc;
+}
+
 int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx)
 {
 	char *usage = "daxctl online-memory <device> [<options>]";
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#6 lore raw

PATCH v2 6/10 libdaxctl: add daxctl_region_create_dev()

In reply to Joao Martins

Add an API to create an empty seed device.

This sysfs attribute is only writeable for a dynamic dax device such as the one exported by hmem.

---
 daxctl/lib/libdaxctl.c   | 26 ++++++++++++++++++++++++++
 daxctl/lib/libdaxctl.sym |  1 +
 daxctl/libdaxctl.h       |  1 +
 3 files changed, 28 insertions(+)
daxctl/lib/libdaxctl.c +26 -0
index 00d5f7fe61ad..d17ff7a02bad 100644
@@ -583,6 +583,32 @@ DAXCTL_EXPORT unsigned long long daxctl_region_get_available_size(
 	return 0;
 }
 
+DAXCTL_EXPORT int daxctl_region_create_dev(struct daxctl_region *region)
+{
+	struct daxctl_ctx *ctx = daxctl_region_get_ctx(region);
+	char *path = region->region_buf;
+	int rc, len = region->buf_len;
+	char *num_devices;
+
+	if (snprintf(path, len, "%s/%s/create", region->region_path, attrs) >= len) {
+		err(ctx, "%s: buffer too small!\n",
+				daxctl_region_get_devname(region));
+		return -EFAULT;
+	}
+
+	if (asprintf(&num_devices, "%d", 1) < 0) {
+		err(ctx, "%s: buffer too small!\n",
+				daxctl_region_get_devname(region));
+		return -EFAULT;
+	}
+
+	rc = sysfs_write_attr(ctx, path, num_devices);
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
 DAXCTL_EXPORT struct daxctl_dev *daxctl_region_get_dev_seed(
 		struct daxctl_region *region)
 {
daxctl/lib/libdaxctl.sym +1 -0
index d8b4137c76b7..26987ba021ab 100644
@@ -79,4 +79,5 @@ global:
 LIBDAXCTL_8 {
 global:
 	daxctl_dev_set_size;
+	daxctl_region_create_dev;
 } LIBDAXCTL_7;
daxctl/libdaxctl.h +1 -0
index e3d482743cc6..a579ddd1d43c 100644
@@ -56,6 +56,7 @@ unsigned long daxctl_region_get_align(struct daxctl_region *region);
 const char *daxctl_region_get_devname(struct daxctl_region *region);
 const char *daxctl_region_get_path(struct daxctl_region *region);
 
+int daxctl_region_create_dev(struct daxctl_region *region);
 struct daxctl_dev *daxctl_region_get_dev_seed(struct daxctl_region *region);
 
 struct daxctl_dev;
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#7 lore raw

PATCH v2 7/10 daxctl: add command to create device

In reply to Joao Martins

Add a 'create-device' command which creates a devdax region. So far the only new option is size, which when omitted uses the entire available space. Example usage:

	$ daxctl reconfigure-device -s 0 dax0.0
	reconfigured 1 device
	$ daxctl create-device -s 4G -r 0
	[
	  {
	    "chardev":"dax0.1",
	    "size":4294967296,
	    "target_node":0,
	    "mode":"devdax"
	  }
	]
	created 1 device

Or using the whole available space like default behaviour or ndctl-create-namespace:

	$ daxctl create-device
	[
	  {
	    "chardev":"dax0.1",
	    "size":120259084288,
	    "target_node":0,
	    "mode":"devdax"
	  }
	]
	created 1 device
---
 Documentation/daxctl/Makefile.am              |   3 +-
 Documentation/daxctl/daxctl-create-device.txt | 105 ++++++++++++++++++++++++
 daxctl/builtin.h                              |   1 +
 daxctl/daxctl.c                               |   1 +
 daxctl/device.c                               | 111 +++++++++++++++++++++++++-
 5 files changed, 219 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/daxctl/daxctl-create-device.txt
Documentation/daxctl/Makefile.am +2 -1
index e43d34183142..27e201dfc254 100644
@@ -33,7 +33,8 @@ man1_MANS = \
 	daxctl-online-memory.1 \
 	daxctl-offline-memory.1 \
 	daxctl-disable-device.1 \
-	daxctl-enable-device.1
+	daxctl-enable-device.1 \
+	daxctl-create-device.1
 
 EXTRA_DIST = $(man1_MANS)
 
Documentation/daxctl/daxctl-create-device.txt new file +105 -0

105 lines not on this page · raw message

daxctl/builtin.h +1 -0
index 8f344f86ad20..19b33933b91b 100644
@@ -6,6 +6,7 @@
 struct daxctl_ctx;
 int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_migrate(int argc, const char **argv, struct daxctl_ctx *ctx);
+int cmd_create_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_reconfig_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
daxctl/daxctl.c +1 -0
index a4699b3780bd..1f315168c513 100644
@@ -71,6 +71,7 @@ static struct cmd_struct commands[] = {
 	{ "list", .d_fn = cmd_list },
 	{ "help", .d_fn = cmd_help },
 	{ "migrate-device-model", .d_fn = cmd_migrate },
+	{ "create-device", .d_fn = cmd_create_device },
 	{ "reconfigure-device", .d_fn = cmd_reconfig_device },
 	{ "online-memory", .d_fn = cmd_online_memory },
 	{ "offline-memory", .d_fn = cmd_offline_memory },
daxctl/device.c +110 -1

153 lines not on this page · raw message

Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#8 lore raw

PATCH v2 8/10 libdaxctl: add daxctl_region_destroy_dev()

In reply to Joao Martins

Add an API to destroy an empty device.

This 'delete' sysfs attribute is only writeable for a dynamic dax device such as the one exported by hmem.

---
 daxctl/lib/libdaxctl.c   | 17 +++++++++++++++++
 daxctl/lib/libdaxctl.sym |  1 +
 daxctl/libdaxctl.h       |  1 +
 3 files changed, 19 insertions(+)
daxctl/lib/libdaxctl.c +17 -0
index d17ff7a02bad..9b43b68facfe 100644
@@ -609,6 +609,23 @@ DAXCTL_EXPORT int daxctl_region_create_dev(struct daxctl_region *region)
 	return 0;
 }
 
+DAXCTL_EXPORT int daxctl_region_destroy_dev(struct daxctl_region *region,
+					    struct daxctl_dev *dev)
+{
+	struct daxctl_ctx *ctx = daxctl_region_get_ctx(region);
+	char *path = region->region_buf;
+	int rc, len = region->buf_len;
+
+	if (snprintf(path, len, "%s/%s/delete", region->region_path, attrs) >= len) {
+		err(ctx, "%s: buffer too small!\n",
+				daxctl_region_get_devname(region));
+		return -EFAULT;
+	}
+
+	rc = sysfs_write_attr(ctx, path, daxctl_dev_get_devname(dev));
+	return rc;
+}
+
 DAXCTL_EXPORT struct daxctl_dev *daxctl_region_get_dev_seed(
 		struct daxctl_region *region)
 {
daxctl/lib/libdaxctl.sym +1 -0
index 26987ba021ab..33c926411037 100644
@@ -80,4 +80,5 @@ LIBDAXCTL_8 {
 global:
 	daxctl_dev_set_size;
 	daxctl_region_create_dev;
+	daxctl_region_destroy_dev;
 } LIBDAXCTL_7;
daxctl/libdaxctl.h +1 -0
index a579ddd1d43c..2b14faad1895 100644
@@ -61,6 +61,7 @@ struct daxctl_dev *daxctl_region_get_dev_seed(struct daxctl_region *region);
 
 struct daxctl_dev;
 struct daxctl_dev *daxctl_dev_get_first(struct daxctl_region *region);
+int daxctl_region_destroy_dev(struct daxctl_region *region, struct daxctl_dev *dev);
 struct daxctl_dev *daxctl_dev_get_next(struct daxctl_dev *dev);
 struct daxctl_region *daxctl_dev_get_region(struct daxctl_dev *dev);
 int daxctl_dev_get_id(struct daxctl_dev *dev);
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#9 lore raw

PATCH v2 9/10 daxctl: add command to destroy device

In reply to Joao Martins

Add a 'destroy-device' command which destroys a dax device. Like namespaces, the device needs to be disabled in order to be destroyed. Example usage:

	$ daxctl disable-device dax0.1
	disabled 1 device
	$ daxctl destroy-device dax0.1
	destroyed 1 device
---
 Documentation/daxctl/Makefile.am               |  3 +-
 Documentation/daxctl/daxctl-destroy-device.txt | 63 ++++++++++++++++++++++++
 daxctl/builtin.h                               |  1 +
 daxctl/daxctl.c                                |  1 +
 daxctl/device.c                                | 66 ++++++++++++++++++++++++++
 5 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/daxctl/daxctl-destroy-device.txt
Documentation/daxctl/Makefile.am +2 -1
index 27e201dfc254..2b3f92ca5b96 100644
@@ -34,7 +34,8 @@ man1_MANS = \
 	daxctl-offline-memory.1 \
 	daxctl-disable-device.1 \
 	daxctl-enable-device.1 \
-	daxctl-create-device.1
+	daxctl-create-device.1 \
+	daxctl-destroy-device.1
 
 EXTRA_DIST = $(man1_MANS)
 
Documentation/daxctl/daxctl-destroy-device.txt new file +63 -0

63 lines not on this page · raw message

daxctl/builtin.h +1 -0
index 19b33933b91b..29ba63ca17aa 100644
@@ -7,6 +7,7 @@ struct daxctl_ctx;
 int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_migrate(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_create_device(int argc, const char **argv, struct daxctl_ctx *ctx);
+int cmd_destroy_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_reconfig_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
 int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
daxctl/daxctl.c +1 -0
index 1f315168c513..bd5539900391 100644
@@ -72,6 +72,7 @@ static struct cmd_struct commands[] = {
 	{ "help", .d_fn = cmd_help },
 	{ "migrate-device-model", .d_fn = cmd_migrate },
 	{ "create-device", .d_fn = cmd_create_device },
+	{ "destroy-device", .d_fn = cmd_destroy_device },
 	{ "reconfigure-device", .d_fn = cmd_reconfig_device },
 	{ "online-memory", .d_fn = cmd_online_memory },
 	{ "offline-memory", .d_fn = cmd_offline_memory },
daxctl/device.c +66 -0

114 lines not on this page · raw message

Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#10 lore raw

PATCH v2 10/10 daxctl/test: Add tests for dynamic dax regions

In reply to Joao Martins

Add a couple tests which exercise the new sysfs based interface for Soft-Reserved regions (by EFI/HMAT, or efi_fake_mem).

The tests exercise the daxctl orchestration surrounding for creating/disabling/destroying/reconfiguring devices. Furthermore it exercises dax region space allocation code paths particularly:

1) zeroing out and reconfiguring a dax device from its current size to be max available and back to initial size

2) creates devices from holes in the beginning, middle of the region.

3) reconfigures devices in a interleaving fashion

4) test adjust of the region towards beginning and end

The tests assume you pass a valid efi_fake_mem parameter marked as EFI_MEMORY_SP e.g.

	efi_fake_mem=112G@16G:0x40000

Naturally it bails out from the test if hmem device driver isn't loaded or builtin. If hmem regions are found, only region 0 is used, and the others remain untouched.

---
 test/Makefile.am      |   1 +
 test/daxctl-create.sh | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 295 insertions(+)
 create mode 100755 test/daxctl-create.sh
test/Makefile.am +1 -0
index 1d24a65ded8b..6b7c82f9a4e2 100644
@@ -58,6 +58,7 @@ TESTS +=\
 	device-dax \
 	device-dax-fio.sh \
 	daxctl-devices.sh \
+	daxctl-create.sh \
 	dm.sh \
 	mmap.sh
 
test/daxctl-create.sh new file +294 -0

294 lines not on this page · raw message

Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
#11 lore raw

Re: [PATCH ndctl v2 10/10] daxctl/test: Add tests for dynamic dax regions

Quoted 23 lines · Joao Martins

Add a couple tests which exercise the new sysfs based interface for Soft-Reserved regions (by EFI/HMAT, or efi_fake_mem).

The tests exercise the daxctl orchestration surrounding for creating/disabling/destroying/reconfiguring devices. Furthermore it exercises dax region space allocation code paths particularly:

1) zeroing out and reconfiguring a dax device from its current size to be max available and back to initial size

2) creates devices from holes in the beginning, middle of the region.

3) reconfigures devices in a interleaving fashion

4) test adjust of the region towards beginning and end

The tests assume you pass a valid efi_fake_mem parameter marked as EFI_MEMORY_SP e.g.

Quoted 7 lines
	efi_fake_mem=112G@16G:0x40000

Naturally it bails out from the test if hmem device driver isn't loaded or builtin. If hmem regions are found, only region 0 is used, and the others remain untouched.

Following your suggestion[0], I added a couple more validations to this test suite, covering the mappings. So on top of this patch I added the following snip below the scissors mark. Mainly, I check that the size calculated by mappingNNNN is the same as advertised by the sysfs size attribute, thus looping through all the mappings.

Perhaps it would be enough to have just such validation in setup_dev() to catch the bug in [0]. But I went ahead and also validated the test cases where a certain amount of mappings are meant to be created.

My only worry is the last piece in daxctl_test_adjust() where we might be tying too much on how a kernel version picks space from the region; should this logic change in an unforeseeable future (e.g. allowing space at the beginning to be adjusted). Otherwise, if this no concern, let me know and I can resend a v3 with the adjustment below.

----->8------
Subject: Validate @size versus mappingX sizes

[0]
https://lore.kernel.org/linux-nvdimm/CAPcyv4hFS7JS9s7cUY=2Ru2kUTRsesxwX1PGnnc_tudJjoDUGw@mail.gmail.com/

---

 test/daxctl-create.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)
test/daxctl-create.sh +63 -1
index 0d35112b4119..8dbc00fc574f 100755
@@ -46,8 +46,16 @@ find_testdev()
 
 setup_dev()
 {
+	local rc=1
+	local nmaps=0
 	test -n "$testdev"
 
+	nmaps=$(daxctl_get_nr_mappings "$testdev")
+	if [[ $nmaps == 0 ]]; then
+		printf "Device is idle"
+		exit "$rc"
+	fi
+
 	"$DAXCTL" disable-device "$testdev"
 	"$DAXCTL" reconfigure-device -s 0 "$testdev"
 	available=$("$DAXCTL" list -r 0 | jq -er '.[0].available_size | .//""')
@@ -110,6 +118,47 @@ daxctl_get_mode()
 	"$DAXCTL" list -d "$1" | jq -er '.[].mode'
 }
 
+daxctl_get_size_by_mapping()
+{
+	local size=0
+	local _start=0
+	local _end=0
+
+	_start=$(cat $1/start)
+	_end=$(cat $1/end)
+	((size=size + _end - _start + 1))
+	echo $size
+}
+
+daxctl_get_nr_mappings()
+{
+	local i=0
+	local _size=0
+	local devsize=0
+	local path=""
+
+	path=$(readlink -f /sys/bus/dax/devices/"$1"/)
+	until ! [ -d $path/mapping$i ]
+	do
+		_size=$(daxctl_get_size_by_mapping "$path/mapping$i")
+		if [[ $msize == 0 ]]; then
+			i=0
+			break
+		fi
+		((devsize=devsize + _size))
+		((i=i + 1))
+	done
+
+	# Return number of mappings if the sizes between size field
+	# and the one computed by mappingNNN are the same
+	_size=$("$DAXCTL" list -d $1 | jq -er '.[0].size | .//""')
+	if [[ ! $_size == $devsize ]]; then
+		echo 0
+	else
+		echo $i
+	fi
+}
+
 daxctl_test_multi()
 {
 	local daxdev
@@ -139,6 +188,7 @@ daxctl_test_multi()
 	new_size=$(expr $size \* 2)
 	daxdev_4=$("$DAXCTL" create-device -r 0 -s $new_size | jq -er '.[].chardev')
 	test -n $daxdev_4
+	test $(daxctl_get_nr_mappings $daxdev_4) -eq 2
 
 	fail_if_available
 
@@ -173,6 +223,9 @@ daxctl_test_multi_reconfig()
 		"$DAXCTL" reconfigure-device -s $i "$daxdev_1"
 	done
 
+	test $(daxctl_get_nr_mappings $testdev) -eq $((ncfgs / 2))
+	test $(daxctl_get_nr_mappings $daxdev_1) -eq $((ncfgs / 2))
+
 	fail_if_available
 
 	"$DAXCTL" disable-device "$daxdev_1" && "$DAXCTL" destroy-device "$daxdev_1"
@@ -191,7 +244,8 @@ daxctl_test_adjust()
 	start=$(expr $size + $size)
 	for i in $(seq 1 1 $ncfgs)
 	do
-		daxdev=$("$DAXCTL" create-device -r 0 -s $size)
+		daxdev=$("$DAXCTL" create-device -r 0 -s $size | jq -er '.[].chardev')
+		test $(daxctl_get_nr_mappings $daxdev) -eq 1
 	done
 
 	daxdev=$(daxctl_get_dev "dax0.1")
@@ -202,10 +256,17 @@ daxctl_test_adjust()
 	daxdev=$(daxctl_get_dev "dax0.2")
 	"$DAXCTL" disable-device "$daxdev"
 	"$DAXCTL" reconfigure-device -s $(expr $size \* 2) "$daxdev"
+	# Allocates space at the beginning: expect two mappings as
+	# as don't adjust the mappingX region. This is because we
+	# preserve the relative page_offset of existing allocations
+	test $(daxctl_get_nr_mappings $daxdev) -eq 2
 
 	daxdev=$(daxctl_get_dev "dax0.3")
 	"$DAXCTL" disable-device "$daxdev"
 	"$DAXCTL" reconfigure-device -s $(expr $size \* 2) "$daxdev"
+	# Adjusts space at the end, expect one mapping because we are
+	# able to extend existing region range.
+	test $(daxctl_get_nr_mappings $daxdev) -eq 1
 
 	fail_if_available
 
@@ -232,6 +293,7 @@ daxctl_test1()
 	daxdev=$("$DAXCTL" create-device -r 0 | jq -er '.[].chardev')
 
 	test -n "$daxdev"
+	test $(daxctl_get_nr_mappings $daxdev) -eq 1
 	fail_if_available
 
 	"$DAXCTL" disable-device "$daxdev" && "$DAXCTL" destroy-device "$daxdev"

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

#12 lore raw

Re: [PATCH ndctl v2 10/10] daxctl/test: Add tests for dynamic dax regions

Quoted 42 lines · Joao Martins
Quoted 23 lines · Joao Martins

Add a couple tests which exercise the new sysfs based interface for Soft-Reserved regions (by EFI/HMAT, or efi_fake_mem).

The tests exercise the daxctl orchestration surrounding for creating/disabling/destroying/reconfiguring devices. Furthermore it exercises dax region space allocation code paths particularly:

1) zeroing out and reconfiguring a dax device from its current size to be max available and back to initial size

2) creates devices from holes in the beginning, middle of the region.

3) reconfigures devices in a interleaving fashion

4) test adjust of the region towards beginning and end

The tests assume you pass a valid efi_fake_mem parameter marked as EFI_MEMORY_SP e.g.

Quoted 7 lines
	efi_fake_mem=112G@16G:0x40000

Naturally it bails out from the test if hmem device driver isn't loaded or builtin. If hmem regions are found, only region 0 is used, and the others remain untouched.

Following your suggestion[0], I added a couple more validations to this test suite, covering the mappings. So on top of this patch I added the following snip below the scissors mark. Mainly, I check that the size calculated by mappingNNNN is the same as advertised by the sysfs size attribute, thus looping through all the mappings.

Perhaps it would be enough to have just such validation in setup_dev() to catch the bug in [0]. But I went ahead and also validated the test cases where a certain amount of mappings are meant to be created.

Quoted 6 lines

My only worry is the last piece in daxctl_test_adjust() where we might be tying too much on how a kernel version picks space from the region; should this logic change in an unforeseeable future (e.g. allowing space at the beginning to be adjusted). Otherwise, if this no concern, let me know and I can resend a v3 with the adjustment below.

Ping?

Quoted 134 lines

----->8------
Subject: Validate @size versus mappingX sizes

[0]
https://lore.kernel.org/linux-nvdimm/CAPcyv4hFS7JS9s7cUY=2Ru2kUTRsesxwX1PGnnc_tudJjoDUGw@mail.gmail.com/

---

 test/daxctl-create.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)
test/daxctl-create.sh +63 -1
index 0d35112b4119..8dbc00fc574f 100755
@@ -46,8 +46,16 @@ find_testdev()
 
 setup_dev()
 {
+	local rc=1
+	local nmaps=0
 	test -n "$testdev"
 
+	nmaps=$(daxctl_get_nr_mappings "$testdev")
+	if [[ $nmaps == 0 ]]; then
+		printf "Device is idle"
+		exit "$rc"
+	fi
+
 	"$DAXCTL" disable-device "$testdev"
 	"$DAXCTL" reconfigure-device -s 0 "$testdev"
 	available=$("$DAXCTL" list -r 0 | jq -er '.[0].available_size | .//""')
@@ -110,6 +118,47 @@ daxctl_get_mode()
 	"$DAXCTL" list -d "$1" | jq -er '.[].mode'
 }
 
+daxctl_get_size_by_mapping()
+{
+	local size=0
+	local _start=0
+	local _end=0
+
+	_start=$(cat $1/start)
+	_end=$(cat $1/end)
+	((size=size + _end - _start + 1))
+	echo $size
+}
+
+daxctl_get_nr_mappings()
+{
+	local i=0
+	local _size=0
+	local devsize=0
+	local path=""
+
+	path=$(readlink -f /sys/bus/dax/devices/"$1"/)
+	until ! [ -d $path/mapping$i ]
+	do
+		_size=$(daxctl_get_size_by_mapping "$path/mapping$i")
+		if [[ $msize == 0 ]]; then
+			i=0
+			break
+		fi
+		((devsize=devsize + _size))
+		((i=i + 1))
+	done
+
+	# Return number of mappings if the sizes between size field
+	# and the one computed by mappingNNN are the same
+	_size=$("$DAXCTL" list -d $1 | jq -er '.[0].size | .//""')
+	if [[ ! $_size == $devsize ]]; then
+		echo 0
+	else
+		echo $i
+	fi
+}
+
 daxctl_test_multi()
 {
 	local daxdev
@@ -139,6 +188,7 @@ daxctl_test_multi()
 	new_size=$(expr $size \* 2)
 	daxdev_4=$("$DAXCTL" create-device -r 0 -s $new_size | jq -er '.[].chardev')
 	test -n $daxdev_4
+	test $(daxctl_get_nr_mappings $daxdev_4) -eq 2
 
 	fail_if_available
 
@@ -173,6 +223,9 @@ daxctl_test_multi_reconfig()
 		"$DAXCTL" reconfigure-device -s $i "$daxdev_1"
 	done
 
+	test $(daxctl_get_nr_mappings $testdev) -eq $((ncfgs / 2))
+	test $(daxctl_get_nr_mappings $daxdev_1) -eq $((ncfgs / 2))
+
 	fail_if_available
 
 	"$DAXCTL" disable-device "$daxdev_1" && "$DAXCTL" destroy-device "$daxdev_1"
@@ -191,7 +244,8 @@ daxctl_test_adjust()
 	start=$(expr $size + $size)
 	for i in $(seq 1 1 $ncfgs)
 	do
-		daxdev=$("$DAXCTL" create-device -r 0 -s $size)
+		daxdev=$("$DAXCTL" create-device -r 0 -s $size | jq -er '.[].chardev')
+		test $(daxctl_get_nr_mappings $daxdev) -eq 1
 	done
 
 	daxdev=$(daxctl_get_dev "dax0.1")
@@ -202,10 +256,17 @@ daxctl_test_adjust()
 	daxdev=$(daxctl_get_dev "dax0.2")
 	"$DAXCTL" disable-device "$daxdev"
 	"$DAXCTL" reconfigure-device -s $(expr $size \* 2) "$daxdev"
+	# Allocates space at the beginning: expect two mappings as
+	# as don't adjust the mappingX region. This is because we
+	# preserve the relative page_offset of existing allocations
+	test $(daxctl_get_nr_mappings $daxdev) -eq 2
 
 	daxdev=$(daxctl_get_dev "dax0.3")
 	"$DAXCTL" disable-device "$daxdev"
 	"$DAXCTL" reconfigure-device -s $(expr $size \* 2) "$daxdev"
+	# Adjusts space at the end, expect one mapping because we are
+	# able to extend existing region range.
+	test $(daxctl_get_nr_mappings $daxdev) -eq 1
 
 	fail_if_available
 
@@ -232,6 +293,7 @@ daxctl_test1()
 	daxdev=$("$DAXCTL" create-device -r 0 | jq -er '.[].chardev')
 
 	test -n "$daxdev"
+	test $(daxctl_get_nr_mappings $daxdev) -eq 1
 	fail_if_available
 
 	"$DAXCTL" disable-device "$daxdev" && "$DAXCTL" destroy-device "$daxdev"
Quoted 4 lines

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

maintainer
#13 lore raw

Re: [PATCH ndctl v2 10/10] daxctl/test: Add tests for dynamic dax regions

Quoted 43 lines · Joao Martins
Quoted 42 lines · Joao Martins
Quoted 23 lines · Joao Martins

Add a couple tests which exercise the new sysfs based interface for Soft-Reserved regions (by EFI/HMAT, or efi_fake_mem).

The tests exercise the daxctl orchestration surrounding for creating/disabling/destroying/reconfiguring devices. Furthermore it exercises dax region space allocation code paths particularly:

1) zeroing out and reconfiguring a dax device from its current size to be max available and back to initial size

2) creates devices from holes in the beginning, middle of the region.

3) reconfigures devices in a interleaving fashion

4) test adjust of the region towards beginning and end

The tests assume you pass a valid efi_fake_mem parameter marked as EFI_MEMORY_SP e.g.

Quoted 7 lines
	efi_fake_mem=112G@16G:0x40000

Naturally it bails out from the test if hmem device driver isn't loaded or builtin. If hmem regions are found, only region 0 is used, and the others remain untouched.

Following your suggestion[0], I added a couple more validations to this test suite, covering the mappings. So on top of this patch I added the following snip below the scissors mark. Mainly, I check that the size calculated by mappingNNNN is the same as advertised by the sysfs size attribute, thus looping through all the mappings.

Perhaps it would be enough to have just such validation in setup_dev() to catch the bug in [0]. But I went ahead and also validated the test cases where a certain amount of mappings are meant to be created.

Quoted 8 lines
Quoted 6 lines

My only worry is the last piece in daxctl_test_adjust() where we might be tying too much on how a kernel version picks space from the region; should this logic change in an unforeseeable future (e.g. allowing space at the beginning to be adjusted). Otherwise, if this no concern, let me know and I can resend a v3 with the adjustment below.

Ping?

Hi Joao,

Thanks for the patience on these, I've gone through the patches in preparation for the next release, and they all look mostly fine. I had a few minor fixups - to the documentation and the test (fixup module name, and shellcheck complaints). I've appended a diff below of all the fixups I added.

I've also included the patch below for the mapping size validation. I think the concern for future kernel layout changes is valid, but if/when that happens, we can always come back and relax or adjust the test as needed. So for now, I think having a pickier test should be better than not having one.

Quoted 4 lines
Quoted 4 lines

----->8------
Subject: Validate @size versus mappingX sizes

Quoted 8 lines
Quoted 8 lines

[0]
https://lore.kernel.org/linux-nvdimm/CAPcyv4hFS7JS9s7cUY=2Ru2kUTRsesxwX1PGnnc_tudJjoDUGw@mail.gmail.com/

---

 test/daxctl-create.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

My fixups:

---

 Documentation/daxctl/daxctl-create-device.txt      | 18 +++-----------
 Documentation/daxctl/daxctl-destroy-device.txt     | 22 ++++--------------
 Documentation/daxctl/daxctl-disable-device.txt     | 22 ++++--------------
 Documentation/daxctl/daxctl-enable-device.txt      | 22 ++++--------------
 Documentation/daxctl/daxctl-reconfigure-device.txt | 19 ++++-----------
 Documentation/daxctl/human-option.txt              |  8 +++++++
 Documentation/daxctl/region-option.txt             |  8 +++++++
 Documentation/daxctl/verbose-option.txt            |  5 ++++
 util/filter.c                                      |  2 +-
 test/daxctl-create.sh                              | 76 ++++++++++++++++++++++++++++++------------------------------
 10 files changed, 82 insertions(+), 120 deletions(-)

---

Documentation/daxctl/daxctl-create-device.txt +3 -15
index 648d254..70029ab 100644
@@ -71,12 +71,7 @@ EFI memory map with EFI_MEMORY_SP. The resultant ranges mean that it's
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
+include::region-option.txt[]
 
 -s::
 --size=::
@@ -87,16 +82,9 @@ OPTIONS
 
 	The size must be a multiple of the region alignment.
 
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
+include::human-option.txt[]
 
--v::
---verbose::
-	Emit more debug messages
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-destroy-device.txt +5 -17
index 1c91cb2..a63ab0c 100644
@@ -38,23 +38,11 @@ Destroys a dax device in 'devdax' mode.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
-
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
-
--v::
---verbose::
-	Emit more debug messages
+include::region-option.txt[]
+
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-disable-device.txt +5 -17
index 383aeeb..ee9f6e8 100644
@@ -33,23 +33,11 @@ Disables a dax device in 'devdax' mode.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
-
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
-
--v::
---verbose::
-	Emit more debug messages
+include::region-option.txt[]
+
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-enable-device.txt +5 -17
index 6410d92..24cdcf3 100644
@@ -34,23 +34,11 @@ Enables a dax device in 'devdax' mode.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
-
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
-
--v::
---verbose::
-	Emit more debug messages
+include::region-option.txt[]
+
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-reconfigure-device.txt +4 -15
index 8caae43..9a11ff5 100644
@@ -121,12 +121,7 @@ refrain from then onlining it.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
+include::region-option.txt[]
 
 -s::
 --size=::
@@ -161,16 +156,10 @@ include::movable-options.txt[]
 	to offline the memory on the NUMA node associated with the dax device
 	before converting it back to "devdax" mode.
 
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
 
--v::
---verbose::
-	Emit more debug messages
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/human-option.txt new file +8 -0
new file mode 100644
index 0000000..2f4de7a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+
+-u::
+--human::
+	By default the command will output machine-friendly raw-integer
+	data. Instead, with this flag, numbers representing storage size
+	will be formatted as human readable strings with units, other
+	fields are converted to hexadecimal strings.
Documentation/daxctl/region-option.txt new file +8 -0
new file mode 100644
index 0000000..a824e22
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+
+-r::
+--region=::
+	Restrict the operation to devices belonging to the specified region(s).
+	A device-dax region is a contiguous range of memory that hosts one or
+	more /dev/daxX.Y devices, where X is the region id and Y is the device
+	instance id.
Documentation/daxctl/verbose-option.txt new file +5 -0
new file mode 100644
index 0000000..cb62c8e
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0
+
+-v::
+--verbose::
+	Emit more debug messages
util/filter.c +1 -1
index 7c8debb..8c78f32 100644
@@ -342,7 +342,7 @@ struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
 		return region;
 
 	if ((sscanf(ident, "%d", &region_id) == 1
-				|| sscanf(ident, "region%d", &region_id) == 1)
+			|| sscanf(ident, "region%d", &region_id) == 1)
 			&& daxctl_region_get_id(region) == region_id)
 		return region;
 
test/daxctl-create.sh +38 -38

198 lines not on this page · raw message

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

#14 lore raw

Re: [PATCH ndctl v2 10/10] daxctl/test: Add tests for dynamic dax regions

Quoted 53 lines · Vishal L
Quoted 43 lines · Joao Martins
Quoted 42 lines · Joao Martins
Quoted 23 lines · Joao Martins

Add a couple tests which exercise the new sysfs based interface for Soft-Reserved regions (by EFI/HMAT, or efi_fake_mem).

The tests exercise the daxctl orchestration surrounding for creating/disabling/destroying/reconfiguring devices. Furthermore it exercises dax region space allocation code paths particularly:

1) zeroing out and reconfiguring a dax device from its current size to be max available and back to initial size

2) creates devices from holes in the beginning, middle of the region.

3) reconfigures devices in a interleaving fashion

4) test adjust of the region towards beginning and end

The tests assume you pass a valid efi_fake_mem parameter marked as EFI_MEMORY_SP e.g.

Quoted 7 lines
	efi_fake_mem=112G@16G:0x40000

Naturally it bails out from the test if hmem device driver isn't loaded or builtin. If hmem regions are found, only region 0 is used, and the others remain untouched.

Following your suggestion[0], I added a couple more validations to this test suite, covering the mappings. So on top of this patch I added the following snip below the scissors mark. Mainly, I check that the size calculated by mappingNNNN is the same as advertised by the sysfs size attribute, thus looping through all the mappings.

Perhaps it would be enough to have just such validation in setup_dev() to catch the bug in [0]. But I went ahead and also validated the test cases where a certain amount of mappings are meant to be created.

Quoted 8 lines
Quoted 6 lines

My only worry is the last piece in daxctl_test_adjust() where we might be tying too much on how a kernel version picks space from the region; should this logic change in an unforeseeable future (e.g. allowing space at the beginning to be adjusted). Otherwise, if this no concern, let me know and I can resend a v3 with the adjustment below.

Ping?

Quoted 8 lines

Hi Joao,

Thanks for the patience on these, I've gone through the patches in preparation for the next release, and they all look mostly fine. I had a few minor fixups - to the documentation and the test (fixup module name, and shellcheck complaints). I've appended a diff below of all the fixups I added.

The adjustments are looking good AFAICT.

Quoted 6 lines

I've also included the patch below for the mapping size validation. I think the concern for future kernel layout changes is valid, but if/when that happens, we can always come back and relax or adjust the test as needed. So for now, I think having a pickier test should be better than not having one.

Yeah, makes sense.

Thanks!
Joao
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

maintainer
#15 lore raw

Re: [PATCH ndctl v2 10/10] daxctl/test: Add tests for dynamic dax regions

In reply to Joao Martins
Quoted 43 lines · Joao Martins
Quoted 42 lines · Joao Martins
Quoted 23 lines · Joao Martins

Add a couple tests which exercise the new sysfs based interface for Soft-Reserved regions (by EFI/HMAT, or efi_fake_mem).

The tests exercise the daxctl orchestration surrounding for creating/disabling/destroying/reconfiguring devices. Furthermore it exercises dax region space allocation code paths particularly:

1) zeroing out and reconfiguring a dax device from its current size to be max available and back to initial size

2) creates devices from holes in the beginning, middle of the region.

3) reconfigures devices in a interleaving fashion

4) test adjust of the region towards beginning and end

The tests assume you pass a valid efi_fake_mem parameter marked as EFI_MEMORY_SP e.g.

Quoted 7 lines
	efi_fake_mem=112G@16G:0x40000

Naturally it bails out from the test if hmem device driver isn't loaded or builtin. If hmem regions are found, only region 0 is used, and the others remain untouched.

Following your suggestion[0], I added a couple more validations to this test suite, covering the mappings. So on top of this patch I added the following snip below the scissors mark. Mainly, I check that the size calculated by mappingNNNN is the same as advertised by the sysfs size attribute, thus looping through all the mappings.

Perhaps it would be enough to have just such validation in setup_dev() to catch the bug in [0]. But I went ahead and also validated the test cases where a certain amount of mappings are meant to be created.

Quoted 8 lines
Quoted 6 lines

My only worry is the last piece in daxctl_test_adjust() where we might be tying too much on how a kernel version picks space from the region; should this logic change in an unforeseeable future (e.g. allowing space at the beginning to be adjusted). Otherwise, if this no concern, let me know and I can resend a v3 with the adjustment below.

Ping?

Hi Joao,

Thanks for the patience on these, I've gone through the patches in preparation for the next release, and they all look mostly fine. I had a few minor fixups - to the documentation and the test (fixup module name, and shellcheck complaints). I've appended a diff below of all the fixups I added.

I've also included the patch below for the mapping size validation. I think the concern for future kernel layout changes is valid, but if/when that happens, we can always come back and relax or adjust the test as needed. So for now, I think having a pickier test should be better than not having one.

Quoted 4 lines
Quoted 4 lines

----->8------
Subject: Validate @size versus mappingX sizes

Quoted 8 lines
Quoted 8 lines

[0]
https://lore.kernel.org/linux-nvdimm/CAPcyv4hFS7JS9s7cUY=2Ru2kUTRsesxwX1PGnnc_tudJjoDUGw@mail.gmail.com/

---

 test/daxctl-create.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

My fixups:

---

Documentation/daxctl/daxctl-create-device.txt | 18 +++-----------

 Documentation/daxctl/daxctl-destroy-device.txt     | 22 ++++--------------
 Documentation/daxctl/daxctl-disable-device.txt     | 22 ++++--------------
 Documentation/daxctl/daxctl-enable-device.txt      | 22 ++++--------------
 Documentation/daxctl/daxctl-reconfigure-device.txt | 19 ++++-----------
 Documentation/daxctl/human-option.txt              |  8 +++++++
 Documentation/daxctl/region-option.txt             |  8 +++++++
 Documentation/daxctl/verbose-option.txt            |  5 ++++
 util/filter.c                                      |  2 +-
 test/daxctl-create.sh                              | 76 ++++++++++++++++++++++++++++++------------------------------
 10 files changed, 82 insertions(+), 120 deletions(-)

---

Documentation/daxctl/daxctl-create-device.txt +3 -15
index 648d254..70029ab 100644
@@ -71,12 +71,7 @@ EFI memory map with EFI_MEMORY_SP. The resultant ranges mean that it's
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
+include::region-option.txt[]
 
 -s::
 --size=::
@@ -87,16 +82,9 @@ OPTIONS
 
 	The size must be a multiple of the region alignment.
 
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
+include::human-option.txt[]
 
--v::
---verbose::
-	Emit more debug messages
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-destroy-device.txt +5 -17
index 1c91cb2..a63ab0c 100644
@@ -38,23 +38,11 @@ Destroys a dax device in 'devdax' mode.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
-
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
-
--v::
---verbose::
-	Emit more debug messages
+include::region-option.txt[]
+
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-disable-device.txt +5 -17
index 383aeeb..ee9f6e8 100644
@@ -33,23 +33,11 @@ Disables a dax device in 'devdax' mode.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
-
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
-
--v::
---verbose::
-	Emit more debug messages
+include::region-option.txt[]
+
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-enable-device.txt +5 -17
index 6410d92..24cdcf3 100644
@@ -34,23 +34,11 @@ Enables a dax device in 'devdax' mode.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
-
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
-
--v::
---verbose::
-	Emit more debug messages
+include::region-option.txt[]
+
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/daxctl-reconfigure-device.txt +4 -15
index 8caae43..9a11ff5 100644
@@ -121,12 +121,7 @@ refrain from then onlining it.
 
 OPTIONS
 -------
--r::
---region=::
-	Restrict the operation to devices belonging to the specified region(s).
-	A device-dax region is a contiguous range of memory that hosts one or
-	more /dev/daxX.Y devices, where X is the region id and Y is the device
-	instance id.
+include::region-option.txt[]
 
 -s::
 --size=::
@@ -161,16 +156,10 @@ include::movable-options.txt[]
 	to offline the memory on the NUMA node associated with the dax device
 	before converting it back to "devdax" mode.
 
--u::
---human::
-	By default the command will output machine-friendly raw-integer
-	data. Instead, with this flag, numbers representing storage size
-	will be formatted as human readable strings with units, other
-	fields are converted to hexadecimal strings.
 
--v::
---verbose::
-	Emit more debug messages
+include::human-option.txt[]
+
+include::verbose-option.txt[]
 
 include::../copyright.txt[]
 
Documentation/daxctl/human-option.txt new file +8 -0
new file mode 100644
index 0000000..2f4de7a
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+
+-u::
+--human::
+	By default the command will output machine-friendly raw-integer
+	data. Instead, with this flag, numbers representing storage size
+	will be formatted as human readable strings with units, other
+	fields are converted to hexadecimal strings.
Documentation/daxctl/region-option.txt new file +8 -0
new file mode 100644
index 0000000..a824e22
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+
+-r::
+--region=::
+	Restrict the operation to devices belonging to the specified region(s).
+	A device-dax region is a contiguous range of memory that hosts one or
+	more /dev/daxX.Y devices, where X is the region id and Y is the device
+	instance id.
Documentation/daxctl/verbose-option.txt new file +5 -0
new file mode 100644
index 0000000..cb62c8e
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0
+
+-v::
+--verbose::
+	Emit more debug messages
util/filter.c +1 -1
index 7c8debb..8c78f32 100644
@@ -342,7 +342,7 @@ struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
 		return region;
 
 	if ((sscanf(ident, "%d", &region_id) == 1
-				|| sscanf(ident, "region%d", &region_id) == 1)
+			|| sscanf(ident, "region%d", &region_id) == 1)
 			&& daxctl_region_get_id(region) == region_id)
 		return region;
 
test/daxctl-create.sh +38 -38

198 lines not on this page · raw message

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]