diff options
author | David Hildenbrand <david@redhat.com> | 2022-09-27 13:01:15 +0200 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2022-11-09 02:37:14 +0100 |
commit | a905e82ae44b22a25ea73415a3ec1228775eb9a9 (patch) | |
tree | 13206969ad236ef41a9ca5757b66a92a61923783 /tools/testing/selftests/vm/vm_util.c | |
parent | selftests/vm: anon_cow: test COW handling of anonymous memory (diff) | |
download | linux-a905e82ae44b22a25ea73415a3ec1228775eb9a9.tar.xz linux-a905e82ae44b22a25ea73415a3ec1228775eb9a9.zip |
selftests/vm: factor out pagemap_is_populated() into vm_util
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>
Diffstat (limited to 'tools/testing/selftests/vm/vm_util.c')
-rw-r--r-- | tools/testing/selftests/vm/vm_util.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c index 37dd230673ee..5bbf7641a0f0 100644 --- a/tools/testing/selftests/vm/vm_util.c +++ b/tools/testing/selftests/vm/vm_util.c @@ -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; |