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>
This commit is contained in:
David Hildenbrand 2022-09-27 13:01:15 +02:00 committed by Andrew Morton
parent 69c66add56
commit a905e82ae4
3 changed files with 9 additions and 8 deletions

View File

@ -27,14 +27,6 @@
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;

View 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;

View 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);