summary refs log tree commit diff stats
path: root/system/globals.c
diff options
context:
space:
mode:
authorDaniil Tatianin <d-tatianin@yandex-team.ru>2025-02-12 17:39:20 +0300
committerPeter Xu <peterx@redhat.com>2025-02-12 11:36:13 -0500
commit13057e064a3edae7abf9ca2c207cdf48b82c5aad (patch)
tree1e7c4af97ad7f9e543c651aea8601a71d2f2d99d /system/globals.c
parentcd2e472e54a49c13b0a728cdda7c10c50421e23d (diff)
downloadfocaccia-qemu-13057e064a3edae7abf9ca2c207cdf48b82c5aad.tar.gz
focaccia-qemu-13057e064a3edae7abf9ca2c207cdf48b82c5aad.zip
overcommit: introduce mem-lock=on-fault
Locking the memory without MCL_ONFAULT instantly prefaults any mmaped
anonymous memory with a write-fault, which introduces a lot of extra
overhead in terms of memory usage when all you want to do is to prevent
kcompactd from migrating and compacting QEMU pages. Add an option to
only lock pages lazily as they're faulted by the process by using
MCL_ONFAULT if asked.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Link: https://lore.kernel.org/r/20250212143920.1269754-5-d-tatianin@yandex-team.ru
Signed-off-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'system/globals.c')
-rw-r--r--system/globals.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/system/globals.c b/system/globals.c
index adeff38348..316623bd20 100644
--- a/system/globals.c
+++ b/system/globals.c
@@ -33,7 +33,12 @@
 
 bool should_mlock(MlockState state)
 {
-    return state == MLOCK_ON;
+    return state == MLOCK_ON || state == MLOCK_ON_FAULT;
+}
+
+bool is_mlock_on_fault(MlockState state)
+{
+    return state == MLOCK_ON_FAULT;
 }
 
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;