nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH 0/3] ndctl: nvdimm notification tests
@ 2016-08-23 23:05 Dan Williams
  2016-08-23 23:05 ` [ndctl PATCH 1/3] test: gate SMART payload verification on v4.9 Dan Williams
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dan Williams @ 2016-08-23 23:05 UTC (permalink / raw)
  To: linux-nvdimm

Add a new api, ndctl_dimm_get_health_eventfd(), and test that the kernel
signals an event on that file descriptor after a smart-threshold
command. 

Also, include a new gate for the SMART verification test to await when
nfit_test is updated to emit the new v1.2 format of the SMART DSM
payload.

---

Dan Williams (3):
      test: gate SMART payload verification on v4.9
      ndctl: add ndctl_dimm_get_health_eventfd() api
      test: validate ndctl_dimm_get_health_eventfd()


 ndctl/lib/libndctl.c   |   11 +++++++++
 ndctl/lib/libndctl.sym |    1 +
 ndctl/libndctl.h.in    |    1 +
 test/libndctl.c        |   61 ++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 69 insertions(+), 5 deletions(-)
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ndctl PATCH 1/3] test: gate SMART payload verification on v4.9
  2016-08-23 23:05 [ndctl PATCH 0/3] ndctl: nvdimm notification tests Dan Williams
@ 2016-08-23 23:05 ` Dan Williams
  2016-08-23 23:05 ` [ndctl PATCH 2/3] ndctl: add ndctl_dimm_get_health_eventfd() api Dan Williams
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2016-08-23 23:05 UTC (permalink / raw)
  To: linux-nvdimm

The kernel uses the old v1 DSM payload until v4.9.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/libndctl.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/libndctl.c b/test/libndctl.c
index 30b78a2824f1..7c81531a03c2 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2254,8 +2254,11 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 	};
 	unsigned int i, rc = 0;
 
-	/* the kernel did not start emulating smart data until 4.7 */
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 7, 0)))
+	/*
+	 * The kernel did not start emulating v1.2 namespace spec smart data
+	 * until 4.9.
+	 */
+	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 9, 0)))
 		dimm_commands &= ~((1 << ND_CMD_SMART)
 				| (1 << ND_CMD_SMART_THRESHOLD));
 

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [ndctl PATCH 2/3] ndctl: add ndctl_dimm_get_health_eventfd() api
  2016-08-23 23:05 [ndctl PATCH 0/3] ndctl: nvdimm notification tests Dan Williams
  2016-08-23 23:05 ` [ndctl PATCH 1/3] test: gate SMART payload verification on v4.9 Dan Williams
