* [PATCH] qemu/osdep: Add huge page aligned support on LoongArch platform
@ 2024-01-15 7:32 Bibo Mao
2024-01-16 10:12 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Bibo Mao @ 2024-01-15 7:32 UTC (permalink / raw)
To: Song Gao; +Cc: qemu-devel
On LoongArch kvm mode if transparent huge page wants to be enabled, base
address and size of memslot from both HVA and GPA view. And LoongArch
supports both 4K and 16K page size with Linux kernel, so transparent huge
page size is calculated from real page size rather than hardcoded size.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
include/qemu/osdep.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 9a405bed89..c9692cc314 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -547,6 +547,14 @@ int madvise(char *, size_t, int);
# define QEMU_VMALLOC_ALIGN (256 * 4096)
#elif defined(__linux__) && defined(__sparc__)
# define QEMU_VMALLOC_ALIGN MAX(qemu_real_host_page_size(), SHMLBA)
+#elif defined(__linux__) && defined(__loongarch__)
+ /*
+ * For transparent hugepage optimization, it has better be huge page
+ * aligned. LoongArch host system supports two kinds of pagesize: 4K
+ * and 16K, here calculate huge page size from host page size
+ */
+# define QEMU_VMALLOC_ALIGN (qemu_real_host_page_size() * \
+ qemu_real_host_page_size() / sizeof(long))
#else
# define QEMU_VMALLOC_ALIGN qemu_real_host_page_size()
#endif
--
2.39.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] qemu/osdep: Add huge page aligned support on LoongArch platform
2024-01-15 7:32 [PATCH] qemu/osdep: Add huge page aligned support on LoongArch platform Bibo Mao
@ 2024-01-16 10:12 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2024-01-16 10:12 UTC (permalink / raw)
To: Bibo Mao; +Cc: Song Gao, qemu-devel
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-16 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 7:32 [PATCH] qemu/osdep: Add huge page aligned support on LoongArch platform Bibo Mao
2024-01-16 10:12 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).