* [ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups
@ 2021-01-13 7:14 Dan Williams
2021-01-13 7:14 ` [ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning Dan Williams
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Dan Williams @ 2021-01-13 7:14 UTC (permalink / raw)
To: vishal.l.verma; +Cc: linux-nvdimm
Vishal,
Here's a collection of test updates. It adds support for regression
testing pfn_to_online_page() which suffered from a lack of precision in
mixed zone memory-sections. Updates the mremap() regression to accept
failure as an option (the behavior in v5.11-rc1+). Fixes a warning, and
ditches an 'out' label.
---
Dan Williams (4):
ndctl/test: Fix btt expect table compile warning
ndctl/test: Cleanup unnecessary out label
ndctl/test: Fix device-dax mremap() test
ndctl/test: Exercise soft_offline_page() corner cases
test/dax-pmd.c | 17 +++++++++--------
test/dax-poison.c | 19 +++++++++++++++++++
test/device-dax.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
test/libndctl.c | 12 ++++++------
4 files changed, 79 insertions(+), 14 deletions(-)
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning
2021-01-13 7:14 [ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups Dan Williams
@ 2021-01-13 7:14 ` Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 2/4] ndctl/test: Cleanup unnecessary out label Dan Williams
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2021-01-13 7:14 UTC (permalink / raw)
To: vishal.l.verma; +Cc: linux-nvdimm
../test/libndctl.c:989:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
989 | unsigned long long expect_table[][2] = {
| ^~~~~~~~
...just move the declaration a few lines up.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
test/libndctl.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/libndctl.c b/test/libndctl.c
index 24d72b382239..fc651499cc86 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -980,12 +980,6 @@ static int check_btt_size(struct ndctl_btt *btt)
struct ndctl_ctx *ctx = ndctl_btt_get_ctx(btt);
struct ndctl_test *test = ndctl_get_private_data(ctx);
struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt);
-
- if (!ndns)
- return -ENXIO;
-
- ns_size = ndctl_namespace_get_size(ndns);
- sect_size = ndctl_btt_get_sector_size(btt);
unsigned long long expect_table[][2] = {
[0] = {
[0] = 0x11b5400,
@@ -1001,6 +995,12 @@ static int check_btt_size(struct ndctl_btt *btt)
},
};
+ if (!ndns)
+ return -ENXIO;
+
+ ns_size = ndctl_namespace_get_size(ndns);
+ sect_size = ndctl_btt_get_sector_size(btt);
+
if (sect_size >= SZ_4K)
sect_select = 1;
else if (sect_size >= 512)
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [ndctl PATCH 2/4] ndctl/test: Cleanup unnecessary out label
2021-01-13 7:14 [ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups Dan Williams
2021-01-13 7:14 ` [ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning Dan Williams
@ 2021-01-13 7:15 ` Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 3/4] ndctl/test: Fix device-dax mremap() test Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 4/4] ndctl/test: Exercise soft_offline_page() corner cases Dan Williams
3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2021-01-13 7:15 UTC (permalink / raw)
To: vishal.l.verma; +Cc: linux-nvdimm
There are no cleanup actions to take in test_dax_remap(), and it is already
inconsistent for having a single return point, so remove the out label.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
test/dax-pmd.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/test/dax-pmd.c b/test/dax-pmd.c
index 401826d02d69..b1251db63041 100644
--- a/test/dax-pmd.c
+++ b/test/dax-pmd.c
@@ -83,20 +83,18 @@ int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, voi
act.sa_flags = SA_SIGINFO;
if (sigaction(SIGBUS, &act, 0)) {
perror("sigaction");
- rc = EXIT_FAILURE;
- goto out;
+ return EXIT_FAILURE;
}
/* test fault after device-dax instance disabled */
if (sigsetjmp(sj_env, 1)) {
if (!fsdax && align > SZ_4K) {
fprintf(stderr, "got expected SIGBUS after mremap() of device-dax\n");
- rc = 0;
+ return 0;
} else {
fprintf(stderr, "unpexpected SIGBUS after mremap()\n");
- rc = -EIO;
+ return -EIO;
}
- goto out;
}
*(int *) anon = 0xAA;
@@ -107,9 +105,7 @@ int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, voi
return -ENXIO;
}
- rc = 0;
-out:
- return rc;
+ return 0;
}
int test_dax_directio(int dax_fd, unsigned long align, void *dax_addr, off_t offset)
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [ndctl PATCH 3/4] ndctl/test: Fix device-dax mremap() test
2021-01-13 7:14 [ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups Dan Williams
2021-01-13 7:14 ` [ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 2/4] ndctl/test: Cleanup unnecessary out label Dan Williams
@ 2021-01-13 7:15 ` Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 4/4] ndctl/test: Exercise soft_offline_page() corner cases Dan Williams
3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2021-01-13 7:15 UTC (permalink / raw)
To: vishal.l.verma; +Cc: linux-nvdimm
The test_dax_remap() test is a regression check for mishandling of mremap()
in the presence of pmd_devmap(). My understanding is that it was a fuzzing
condition not something an application would want to do in practice.
On recent kernels with commit 73d5e0629919 ("mremap: check if it's possible
to split original vma"), the test fails for device-dax. That seems an
equally acceptable result of attempting this remap, so update the test
rather than ask the kernel to preserve the old behaviour.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
test/dax-pmd.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/dax-pmd.c b/test/dax-pmd.c
index b1251db63041..7648e348b0a6 100644
--- a/test/dax-pmd.c
+++ b/test/dax-pmd.c
@@ -69,6 +69,11 @@ int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, voi
remap = mremap(addr, REMAP_SIZE, REMAP_SIZE, MREMAP_MAYMOVE|MREMAP_FIXED, anon);
+ if (remap == MAP_FAILED) {
+ fprintf(stderr, "%s: mremap failed, that's ok too\n", __func__);
+ return 0;
+ }
+
if (remap != anon) {
rc = -ENXIO;
perror("mremap");
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [ndctl PATCH 4/4] ndctl/test: Exercise soft_offline_page() corner cases
2021-01-13 7:14 [ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups Dan Williams
` (2 preceding siblings ...)
2021-01-13 7:15 ` [ndctl PATCH 3/4] ndctl/test: Fix device-dax mremap() test Dan Williams
@ 2021-01-13 7:15 ` Dan Williams
3 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2021-01-13 7:15 UTC (permalink / raw)
To: vishal.l.verma; +Cc: linux-nvdimm
Test soft-offline injection into PMEM namespace metadata and user mapped
space. Both attempts should fail on kernels with a pfn_to_online_page()
implementation that considers subsection ZONE_DEVICE ranges.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
test/dax-poison.c | 19 +++++++++++++++++++
test/device-dax.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+)
diff --git a/test/dax-poison.c b/test/dax-poison.c
index a4ef12eca1be..4e09761f0a5e 100644
--- a/test/dax-poison.c
+++ b/test/dax-poison.c
@@ -5,6 +5,7 @@
#include <signal.h>
#include <setjmp.h>
#include <sys/mman.h>
+#include <linux/mman.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
@@ -49,6 +50,7 @@ int test_dax_poison(struct ndctl_test *test, int dax_fd, unsigned long align,
unsigned char *addr = MAP_FAILED;
struct sigaction act;
unsigned x = x;
+ FILE *smaps;
void *buf;
int rc;
@@ -94,6 +96,9 @@ int test_dax_poison(struct ndctl_test *test, int dax_fd, unsigned long align,
goto out;
}
+ fprintf(stderr, "%s: mmap got %p align: %ld offset: %zd\n",
+ __func__, addr, align, offset);
+
if (sigsetjmp(sj_env, 1)) {
if (sig_mcerr_ar) {
fprintf(stderr, "madvise triggered 'action required' sigbus\n");
@@ -104,6 +109,20 @@ int test_dax_poison(struct ndctl_test *test, int dax_fd, unsigned long align,
}
}
+ rc = madvise(addr + align / 2, 4096, MADV_SOFT_OFFLINE);
+ if (rc == 0) {
+ fprintf(stderr, "softoffline should always fail for dax\n");
+ smaps = fopen("/proc/self/smaps", "r");
+ do {
+ rc = fread(buf, 1, 4096, smaps);
+ fwrite(buf, 1, rc, stderr);
+ } while (rc);
+ fclose(smaps);
+ fail();
+ rc = -ENXIO;
+ goto out;
+ }
+
rc = madvise(addr + align / 2, 4096, MADV_HWPOISON);
if (rc) {
fail();
diff --git a/test/device-dax.c b/test/device-dax.c
index 5f0da297f28e..aad8fa5f1cb1 100644
--- a/test/device-dax.c
+++ b/test/device-dax.c
@@ -128,6 +128,44 @@ static int verify_data(struct daxctl_dev *dev, char *dax_buf,
return 0;
}
+static int test_dax_soft_offline(struct ndctl_test *test, struct ndctl_namespace *ndns)
+{
+ unsigned long long resource = ndctl_namespace_get_resource(ndns);
+ int fd, rc;
+ char *buf;
+
+ if (resource == ULLONG_MAX) {
+ fprintf(stderr, "failed to get resource: %s\n",
+ ndctl_namespace_get_devname(ndns));
+ return -ENXIO;
+ }
+
+ fd = open("/sys/devices/system/memory/soft_offline_page", O_WRONLY);
+ if (fd < 0) {
+ fprintf(stderr, "failed to open soft_offline_page\n");
+ return -ENOENT;
+ }
+
+ rc = asprintf(&buf, "%#llx\n", resource);
+ if (rc < 0) {
+ fprintf(stderr, "failed to alloc resource\n");
+ close(fd);
+ return -ENOMEM;
+ }
+
+ fprintf(stderr, "%s: try to offline page @%#llx\n", __func__, resource);
+ rc = write(fd, buf, rc);
+ free(buf);
+ close(fd);
+
+ if (rc >= 0) {
+ fprintf(stderr, "%s: should have failed\n", __func__);
+ return -ENXIO;
+ }
+
+ return 0;
+}
+
static int __test_device_dax(unsigned long align, int loglevel,
struct ndctl_test *test, struct ndctl_ctx *ctx)
{
@@ -278,6 +316,13 @@ static int __test_device_dax(unsigned long align, int loglevel,
goto out;
}
+ rc = test_dax_soft_offline(test, ndns);
+ if (rc) {
+ fprintf(stderr, "%s: failed dax soft offline\n",
+ ndctl_namespace_get_devname(ndns));
+ goto out;
+ }
+
rc = test_dax_poison(test, fd, align, NULL, 0, devdax);
if (rc) {
fprintf(stderr, "%s: failed dax poison\n",
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-13 7:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 7:14 [ndctl PATCH 0/4] ndctl/test: softoffline, mremap, and misc fixups Dan Williams
2021-01-13 7:14 ` [ndctl PATCH 1/4] ndctl/test: Fix btt expect table compile warning Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 2/4] ndctl/test: Cleanup unnecessary out label Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 3/4] ndctl/test: Fix device-dax mremap() test Dan Williams
2021-01-13 7:15 ` [ndctl PATCH 4/4] ndctl/test: Exercise soft_offline_page() corner cases Dan Williams
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).