@ 2016-08-23 23:05 ` Dan Williams
  2016-08-23 23:05 ` [ndctl PATCH 3/3] test: validate ndctl_dimm_get_health_eventfd() Dan Williams
  2016-08-23 23:48 ` [ndctl PATCH 0/3] ndctl: nvdimm notification tests Vishal Verma
  3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2016-08-23 23:05 UTC (permalink / raw)
  To: linux-nvdimm

Return a poll(2) capable file descriptor that triggers whenever an
nvdimm device receives an ACPI 6.1 health event notification.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/lib/libndctl.c   |   11 +++++++++++
 ndctl/lib/libndctl.sym |    1 +
 ndctl/libndctl.h.in    |    1 +
 3 files changed, 13 insertions(+)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 5f354ac0fa7a..205fef17a151 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -139,6 +139,7 @@ struct ndctl_dimm {
 	char *unique_id;
 	char *dimm_path;
 	char *dimm_buf;
+	int health_eventfd;
 	int buf_len;
 	int id;
 	union {
@@ -591,6 +592,8 @@ static void free_dimm(struct ndctl_dimm *dimm)
 	free(dimm->dimm_path);
 	if (dimm->module)
 		kmod_module_unref(dimm->module);
+	if (dimm->health_eventfd > -1)
+		close(dimm->health_eventfd);
 	free(dimm);
 }
 
@@ -1169,6 +1172,7 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 	dimm->vendor_id = -1;
 	dimm->device_id = -1;
 	dimm->revision_id = -1;
+	dimm->health_eventfd = -1;
 	dimm->subsystem_vendor_id = -1;
 	dimm->subsystem_device_id = -1;
 	dimm->subsystem_revision_id = -1;
@@ -1250,6 +1254,8 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 	sprintf(path, "%s/nfit/flags", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) == 0)
 		parse_nfit_mem_flags(dimm, buf);
+
+	dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
  out:
 	list_add(&bus->dimms, &dimm->list);
 	free(path);
@@ -1429,6 +1435,11 @@ NDCTL_EXPORT int ndctl_dimm_is_cmd_supported(struct ndctl_dimm *dimm,
 	return !!(dimm->dsm_mask & (1ULL << cmd));
 }
 
+NDCTL_EXPORT int ndctl_dimm_get_health_eventfd(struct ndctl_dimm *dimm)
+{
+	return dimm->health_eventfd;
+}
+
 NDCTL_EXPORT unsigned int ndctl_dimm_handle_get_node(struct ndctl_dimm *dimm)
 {
 	return dimm->handle >> 16 & 0xfff;
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index b5d286683732..dfc44ae51362 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -62,6 +62,7 @@ global:
 	ndctl_dimm_failed_restore;
 	ndctl_dimm_smart_pending;
 	ndctl_dimm_failed_flush;
+	ndctl_dimm_get_health_eventfd;
 	ndctl_dimm_is_cmd_supported;
 	ndctl_dimm_handle_get_node;
 	ndctl_dimm_handle_get_socket;
diff --git a/ndctl/libndctl.h.in b/ndctl/libndctl.h.in
index 451466aedb7e..00bce4298958 100644
--- a/ndctl/libndctl.h.in
+++ b/ndctl/libndctl.h.in
@@ -143,6 +143,7 @@ int ndctl_dimm_failed_arm(struct ndctl_dimm *dimm);
 int ndctl_dimm_failed_restore(struct ndctl_dimm *dimm);
 int ndctl_dimm_smart_pending(struct ndctl_dimm *dimm);
 int ndctl_dimm_failed_flush(struct ndctl_dimm *dimm);
+int ndctl_dimm_get_health_eventfd(struct ndctl_dimm *dimm);
 unsigned int ndctl_dimm_handle_get_node(struct ndctl_dimm *dimm);
 unsigned int ndctl_dimm_handle_get_socket(struct ndctl_dimm *dimm);
 unsigned int ndctl_dimm_handle_get_imc(struct ndctl_dimm *dimm);

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [ndctl PATCH 3/3] test: validate ndctl_dimm_get_health_eventfd()
  2016-08-23 23:05 [ndctl PATCH 0/3] ndctl: nvdimm notification tests Dan Williams
  2016-08-23 23:05 ` [ndctl PATCH 1/3] test: gate SMART payload verification on v4.9 Dan Williams
  2016-08-23 23:05 ` [ndctl PATCH 2/3] ndctl: add ndctl_dimm_get_health_eventfd() api Dan Williams
@ 2016-08-23 23:05 ` Dan Williams
  2016-08-23 23:48 ` [ndctl PATCH 0/3] ndctl: nvdimm notification tests Vishal Verma
  3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2016-08-23 23:05 UTC (permalink / raw)
  To: linux-nvdimm

nfit_test simulates a dimm notification event each time the smart-threshold DSM
is invoked.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/libndctl.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/test/libndctl.c b/test/libndctl.c
index 7c81531a03c2..5f86addc5c7e 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -21,8 +21,11 @@
 #include <limits.h>
 #include <syslog.h>
 #include <libkmod.h>
+#include <sys/wait.h>
 #include <uuid/uuid.h>
+#include <sys/types.h>
 #include <sys/ioctl.h>
+#include <sys/select.h>
 #include <linux/version.h>
 
 #include <ccan/array_size/array_size.h>
@@ -1783,6 +1786,7 @@ static int check_btts(struct ndctl_region *region, struct btt **btts)
 struct check_cmd {
 	int (*check_fn)(struct ndctl_bus *bus, struct ndctl_dimm *dimm, struct check_cmd *check);
 	struct ndctl_cmd *cmd;
+	struct ndctl_test *test;
 };
 
 static struct check_cmd *check_cmds;
@@ -2005,7 +2009,9 @@ static int check_smart_threshold(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 		.spares = 5,
 	};
 	struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_smart_threshold(dimm);
-	int rc;
+	struct timeval tm;
+	fd_set fds;
+	int rc, fd;
 
 	if (!cmd) {
 		fprintf(stderr, "%s: dimm: %#x failed to create cmd\n",
@@ -2013,6 +2019,36 @@ static int check_smart_threshold(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 		return -ENXIO;
 	}
 
+	fd = ndctl_dimm_get_health_eventfd(dimm);
+	FD_ZERO(&fds);
+	tm.tv_sec = 0;
+	tm.tv_usec = 500;
+	rc = select(fd + 1, NULL, NULL, &fds, &tm);
+	if (rc) {
+		fprintf(stderr, "%s: expected health event timeout\n",
+				ndctl_dimm_get_devname(dimm));
+		return -ENXIO;
+	}
+
+	/*
+	 * Starting with v4.9 smart threshold requests trigger the file
+	 * descriptor returned by ndctl_dimm_get_health_eventfd().
+	 */
+	if (ndctl_test_attempt(check->test, KERNEL_VERSION(4, 9, 0))) {
+		int pid = fork();
+
+		if (pid == 0) {
+			FD_ZERO(&fds);
+			FD_SET(fd, &fds);
+			tm.tv_sec = 1;
+			tm.tv_usec = 0;
+			rc = select(fd + 1, NULL, NULL, &fds, &tm);
+			if (rc != 1 || !FD_ISSET(fd, &fds))
+				exit(EXIT_FAILURE);
+			exit(EXIT_SUCCESS);
+		}
+	}
+
 	rc = ndctl_cmd_submit(cmd);
 	if (rc) {
 		fprintf(stderr, "%s: dimm: %#x failed to submit cmd: %d\n",
@@ -2021,6 +2057,15 @@ static int check_smart_threshold(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 		return rc;
 	}
 
+	if (ndctl_test_attempt(check->test, KERNEL_VERSION(4, 9, 0))) {
+		wait(&rc);
+		if (WEXITSTATUS(rc) == EXIT_FAILURE) {
+			fprintf(stderr, "%s: expect health event trigger\n",
+					ndctl_dimm_get_devname(dimm));
+			return -ENXIO;
+		}
+	}
+
 	__check_smart_threshold(dimm, cmd, alarm_control);
 	__check_smart_threshold(dimm, cmd, temperature);
 	__check_smart_threshold(dimm, cmd, spares);
@@ -2235,12 +2280,15 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 	 * check_set_config_data can assume that both
 	 * check_get_config_size and check_get_config_data have run
 	 */
-	static struct check_cmd __check_dimm_cmds[] = {
+	struct check_cmd __check_dimm_cmds[] = {
 		[ND_CMD_GET_CONFIG_SIZE] = { check_get_config_size },
 		[ND_CMD_GET_CONFIG_DATA] = { check_get_config_data },
 		[ND_CMD_SET_CONFIG_DATA] = { check_set_config_data },
 		[ND_CMD_SMART] = { check_smart },
-		[ND_CMD_SMART_THRESHOLD] = { check_smart_threshold },
+		[ND_CMD_SMART_THRESHOLD] = {
+			.check_fn = check_smart_threshold,
+			.test = test,
+		},
 	};
 	static struct check_cmd __check_bus_cmds[] = {
 #ifdef HAVE_NDCTL_ARS

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [ndctl PATCH 0/3] ndctl: nvdimm notification tests
  2016-08-23 23:05 [ndctl PATCH 0/3] ndctl: nvdimm notification tests Dan Williams
                   ` (2 preceding siblings ...)
  2016-08-23 23:05 ` [ndctl PATCH 3/3] test: validate ndctl_dimm_get_health_eventfd() Dan Williams
@ 2016-08-23 23:48 ` Vishal Verma
  3 siblings, 0 replies; 5+ messages in thread
