* [PATCH mm-unstable v1 0/4] selftests/vm: fix some tests on 32bit
@ 2022-12-05 19:37 David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 1/4] mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem David Hildenbrand
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-12-05 19:37 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linux-kselftest, David Hildenbrand, Andrew Morton,
Shuah Khan, Yang Li
I finally had the time to run some of the selftests written by me
(especially "cow") on x86 PAE. I found some unexpected "surprises" :)
With these changes, and with [1] on top of mm-unstable, the "cow" tests and
the "ksm_functional_tests" compile and pass as expected (expected failures
with hugetlb in the "cow" tests). "madv_populate" has one expected test
failure -- x86 does not support softdirty tracking.
#1-#3 fix commits with stable commit ids. #4 fixes a test that is not in
mm-stable yet.
A note that there are many other compile errors/warnings when compiling
on 32bit and with older Linux headers ... something for another day.
[1] https://lkml.kernel.org/r/20221205150857.167583-1-david@redhat.com
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Yang Li <yang.lee@linux.alibaba.com>
David Hildenbrand (4):
mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem
selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE)
definitions
selftests/vm: cow: fix compile warning on 32bit
selftests/vm: ksm_functional_tests: fixes for 32bit
mm/gup_test.c | 10 +++++++---
tools/testing/selftests/vm/cow.c | 4 ++--
tools/testing/selftests/vm/ksm_functional_tests.c | 4 ++--
tools/testing/selftests/vm/madv_populate.c | 7 +++++++
tools/testing/selftests/vm/vm_util.c | 2 +-
5 files changed, 19 insertions(+), 8 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH mm-unstable v1 1/4] mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem
2022-12-05 19:37 [PATCH mm-unstable v1 0/4] selftests/vm: fix some tests on 32bit David Hildenbrand
@ 2022-12-05 19:37 ` David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 2/4] selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE) definitions David Hildenbrand
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-12-05 19:37 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linux-kselftest, David Hildenbrand, Andrew Morton,
Shuah Khan, Yang Li
... we have to kmap()/kunmap(), otherwise this won't work as expected
with highmem.
Fixes: c77369b437f9 ("mm/gup_test: start/stop/read functionality for PIN LONGTERM test")
Signed-off-by: David Hildenbrand <david@redhat.com>
---
mm/gup_test.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/mm/gup_test.c b/mm/gup_test.c
index 0d76d9b4bb5a..33f431e0da60 100644
--- a/mm/gup_test.c
+++ b/mm/gup_test.c
@@ -4,6 +4,7 @@
#include <linux/uaccess.h>
#include <linux/ktime.h>
#include <linux/debugfs.h>
+#include <linux/highmem.h>
#include "gup_test.h"
static void put_back_pages(unsigned int cmd, struct page **pages,
@@ -297,10 +298,13 @@ static inline int pin_longterm_test_read(unsigned long arg)
return -EFAULT;
for (i = 0; i < pin_longterm_test_nr_pages; i++) {
- void *addr = page_to_virt(pin_longterm_test_pages[i]);
+ void *addr = kmap_local_page(pin_longterm_test_pages[i]);
+ unsigned long ret;
- if (copy_to_user((void __user *)(unsigned long)user_addr, addr,
- PAGE_SIZE))
+ ret = copy_to_user((void __user *)(unsigned long)user_addr, addr,
+ PAGE_SIZE);
+ kunmap_local(addr);
+ if (ret)
return -EFAULT;
user_addr += PAGE_SIZE;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH mm-unstable v1 2/4] selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE) definitions
2022-12-05 19:37 [PATCH mm-unstable v1 0/4] selftests/vm: fix some tests on 32bit David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 1/4] mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem David Hildenbrand
@ 2022-12-05 19:37 ` David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 3/4] selftests/vm: cow: fix compile warning on 32bit David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 4/4] selftests/vm: ksm_functional_tests: fixes for 32bit David Hildenbrand
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-12-05 19:37 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linux-kselftest, David Hildenbrand, Andrew Morton,
Shuah Khan, Yang Li
The tests fail to compile in some environments (e.g., Debian 11.5 on x86).
Let's simply conditionally define MADV_POPULATE_(READ|WRITE) if not
already defined, similar to how the khugepaged.c test handles it.
Fixes: 39b2e5cae43d ("selftests/vm: make MADV_POPULATE_(READ|WRITE) use in-tree headers")
Signed-off-by: David Hildenbrand <david@redhat.com>
---
tools/testing/selftests/vm/madv_populate.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/vm/madv_populate.c b/tools/testing/selftests/vm/madv_populate.c
index 60547245e479..262eae6b58f2 100644
--- a/tools/testing/selftests/vm/madv_populate.c
+++ b/tools/testing/selftests/vm/madv_populate.c
@@ -20,6 +20,13 @@
#include "../kselftest.h"
#include "vm_util.h"
+#ifndef MADV_POPULATE_READ
+#define MADV_POPULATE_READ 22
+#endif /* MADV_POPULATE_READ */
+#ifndef MADV_POPULATE_WRITE
+#define MADV_POPULATE_WRITE 23
+#endif /* MADV_POPULATE_WRITE */
+
/*
* For now, we're using 2 MiB of private anonymous memory for all tests.
*/
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH mm-unstable v1 3/4] selftests/vm: cow: fix compile warning on 32bit
2022-12-05 19:37 [PATCH mm-unstable v1 0/4] selftests/vm: fix some tests on 32bit David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 1/4] mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 2/4] selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE) definitions David Hildenbrand
@ 2022-12-05 19:37 ` David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 4/4] selftests/vm: ksm_functional_tests: fixes for 32bit David Hildenbrand
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-12-05 19:37 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linux-kselftest, David Hildenbrand, Andrew Morton,
Shuah Khan, Yang Li
The compiler complains about the conversion of a pointer to an int of
different width.
Fixes: 6f1405efc61b ("selftests/vm: anon_cow: add R/O longterm tests via gup_test")
Signed-off-by: David Hildenbrand <david@redhat.com>
---
tools/testing/selftests/vm/cow.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/vm/cow.c b/tools/testing/selftests/vm/cow.c
index 73e05b52c49e..26f6ea3079e2 100644
--- a/tools/testing/selftests/vm/cow.c
+++ b/tools/testing/selftests/vm/cow.c
@@ -650,7 +650,7 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,
}
/* Take a R/O pin. This should trigger unsharing. */
- args.addr = (__u64)mem;
+ args.addr = (__u64)(uintptr_t)mem;
args.size = size;
args.flags = fast ? PIN_LONGTERM_TEST_FLAG_USE_FAST : 0;
ret = ioctl(gup_fd, PIN_LONGTERM_TEST_START, &args);
@@ -669,7 +669,7 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,
* Read back the content via the pin to the temporary buffer and
* test if we observed the modification.
*/
- tmp_val = (__u64)tmp;
+ tmp_val = (__u64)(uintptr_t)tmp;
ret = ioctl(gup_fd, PIN_LONGTERM_TEST_READ, &tmp_val);
if (ret)
ksft_test_result_fail("PIN_LONGTERM_TEST_READ failed\n");
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH mm-unstable v1 4/4] selftests/vm: ksm_functional_tests: fixes for 32bit
2022-12-05 19:37 [PATCH mm-unstable v1 0/4] selftests/vm: fix some tests on 32bit David Hildenbrand
` (2 preceding siblings ...)
2022-12-05 19:37 ` [PATCH mm-unstable v1 3/4] selftests/vm: cow: fix compile warning on 32bit David Hildenbrand
@ 2022-12-05 19:37 ` David Hildenbrand
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-12-05 19:37 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, linux-kselftest, David Hildenbrand, Andrew Morton,
Shuah Khan, Yang Li
The test currently fails on 32bit. Fixing the "-1ull" vs. "-1ul" seems
to make the test pass and the compiler happy.
Note: This test is not in mm-stable yet. This fix should be squashed into
"selftests/vm: add KSM unmerge tests".
Signed-off-by: David Hildenbrand <david@redhat.com>
---
tools/testing/selftests/vm/ksm_functional_tests.c | 4 ++--
tools/testing/selftests/vm/vm_util.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/vm/ksm_functional_tests.c b/tools/testing/selftests/vm/ksm_functional_tests.c
index 96644be68962..b11b7e5115dc 100644
--- a/tools/testing/selftests/vm/ksm_functional_tests.c
+++ b/tools/testing/selftests/vm/ksm_functional_tests.c
@@ -42,13 +42,13 @@ static bool range_maps_duplicates(char *addr, unsigned long size)
for (offs_a = 0; offs_a < size; offs_a += pagesize) {
pfn_a = pagemap_get_pfn(pagemap_fd, addr + offs_a);
/* Page not present or PFN not exposed by the kernel. */
- if (pfn_a == -1ull || !pfn_a)
+ if (pfn_a == -1ul || !pfn_a)
continue;
for (offs_b = offs_a + pagesize; offs_b < size;
offs_b += pagesize) {
pfn_b = pagemap_get_pfn(pagemap_fd, addr + offs_b);
- if (pfn_b == -1ull || !pfn_b)
+ if (pfn_b == -1ul || !pfn_b)
continue;
if (pfn_a == pfn_b)
return true;
diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c
index 710571902743..40e795624ff3 100644
--- a/tools/testing/selftests/vm/vm_util.c
+++ b/tools/testing/selftests/vm/vm_util.c
@@ -50,7 +50,7 @@ unsigned long pagemap_get_pfn(int fd, char *start)
/* If present (63th bit), PFN is at bit 0 -- 54. */
if (entry & 0x8000000000000000ull)
return entry & 0x007fffffffffffffull;
- return -1ull;
+ return -1ul;
}
void clear_softdirty(void)
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-05 19:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 19:37 [PATCH mm-unstable v1 0/4] selftests/vm: fix some tests on 32bit David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 1/4] mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 2/4] selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE) definitions David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 3/4] selftests/vm: cow: fix compile warning on 32bit David Hildenbrand
2022-12-05 19:37 ` [PATCH mm-unstable v1 4/4] selftests/vm: ksm_functional_tests: fixes for 32bit David Hildenbrand
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).