mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -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
|
@ -397,7 +397,7 @@ static int vfio_dma_unmap_bitmap(VFIOContainer *container,
|
|||
{
|
||||
struct vfio_iommu_type1_dma_unmap *unmap;
|
||||
struct vfio_bitmap *bitmap;
|
||||
uint64_t pages = REAL_HOST_PAGE_ALIGN(size) / qemu_real_host_page_size;
|
||||
uint64_t pages = REAL_HOST_PAGE_ALIGN(size) / qemu_real_host_page_size();
|
||||
int ret;
|
||||
|
||||
unmap = g_malloc0(sizeof(*unmap) + sizeof(*bitmap));
|
||||
|
@ -414,7 +414,7 @@ static int vfio_dma_unmap_bitmap(VFIOContainer *container,
|
|||
* to qemu_real_host_page_size.
|
||||
*/
|
||||
|
||||
bitmap->pgsize = qemu_real_host_page_size;
|
||||
bitmap->pgsize = qemu_real_host_page_size();
|
||||
bitmap->size = ROUND_UP(pages, sizeof(__u64) * BITS_PER_BYTE) /
|
||||
BITS_PER_BYTE;
|
||||
|
||||
|
@ -882,8 +882,8 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|||
}
|
||||
|
||||
if (unlikely((section->offset_within_address_space &
|
||||
~qemu_real_host_page_mask) !=
|
||||
(section->offset_within_region & ~qemu_real_host_page_mask))) {
|
||||
~qemu_real_host_page_mask()) !=
|
||||
(section->offset_within_region & ~qemu_real_host_page_mask()))) {
|
||||
error_report("%s received unaligned region", __func__);
|
||||
return;
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|||
iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
||||
llend = int128_make64(section->offset_within_address_space);
|
||||
llend = int128_add(llend, section->size);
|
||||
llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
||||
llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask()));
|
||||
|
||||
if (int128_ge(int128_make64(iova), llend)) {
|
||||
if (memory_region_is_ram_device(section->mr)) {
|
||||
|
@ -899,7 +899,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
|
|||
memory_region_name(section->mr),
|
||||
section->offset_within_address_space,
|
||||
int128_getlo(section->size),
|
||||
qemu_real_host_page_size);
|
||||
qemu_real_host_page_size());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1118,8 +1118,8 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|||
}
|
||||
|
||||
if (unlikely((section->offset_within_address_space &
|
||||
~qemu_real_host_page_mask) !=
|
||||
(section->offset_within_region & ~qemu_real_host_page_mask))) {
|
||||
~qemu_real_host_page_mask()) !=
|
||||
(section->offset_within_region & ~qemu_real_host_page_mask()))) {
|
||||
error_report("%s received unaligned region", __func__);
|
||||
return;
|
||||
}
|
||||
|
@ -1150,7 +1150,7 @@ static void vfio_listener_region_del(MemoryListener *listener,
|
|||
iova = REAL_HOST_PAGE_ALIGN(section->offset_within_address_space);
|
||||
llend = int128_make64(section->offset_within_address_space);
|
||||
llend = int128_add(llend, section->size);
|
||||
llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask));
|
||||
llend = int128_and(llend, int128_exts64(qemu_real_host_page_mask()));
|
||||
|
||||
if (int128_ge(int128_make64(iova), llend)) {
|
||||
return;
|
||||
|
@ -1272,9 +1272,9 @@ static int vfio_get_dirty_bitmap(VFIOContainer *container, uint64_t iova,
|
|||
* qemu_real_host_page_size to mark those dirty. Hence set bitmap's pgsize
|
||||
* to qemu_real_host_page_size.
|
||||
*/
|
||||
range->bitmap.pgsize = qemu_real_host_page_size;
|
||||
range->bitmap.pgsize = qemu_real_host_page_size();
|
||||
|
||||
pages = REAL_HOST_PAGE_ALIGN(range->size) / qemu_real_host_page_size;
|
||||
pages = REAL_HOST_PAGE_ALIGN(range->size) / qemu_real_host_page_size();
|
||||
range->bitmap.size = ROUND_UP(pages, sizeof(__u64) * BITS_PER_BYTE) /
|
||||
BITS_PER_BYTE;
|
||||
range->bitmap.data = g_try_malloc0(range->bitmap.size);
|
||||
|
@ -1970,7 +1970,7 @@ static void vfio_get_iommu_info_migration(VFIOContainer *container,
|
|||
* cpu_physical_memory_set_dirty_lebitmap() supports pages in bitmap of
|
||||
* qemu_real_host_page_size to mark those dirty.
|
||||
*/
|
||||
if (cap_mig->pgsize_bitmap & qemu_real_host_page_size) {
|
||||
if (cap_mig->pgsize_bitmap & qemu_real_host_page_size()) {
|
||||
container->dirty_pages_supported = true;
|
||||
container->max_dirty_bitmap_size = cap_mig->max_dirty_bitmap_size;
|
||||
container->dirty_pgsizes = cap_mig->pgsize_bitmap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue