[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/11] softmmu: Create qemu_target_pages_to_MiB()
From: |
Juan Quintela |
Subject: |
[PULL 02/11] softmmu: Create qemu_target_pages_to_MiB() |
Date: |
Mon, 15 May 2023 14:33:25 +0200 |
Function that convert a number of target_pages into its size in MiB.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20230511141208.17779-2-quintela@redhat.com>
---
include/exec/target_page.h | 1 +
softmmu/physmem.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/exec/target_page.h b/include/exec/target_page.h
index 96726c36a4..bbf37aea17 100644
--- a/include/exec/target_page.h
+++ b/include/exec/target_page.h
@@ -18,4 +18,5 @@ size_t qemu_target_page_size(void);
int qemu_target_page_bits(void);
int qemu_target_page_bits_min(void);
+size_t qemu_target_pages_to_MiB(size_t pages);
#endif
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 0e0182d9f2..efaed36773 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3357,6 +3357,17 @@ int qemu_target_page_bits_min(void)
return TARGET_PAGE_BITS_MIN;
}
+/* Convert target pages to MiB (2**20). */
+size_t qemu_target_pages_to_MiB(size_t pages)
+{
+ int page_bits = TARGET_PAGE_BITS;
+
+ /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
+ g_assert(page_bits < 20);
+
+ return pages >> (20 - page_bits);
+}
+
bool cpu_physical_memory_is_io(hwaddr phys_addr)
{
MemoryRegion*mr;
--
2.40.1
- [PULL 00/11] Migration 20230515 patches, Juan Quintela, 2023/05/15
- [PULL 01/11] migration/calc-dirty-rate: replaced CRC32 with xxHash, Juan Quintela, 2023/05/15
- [PULL 02/11] softmmu: Create qemu_target_pages_to_MiB(),
Juan Quintela <=
- [PULL 07/11] migration: A rate limit value of 0 is valid, Juan Quintela, 2023/05/15
- [PULL 11/11] qemu-file: Remove total from qemu_file_total_transferred_*(), Juan Quintela, 2023/05/15
- [PULL 09/11] qemu-file: make qemu_file_[sg]et_rate_limit() use an uint64_t, Juan Quintela, 2023/05/15
- [PULL 05/11] migration: Teach dirtyrate about qemu_target_page_bits(), Juan Quintela, 2023/05/15
- [PULL 06/11] migration: Make dirtyrate.c target independent, Juan Quintela, 2023/05/15
- [PULL 03/11] Use new created qemu_target_pages_to_MiB(), Juan Quintela, 2023/05/15
- [PULL 04/11] migration: Teach dirtyrate about qemu_target_page_size(), Juan Quintela, 2023/05/15
- [PULL 08/11] migration: We set the rate_limit by a second, Juan Quintela, 2023/05/15
- [PULL 10/11] qemu-file: Make rate_limit_used an uint64_t, Juan Quintela, 2023/05/15
- Re: [PULL 00/11] Migration 20230515 patches, Richard Henderson, 2023/05/15