* [PATCH v3 1/4] os: add an ability to lock memory on_fault
2024-12-11 23:04 [PATCH v3 0/4] overcommit: introduce mem-lock-onfault Daniil Tatianin
@ 2024-12-11 23:04 ` Daniil Tatianin
2024-12-11 23:04 ` [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper Daniil Tatianin
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Daniil Tatianin @ 2024-12-11 23:04 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Daniil Tatianin, Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel,
Vladimir Sementsov-Ogievskiy
This will be used in the following commits to make it possible to only
lock memory on fault instead of right away.
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>
---
include/sysemu/os-posix.h | 2 +-
include/sysemu/os-win32.h | 3 ++-
migration/postcopy-ram.c | 2 +-
os-posix.c | 10 ++++++++--
system/vl.c | 2 +-
5 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index b881ac6c6f..ce5b3bccf8 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -53,7 +53,7 @@ bool os_set_runas(const char *user_id);
void os_set_chroot(const char *path);
void os_setup_limits(void);
void os_setup_post(void);
-int os_mlock(void);
+int os_mlock(bool on_fault);
/**
* qemu_alloc_stack:
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index b82a5d3ad9..cd61d69e10 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -123,8 +123,9 @@ static inline bool is_daemonized(void)
return false;
}
-static inline int os_mlock(void)
+static inline int os_mlock(bool on_fault)
{
+ (void)on_fault;
return -ENOSYS;
}
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index a535fd2e30..36ec6a3d75 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -652,7 +652,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
}
if (enable_mlock) {
- if (os_mlock() < 0) {
+ if (os_mlock(false) < 0) {
error_report("mlock: %s", strerror(errno));
/*
* It doesn't feel right to fail at this point, we have a valid
diff --git a/os-posix.c b/os-posix.c
index 43f9a43f3f..0948128134 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -327,18 +327,24 @@ void os_set_line_buffering(void)
setvbuf(stdout, NULL, _IOLBF, 0);
}
-int os_mlock(void)
+int os_mlock(bool on_fault)
{
#ifdef HAVE_MLOCKALL
int ret = 0;
+ int flags = MCL_CURRENT | MCL_FUTURE;
- ret = mlockall(MCL_CURRENT | MCL_FUTURE);
+ if (on_fault) {
+ flags |= MCL_ONFAULT;
+ }
+
+ ret = mlockall(flags);
if (ret < 0) {
error_report("mlockall: %s", strerror(errno));
}
return ret;
#else
+ (void)on_fault;
return -ENOSYS;
#endif
}
diff --git a/system/vl.c b/system/vl.c
index 54998fdbc7..03819a80ef 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -793,7 +793,7 @@ static QemuOptsList qemu_run_with_opts = {
static void realtime_init(void)
{
if (enable_mlock) {
- if (os_mlock() < 0) {
+ if (os_mlock(false) < 0) {
error_report("locking memory failed");
exit(1);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper
2024-12-11 23:04 [PATCH v3 0/4] overcommit: introduce mem-lock-onfault Daniil Tatianin
2024-12-11 23:04 ` [PATCH v3 1/4] os: add an ability to lock memory on_fault Daniil Tatianin
@ 2024-12-11 23:04 ` Daniil Tatianin
2024-12-12 14:44 ` Vladimir Sementsov-Ogievskiy
2024-12-12 16:17 ` Peter Xu
2024-12-11 23:04 ` [PATCH v3 3/4] sysemu: introduce a new MlockState enum Daniil Tatianin
2024-12-11 23:04 ` [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault Daniil Tatianin
3 siblings, 2 replies; 14+ messages in thread
From: Daniil Tatianin @ 2024-12-11 23:04 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Daniil Tatianin, Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel
This will be extended in the future commits, let's move it out of line
right away so that it's easier to read.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
system/vl.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/system/vl.c b/system/vl.c
index 03819a80ef..f0b3ad0df7 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1855,6 +1855,19 @@ static void object_option_parse(const char *str)
visit_free(v);
}
+static void overcommit_parse(const char *str)
+{
+ QemuOpts *opts;
+
+ opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
+ str, false);
+ if (!opts) {
+ exit(1);
+ }
+ enable_mlock = qemu_opt_get_bool(opts, "mem-lock", enable_mlock);
+ enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", enable_cpu_pm);
+}
+
/*
* Very early object creation, before the sandbox options have been activated.
*/
@@ -3532,13 +3545,7 @@ void qemu_init(int argc, char **argv)
object_option_parse(optarg);
break;
case QEMU_OPTION_overcommit:
- opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
- optarg, false);
- if (!opts) {
- exit(1);
- }
- enable_mlock = qemu_opt_get_bool(opts, "mem-lock", enable_mlock);
- enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", enable_cpu_pm);
+ overcommit_parse(optarg);
break;
case QEMU_OPTION_compat:
{
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper
2024-12-11 23:04 ` [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper Daniil Tatianin
@ 2024-12-12 14:44 ` Vladimir Sementsov-Ogievskiy
2024-12-12 16:17 ` Peter Xu
1 sibling, 0 replies; 14+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-12-12 14:44 UTC (permalink / raw)
To: Daniil Tatianin, Paolo Bonzini
Cc: Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel
On 12.12.24 02:04, Daniil Tatianin wrote:
> This will be extended in the future commits, let's move it out of line
> right away so that it's easier to read.
>
> Signed-off-by: Daniil Tatianin<d-tatianin@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper
2024-12-11 23:04 ` [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper Daniil Tatianin
2024-12-12 14:44 ` Vladimir Sementsov-Ogievskiy
@ 2024-12-12 16:17 ` Peter Xu
1 sibling, 0 replies; 14+ messages in thread
From: Peter Xu @ 2024-12-12 16:17 UTC (permalink / raw)
To: Daniil Tatianin; +Cc: Paolo Bonzini, Stefan Weil, Fabiano Rosas, qemu-devel
On Thu, Dec 12, 2024 at 02:04:31AM +0300, Daniil Tatianin wrote:
> This will be extended in the future commits, let's move it out of line
> right away so that it's easier to read.
>
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 3/4] sysemu: introduce a new MlockState enum
2024-12-11 23:04 [PATCH v3 0/4] overcommit: introduce mem-lock-onfault Daniil Tatianin
2024-12-11 23:04 ` [PATCH v3 1/4] os: add an ability to lock memory on_fault Daniil Tatianin
2024-12-11 23:04 ` [PATCH v3 2/4] system/vl: extract overcommit option parsing into a helper Daniil Tatianin
@ 2024-12-11 23:04 ` Daniil Tatianin
2024-12-12 16:19 ` Peter Xu
2024-12-12 16:56 ` Vladimir Sementsov-Ogievskiy
2024-12-11 23:04 ` [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault Daniil Tatianin
3 siblings, 2 replies; 14+ messages in thread
From: Daniil Tatianin @ 2024-12-11 23:04 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Daniil Tatianin, Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel
Replace the boolean value enable_mlock with an enum and add a helper to
decide whether we should be calling os_mlock.
This is a stepping stone towards introducing a new mlock mode, which
will be the third possible state of this enum.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
hw/virtio/virtio-mem.c | 2 +-
include/sysemu/sysemu.h | 10 +++++++++-
migration/postcopy-ram.c | 2 +-
system/globals.c | 7 ++++++-
system/vl.c | 9 +++++++--
5 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index 80ada89551..78d27eb141 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -988,7 +988,7 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
return;
}
- if (enable_mlock) {
+ if (should_mlock(mlock_state)) {
error_setg(errp, "Incompatible with mlock");
return;
}
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 7ec419ce13..f1c9895057 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -43,10 +43,18 @@ extern int display_opengl;
extern const char *keyboard_layout;
extern int old_param;
extern uint8_t *boot_splash_filedata;
-extern bool enable_mlock;
extern bool enable_cpu_pm;
extern QEMUClockType rtc_clock;
+typedef enum {
+ MLOCK_OFF = 0,
+ MLOCK_ON,
+} MlockState;
+
+bool should_mlock(MlockState);
+
+extern MlockState mlock_state;
+
#define MAX_OPTION_ROMS 16
typedef struct QEMUOptionRom {
const char *name;
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 36ec6a3d75..a6a26a9cbb 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -651,7 +651,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
mis->have_fault_thread = false;
}
- if (enable_mlock) {
+ if (should_mlock(mlock_state)) {
if (os_mlock(false) < 0) {
error_report("mlock: %s", strerror(errno));
/*
diff --git a/system/globals.c b/system/globals.c
index 84ce943ac9..c6452d4a0d 100644
--- a/system/globals.c
+++ b/system/globals.c
@@ -31,10 +31,15 @@
#include "sysemu/cpus.h"
#include "sysemu/sysemu.h"
+bool should_mlock(MlockState state)
+{
+ return state == MLOCK_ON;
+}
+
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
int display_opengl;
const char* keyboard_layout;
-bool enable_mlock;
+MlockState mlock_state;
bool enable_cpu_pm;
int autostart = 1;
int vga_interface_type = VGA_NONE;
diff --git a/system/vl.c b/system/vl.c
index f0b3ad0df7..a41306ac84 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -792,7 +792,7 @@ static QemuOptsList qemu_run_with_opts = {
static void realtime_init(void)
{
- if (enable_mlock) {
+ if (should_mlock(mlock_state)) {
if (os_mlock(false) < 0) {
error_report("locking memory failed");
exit(1);
@@ -1858,13 +1858,18 @@ static void object_option_parse(const char *str)
static void overcommit_parse(const char *str)
{
QemuOpts *opts;
+ bool enable_mlock;
opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
str, false);
if (!opts) {
exit(1);
}
- enable_mlock = qemu_opt_get_bool(opts, "mem-lock", enable_mlock);
+
+ enable_mlock = qemu_opt_get_bool(opts, "mem-lock",
+ should_mlock(mlock_state));
+ mlock_state = enable_mlock ? MLOCK_ON : MLOCK_OFF;
+
enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", enable_cpu_pm);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 3/4] sysemu: introduce a new MlockState enum
2024-12-11 23:04 ` [PATCH v3 3/4] sysemu: introduce a new MlockState enum Daniil Tatianin
@ 2024-12-12 16:19 ` Peter Xu
2024-12-12 16:56 ` Vladimir Sementsov-Ogievskiy
1 sibling, 0 replies; 14+ messages in thread
From: Peter Xu @ 2024-12-12 16:19 UTC (permalink / raw)
To: Daniil Tatianin; +Cc: Paolo Bonzini, Stefan Weil, Fabiano Rosas, qemu-devel
On Thu, Dec 12, 2024 at 02:04:32AM +0300, Daniil Tatianin wrote:
> Replace the boolean value enable_mlock with an enum and add a helper to
> decide whether we should be calling os_mlock.
>
> This is a stepping stone towards introducing a new mlock mode, which
> will be the third possible state of this enum.
>
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/4] sysemu: introduce a new MlockState enum
2024-12-11 23:04 ` [PATCH v3 3/4] sysemu: introduce a new MlockState enum Daniil Tatianin
2024-12-12 16:19 ` Peter Xu
@ 2024-12-12 16:56 ` Vladimir Sementsov-Ogievskiy
1 sibling, 0 replies; 14+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-12-12 16:56 UTC (permalink / raw)
To: Daniil Tatianin, Paolo Bonzini
Cc: Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel
On 12.12.24 02:04, Daniil Tatianin wrote:
> Replace the boolean value enable_mlock with an enum and add a helper to
> decide whether we should be calling os_mlock.
>
> This is a stepping stone towards introducing a new mlock mode, which
> will be the third possible state of this enum.
>
> Signed-off-by: Daniil Tatianin<d-tatianin@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault
2024-12-11 23:04 [PATCH v3 0/4] overcommit: introduce mem-lock-onfault Daniil Tatianin
` (2 preceding siblings ...)
2024-12-11 23:04 ` [PATCH v3 3/4] sysemu: introduce a new MlockState enum Daniil Tatianin
@ 2024-12-11 23:04 ` Daniil Tatianin
2024-12-12 16:20 ` Peter Xu
2024-12-12 17:01 ` Vladimir Sementsov-Ogievskiy
3 siblings, 2 replies; 14+ messages in thread
From: Daniil Tatianin @ 2024-12-11 23:04 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Daniil Tatianin, Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel
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.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
include/sysemu/sysemu.h | 2 ++
migration/postcopy-ram.c | 2 +-
qemu-options.hx | 14 +++++++++-----
system/globals.c | 7 ++++++-
system/vl.c | 34 +++++++++++++++++++++++++++-------
5 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index f1c9895057..9834038e8a 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -49,9 +49,11 @@ extern QEMUClockType rtc_clock;
typedef enum {
MLOCK_OFF = 0,
MLOCK_ON,
+ MLOCK_ON_FAULT,
} MlockState;
bool should_mlock(MlockState);
+bool is_mlock_on_fault(MlockState);
extern MlockState mlock_state;
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index a6a26a9cbb..fe396b8ff3 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -652,7 +652,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
}
if (should_mlock(mlock_state)) {
- if (os_mlock(false) < 0) {
+ if (os_mlock(is_mlock_on_fault(mlock_state)) < 0) {
error_report("mlock: %s", strerror(errno));
/*
* It doesn't feel right to fail at this point, we have a valid
diff --git a/qemu-options.hx b/qemu-options.hx
index dacc9790a4..6c8360e62e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4566,21 +4566,25 @@ SRST
ERST
DEF("overcommit", HAS_ARG, QEMU_OPTION_overcommit,
- "-overcommit [mem-lock=on|off][cpu-pm=on|off]\n"
+ "-overcommit [mem-lock=on|off|on-fault][cpu-pm=on|off]\n"
" run qemu with overcommit hints\n"
- " mem-lock=on|off controls memory lock support (default: off)\n"
+ " mem-lock=on|off|on-fault controls memory lock support (default: off)\n"
" cpu-pm=on|off controls cpu power management (default: off)\n",
QEMU_ARCH_ALL)
SRST
-``-overcommit mem-lock=on|off``
+``-overcommit mem-lock=on|off|on-fault``
\
``-overcommit cpu-pm=on|off``
Run qemu with hints about host resource overcommit. The default is
to assume that host overcommits all resources.
Locking qemu and guest memory can be enabled via ``mem-lock=on``
- (disabled by default). This works when host memory is not
- overcommitted and reduces the worst-case latency for guest.
+ or ``mem-lock=on-fault`` (disabled by default). This works when
+ host memory is not overcommitted and reduces the worst-case latency for
+ guest. The on-fault option is better for reducing the memory footprint
+ since it makes allocations lazy, but the pages still get locked in place
+ once faulted by the guest or QEMU. Note that the two options are mutually
+ exclusive.
Guest ability to manage power state of host cpus (increasing latency
for other processes on the same host cpu, but decreasing latency for
diff --git a/system/globals.c b/system/globals.c
index c6452d4a0d..e04d6f57ec 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;
diff --git a/system/vl.c b/system/vl.c
index a41306ac84..b1fdb71a9e 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -347,7 +347,7 @@ static QemuOptsList qemu_overcommit_opts = {
.desc = {
{
.name = "mem-lock",
- .type = QEMU_OPT_BOOL,
+ .type = QEMU_OPT_STRING,
},
{
.name = "cpu-pm",
@@ -793,7 +793,7 @@ static QemuOptsList qemu_run_with_opts = {
static void realtime_init(void)
{
if (should_mlock(mlock_state)) {
- if (os_mlock(false) < 0) {
+ if (os_mlock(is_mlock_on_fault(mlock_state)) < 0) {
error_report("locking memory failed");
exit(1);
}
@@ -1858,7 +1858,7 @@ static void object_option_parse(const char *str)
static void overcommit_parse(const char *str)
{
QemuOpts *opts;
- bool enable_mlock;
+ const char *mem_lock_opt;
opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
str, false);
@@ -1866,11 +1866,31 @@ static void overcommit_parse(const char *str)
exit(1);
}
- enable_mlock = qemu_opt_get_bool(opts, "mem-lock",
- should_mlock(mlock_state));
- mlock_state = enable_mlock ? MLOCK_ON : MLOCK_OFF;
-
enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", enable_cpu_pm);
+
+ mem_lock_opt = qemu_opt_get(opts, "mem-lock");
+ if (!mem_lock_opt) {
+ return;
+ }
+
+ if (strcmp(mem_lock_opt, "on") == 0) {
+ mlock_state = MLOCK_ON;
+ return;
+ }
+
+ if (strcmp(mem_lock_opt, "off") == 0) {
+ mlock_state = MLOCK_OFF;
+ return;
+ }
+
+ if (strcmp(mem_lock_opt, "on-fault") == 0) {
+ mlock_state = MLOCK_ON_FAULT;
+ return;
+ }
+
+ error_report("parameter 'mem-lock' expects one of "
+ "'on', 'off', 'on-fault'");
+ exit(1);
}
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault
2024-12-11 23:04 ` [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault Daniil Tatianin
@ 2024-12-12 16:20 ` Peter Xu
2025-01-09 8:47 ` Daniil Tatianin
2024-12-12 17:01 ` Vladimir Sementsov-Ogievskiy
1 sibling, 1 reply; 14+ messages in thread
From: Peter Xu @ 2024-12-12 16:20 UTC (permalink / raw)
To: Daniil Tatianin; +Cc: Paolo Bonzini, Stefan Weil, Fabiano Rosas, qemu-devel
On Thu, Dec 12, 2024 at 02:04:33AM +0300, Daniil Tatianin wrote:
> 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.
>
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault
2024-12-12 16:20 ` Peter Xu
@ 2025-01-09 8:47 ` Daniil Tatianin
2025-01-09 14:18 ` Peter Xu
0 siblings, 1 reply; 14+ messages in thread
From: Daniil Tatianin @ 2025-01-09 8:47 UTC (permalink / raw)
To: Peter Xu; +Cc: Paolo Bonzini, Stefan Weil, Fabiano Rosas, qemu-devel
On 12/12/24 7:20 PM, Peter Xu wrote:
> On Thu, Dec 12, 2024 at 02:04:33AM +0300, Daniil Tatianin wrote:
>> 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.
>>
>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> Reviewed-by: Peter Xu <peterx@redhat.com>
Hi there! This series has 2 reviewed-bys, is there any way you could
queue it?
Thanks!
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault
2025-01-09 8:47 ` Daniil Tatianin
@ 2025-01-09 14:18 ` Peter Xu
2025-01-21 11:40 ` Daniil Tatianin
0 siblings, 1 reply; 14+ messages in thread
From: Peter Xu @ 2025-01-09 14:18 UTC (permalink / raw)
To: Daniil Tatianin, Paolo Bonzini, Philippe Mathieu-Daudé,
Peter Maydell
Cc: Paolo Bonzini, Stefan Weil, Fabiano Rosas, qemu-devel
On Thu, Jan 09, 2025 at 11:47:40AM +0300, Daniil Tatianin wrote:
> On 12/12/24 7:20 PM, Peter Xu wrote:
>
> > On Thu, Dec 12, 2024 at 02:04:33AM +0300, Daniil Tatianin wrote:
> > > 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.
> > >
> > > Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> > Reviewed-by: Peter Xu <peterx@redhat.com>
>
> Hi there! This series has 2 reviewed-bys, is there any way you could queue
> it?
I think this part belongs to mainloop/posix.. so maybe Paolo?
Also copied Phil and Peter Maydell.
--
Peter Xu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault
2025-01-09 14:18 ` Peter Xu
@ 2025-01-21 11:40 ` Daniil Tatianin
0 siblings, 0 replies; 14+ messages in thread
From: Daniil Tatianin @ 2025-01-21 11:40 UTC (permalink / raw)
To: Peter Xu, Paolo Bonzini, Philippe Mathieu-Daudé,
Peter Maydell
Cc: Stefan Weil, Fabiano Rosas, qemu-devel
On 1/9/25 5:18 PM, Peter Xu wrote:
> On Thu, Jan 09, 2025 at 11:47:40AM +0300, Daniil Tatianin wrote:
>> On 12/12/24 7:20 PM, Peter Xu wrote:
>>
>>> On Thu, Dec 12, 2024 at 02:04:33AM +0300, Daniil Tatianin wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
>>> Reviewed-by: Peter Xu <peterx@redhat.com>
>> Hi there! This series has 2 reviewed-bys, is there any way you could queue
>> it?
> I think this part belongs to mainloop/posix.. so maybe Paolo?
>
> Also copied Phil and Peter Maydell.
>
Ping :)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault
2024-12-11 23:04 ` [PATCH v3 4/4] overcommit: introduce mem-lock=on-fault Daniil Tatianin
2024-12-12 16:20 ` Peter Xu
@ 2024-12-12 17:01 ` Vladimir Sementsov-Ogievskiy
1 sibling, 0 replies; 14+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-12-12 17:01 UTC (permalink / raw)
To: Daniil Tatianin, Paolo Bonzini
Cc: Stefan Weil, Peter Xu, Fabiano Rosas, qemu-devel
On 12.12.24 02:04, Daniil Tatianin wrote:
> 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.
>
> Signed-off-by: Daniil Tatianin<d-tatianin@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 14+ messages in thread