mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
Replace qemu_real_host_page variables with inlined functions
Replace the global variables with inlined helper functions. getpagesize() is very likely annotated with a "const" function attribute (at least with glibc), and thus optimization should apply even better. This avoids the need for a constructor initialization too. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220323155743.1585078-12-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b307e5052d
commit
8e3b0cbb72
53 changed files with 150 additions and 162 deletions
|
@ -50,7 +50,7 @@ size_t qemu_fd_getpagesize(int fd)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
return qemu_real_host_page_size;
|
||||
return qemu_real_host_page_size();
|
||||
}
|
||||
|
||||
size_t qemu_mempath_getpagesize(const char *mem_path)
|
||||
|
@ -81,7 +81,7 @@ size_t qemu_mempath_getpagesize(const char *mem_path)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
return qemu_real_host_page_size;
|
||||
return qemu_real_host_page_size();
|
||||
}
|
||||
|
||||
#define OVERCOMMIT_MEMORY_PATH "/proc/sys/vm/overcommit_memory"
|
||||
|
@ -101,7 +101,7 @@ static bool map_noreserve_effective(int fd, uint32_t qemu_map_flags)
|
|||
* MAP_NORESERVE.
|
||||
* b) MAP_NORESERVE is not affected by /proc/sys/vm/overcommit_memory.
|
||||
*/
|
||||
if (qemu_fd_getpagesize(fd) != qemu_real_host_page_size) {
|
||||
if (qemu_fd_getpagesize(fd) != qemu_real_host_page_size()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void *mmap_reserve(size_t size, int fd)
|
|||
* We do this unless we are using the system page size, in which case
|
||||
* anonymous memory is OK.
|
||||
*/
|
||||
if (fd == -1 || qemu_fd_getpagesize(fd) == qemu_real_host_page_size) {
|
||||
if (fd == -1 || qemu_fd_getpagesize(fd) == qemu_real_host_page_size()) {
|
||||
fd = -1;
|
||||
flags |= MAP_ANONYMOUS;
|
||||
} else {
|
||||
|
@ -243,7 +243,7 @@ static inline size_t mmap_guard_pagesize(int fd)
|
|||
/* Mappings in the same segment must share the same page size */
|
||||
return qemu_fd_getpagesize(fd);
|
||||
#else
|
||||
return qemu_real_host_page_size;
|
||||
return qemu_real_host_page_size();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue