selftests/vm: factor out pagemap_is_populated() into vm_util
authorDavid Hildenbrand <david@redhat.com>
Tue, 27 Sep 2022 11:01:15 +0000 (13:01 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 9 Nov 2022 01:37:14 +0000 (17:37 -0800)
We'll reuse it in the anon_cow test next.

Link: https://lkml.kernel.org/r/20220927110120.106906-3-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Christoph von Recklinghausen <crecklin@redhat.com>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nadav Amit <namit@vmware.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/vm/madv_populate.c
tools/testing/selftests/vm/vm_util.c
tools/testing/selftests/vm/vm_util.h

index 715a42e..6054724 100644 (file)
 
 static size_t pagesize;
 
-static bool pagemap_is_populated(int fd, char *start)
-{
-       uint64_t entry = pagemap_get_entry(fd, start);
-
-       /* Present or swapped. */
-       return entry & 0xc000000000000000ull;
-}
-
 static void sense_support(void)
 {
        char *addr;
index 37dd230..5bbf764 100644 (file)
@@ -35,6 +35,14 @@ bool pagemap_is_swapped(int fd, char *start)
        return entry & 0x4000000000000000ull;
 }
 
+bool pagemap_is_populated(int fd, char *start)
+{
+       uint64_t entry = pagemap_get_entry(fd, start);
+
+       /* Present or swapped. */
+       return entry & 0xc000000000000000ull;
+}
+
 void clear_softdirty(void)
 {
        int ret;
index 833df81..80d5a6a 100644 (file)
@@ -5,6 +5,7 @@
 uint64_t pagemap_get_entry(int fd, char *start);
 bool pagemap_is_softdirty(int fd, char *start);
 bool pagemap_is_swapped(int fd, char *start);
+bool pagemap_is_populated(int fd, char *start);
 void clear_softdirty(void);
 bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);
 uint64_t read_pmd_pagesize(void);