Since we can not know whether a libc implementation of getpagesize() calls syscalls -- potentially slow --, but we know the host page size won't change during runtime, we can cache its value.
Reported-by: Richard Henderson <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- util/osdep.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/osdep.c b/util/osdep.c index 44fad13dcc7..9b50d00dbda 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -616,5 +616,11 @@ int qemu_fdatasync(int fd) uintptr_t qemu_real_host_page_size(void) { - return getpagesize(); + static uintptr_t real_host_page_size; + + if (!real_host_page_size) { + real_host_page_size = getpagesize(); + } + + return real_host_page_size; } -- 2.51.0
