mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

There're already 3 same definitions of the three functions. Move it into vm_util.[ch]. Link: https://lkml.kernel.org/r/20230412164223.328134-1-peterx@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Axel Rasmussen <axelrasmussen@google.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org> Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Zach O'Keefe <zokeefe@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <sys/mman.h>
|
|
#include <err.h>
|
|
#include <string.h> /* ffsl() */
|
|
#include <unistd.h> /* _SC_PAGESIZE */
|
|
|
|
extern unsigned int __page_size;
|
|
extern unsigned int __page_shift;
|
|
|
|
static inline unsigned int psize(void)
|
|
{
|
|
if (!__page_size)
|
|
__page_size = sysconf(_SC_PAGESIZE);
|
|
return __page_size;
|
|
}
|
|
|
|
static inline unsigned int pshift(void)
|
|
{
|
|
if (!__page_shift)
|
|
__page_shift = (ffsl(psize()) - 1);
|
|
return __page_shift;
|
|
}
|
|
|
|
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);
|
|
unsigned long pagemap_get_pfn(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);
|
|
bool check_huge_anon(void *addr, int nr_hpages, uint64_t hpage_size);
|
|
bool check_huge_file(void *addr, int nr_hpages, uint64_t hpage_size);
|
|
bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size);
|
|
int64_t allocate_transhuge(void *ptr, int pagemap_fd);
|
|
unsigned long default_huge_page_size(void);
|
|
|
|
/*
|
|
* On ppc64 this will only work with radix 2M hugepage size
|
|
*/
|
|
#define HPAGE_SHIFT 21
|
|
#define HPAGE_SIZE (1 << HPAGE_SHIFT)
|
|
|
|
#define PAGEMAP_PRESENT(ent) (((ent) & (1ull << 63)) != 0)
|
|
#define PAGEMAP_PFN(ent) ((ent) & ((1ull << 55) - 1))
|