From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYtri-0000Pj-VO for qemu-devel@nongnu.org; Tue, 30 Sep 2014 05:37:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XYtrd-0000fH-TZ for qemu-devel@nongnu.org; Tue, 30 Sep 2014 05:37:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYtrd-0000eI-J0 for qemu-devel@nongnu.org; Tue, 30 Sep 2014 05:36:57 -0400 Date: Tue, 30 Sep 2014 12:40:14 +0300 From: "Michael S. Tsirkin" Message-ID: <1412069893-4717-6-git-send-email-mst@redhat.com> References: <1412069893-4717-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1412069893-4717-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 5/5] vl: Adjust the place of calling mlockall to speedup VM's startup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , zhanghailiang , Anthony Liguori From: zhanghailiang 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 --- vl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vl.c b/vl.c index dbdca59..9d2aaaf 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; @@ -1421,12 +1422,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"); @@ -3974,7 +3971,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); @@ -4442,6 +4439,8 @@ int main(int argc, char **argv, char **envp) machine_class->init(current_machine); + realtime_init(); + audio_init(); cpu_synchronize_all_post_init(); -- MST