From d769efba25a46751061f7159d19c24214c9310b3 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 17 Dec 2014 15:09:47 +0100 Subject: [PATCH 1/2] vl: Adjust the place of calling mlockall to speedup VM's startup Message-id: <1418828987-1909-1-git-send-email-ehabkost@redhat.com> Patchwork-id: 62956 O-Subject: [RHEV-7.1 qemu-kvm-rhev PATCH] vl: Adjust the place of calling mlockall to speedup VM's startup Bugzilla: 1173394 RH-Acked-by: Marcelo Tosatti RH-Acked-by: Luiz Capitulino RH-Acked-by: Igor Mammedov RH-Acked-by: Michael S. Tsirkin From: zhanghailiang [backport note: this won't just speed it up, but is necessary to make mbind() work when using hugetlbfs] If we configure mlock=on and memory policy=bind at the same time, It will consume lots of time for system to treat with memory, especially when call mbind behind mlockall. Adjust the place of calling mlockall, calling mbind before mlockall can remarkably reduce the time of VM's startup. Acked-by: Michael S. Tsirkin Signed-off-by: zhanghailiang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 28d16f38d0d5881f95b074cc802dae8cacc1bf58) Signed-off-by: Eduardo Habkost Signed-off-by: Miroslav Rezanina --- vl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vl.c b/vl.c index bfe543e..a304d7f0 100644 --- a/vl.c +++ b/vl.c @@ -134,6 +134,7 @@ const char* keyboard_layout = NULL; ram_addr_t ram_size; const char *mem_path = NULL; int mem_prealloc = 0; /* force preallocation of physical target memory */ +bool enable_mlock = false; int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart; @@ -1407,12 +1408,8 @@ static void smp_parse(QemuOpts *opts) } -static void configure_realtime(QemuOpts *opts) +static void realtime_init(void) { - bool enable_mlock; - - enable_mlock = qemu_opt_get_bool(opts, "mlock", true); - if (enable_mlock) { if (os_mlock() < 0) { fprintf(stderr, "qemu: locking memory failed\n"); @@ -4001,7 +3998,7 @@ int main(int argc, char **argv, char **envp) if (!opts) { exit(1); } - configure_realtime(opts); + enable_mlock = qemu_opt_get_bool(opts, "mlock", true); break; case QEMU_OPTION_msg: opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0); @@ -4472,6 +4469,8 @@ int main(int argc, char **argv, char **envp) machine_class->init(current_machine); + realtime_init(); + audio_init(); cpu_synchronize_all_post_init(); -- 1.8.3.1