From: Vishal Verma @ 2016-08-23 23:48 UTC (permalink / raw)
  To: Dan Williams; +Cc: linux-nvdimm

On 08/23, Dan Williams wrote:
> Add a new api, ndctl_dimm_get_health_eventfd(), and test that the kernel
> signals an event on that file descriptor after a smart-threshold
> command. 
> 
> Also, include a new gate for the SMART verification test to await when
> nfit_test is updated to emit the new v1.2 format of the SMART DSM
> payload.
> 
> ---
> 
> Dan Williams (3):
>       test: gate SMART payload verification on v4.9
>       ndctl: add ndctl_dimm_get_health_eventfd() api
>       test: validate ndctl_dimm_get_health_eventfd()
> 
> 
>  ndctl/lib/libndctl.c   |   11 +++++++++
>  ndctl/lib/libndctl.sym |    1 +
>  ndctl/libndctl.h.in    |    1 +
>  test/libndctl.c        |   61 ++++++++++++++++++++++++++++++++++++++++++++----
>  4 files changed, 69 insertions(+), 5 deletions(-)

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-23 23:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 23:05 [ndctl PATCH 0/3] ndctl: nvdimm notification tests Dan Williams
2016-08-23 23:05 ` [ndctl PATCH 1/3] test: gate SMART payload verification on v4.9 Dan Williams
2016-08-23 23:05 ` [ndctl PATCH 2/3] ndctl: add ndctl_dimm_get_health_eventfd() api Dan Williams
2016-08-23 23:05 ` [ndctl PATCH 3/3] test: validate ndctl_dimm_get_health_eventfd() Dan Williams
2016-08-23 23:48 ` [ndctl PATCH 0/3] ndctl: nvdimm notification tests Vishal Verma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).