qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vl: Adjust the place of calling mlockall to speedup VM's startup
@ 2014-09-23 10:42 zhanghailiang
  2014-09-26  8:35 ` zhanghailiang
  0 siblings, 1 reply; 4+ messages in thread
From: zhanghailiang @ 2014-09-23 10:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: zhanghailiang, mst, hutao, luonengjun, peter.huangpeng, imammedo

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 <mst@redhat.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
 v2:
- Add Acked-by
- change 'int' to 'bool' (Thanks Hu Tao)
---
 vl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/vl.c b/vl.c
index dc792fe..35e5de6 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");
@@ -3973,7 +3970,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);
@@ -4441,6 +4438,8 @@ int main(int argc, char **argv, char **envp)
 
     machine_class->init(current_machine);
 
+    realtime_init();
+
     audio_init();
 
     cpu_synchronize_all_post_init();
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vl: Adjust the place of calling mlockall to speedup VM's startup
  2014-09-23 10:42 [Qemu-devel] [PATCH v2] vl: Adjust the place of calling mlockall to speedup VM's startup zhanghailiang
@ 2014-09-26  8:35 ` zhanghailiang
  2014-09-26 15:35   ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: zhanghailiang @ 2014-09-26  8:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: luonengjun, imammedo, hutao, peter.huangpeng, mst

Hi,

This has been reviewed, Will anyone pick this up?;)

Thanks,
zhanghailiang
On 2014/9/23 18:42, zhanghailiang wrote:
> 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 <mst@redhat.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>   v2:
> - Add Acked-by
> - change 'int' to 'bool' (Thanks Hu Tao)
> ---
>   vl.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index dc792fe..35e5de6 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");
> @@ -3973,7 +3970,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);
> @@ -4441,6 +4438,8 @@ int main(int argc, char **argv, char **envp)
>
>       machine_class->init(current_machine);
>
> +    realtime_init();
> +
>       audio_init();
>
>       cpu_synchronize_all_post_init();
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vl: Adjust the place of calling mlockall to speedup VM's startup
  2014-09-26  8:35 ` zhanghailiang
@ 2014-09-26 15:35   ` Paolo Bonzini
  2014-09-28  6:05     ` zhanghailiang
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2014-09-26 15:35 UTC (permalink / raw)
  To: zhanghailiang, qemu-devel
  Cc: imammedo, mst, luonengjun, peter.huangpeng, hutao

Il 26/09/2014 10:35, zhanghailiang ha scritto:
> Hi,
> 
> This has been reviewed, Will anyone pick this up?;)

I think mst will.  It's Jewish new year this week, so it will have to
wait for next week.

Paolo

> Thanks,
> zhanghailiang
> On 2014/9/23 18:42, zhanghailiang wrote:
>> 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 <mst@redhat.com>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> ---
>>   v2:
>> - Add Acked-by
>> - change 'int' to 'bool' (Thanks Hu Tao)
>> ---
>>   vl.c | 11 +++++------
>>   1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index dc792fe..35e5de6 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");
>> @@ -3973,7 +3970,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);
>> @@ -4441,6 +4438,8 @@ int main(int argc, char **argv, char **envp)
>>
>>       machine_class->init(current_machine);
>>
>> +    realtime_init();
>> +
>>       audio_init();
>>
>>       cpu_synchronize_all_post_init();
>>
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vl: Adjust the place of calling mlockall to speedup VM's startup
  2014-09-26 15:35   ` Paolo Bonzini
@ 2014-09-28  6:05     ` zhanghailiang
  0 siblings, 0 replies; 4+ messages in thread
From: zhanghailiang @ 2014-09-28  6:05 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel
  Cc: imammedo, mst, luonengjun, peter.huangpeng, hutao

On 2014/9/26 23:35, Paolo Bonzini wrote:
> Il 26/09/2014 10:35, zhanghailiang ha scritto:
>> Hi,
>>
>> This has been reviewed, Will anyone pick this up?;)
>
> I think mst will.  It's Jewish new year this week, so it will have to
> wait for next week.
>
OK, Thanks;)

Best Regard,
zhanghailiang
> Paolo
>
>> Thanks,
>> zhanghailiang
>> On 2014/9/23 18:42, zhanghailiang wrote:
>>> 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 <mst@redhat.com>
>>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>>> ---
>>>    v2:
>>> - Add Acked-by
>>> - change 'int' to 'bool' (Thanks Hu Tao)
>>> ---
>>>    vl.c | 11 +++++------
>>>    1 file changed, 5 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/vl.c b/vl.c
>>> index dc792fe..35e5de6 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");
>>> @@ -3973,7 +3970,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);
>>> @@ -4441,6 +4438,8 @@ int main(int argc, char **argv, char **envp)
>>>
>>>        machine_class->init(current_machine);
>>>
>>> +    realtime_init();
>>> +
>>>        audio_init();
>>>
>>>        cpu_synchronize_all_post_init();
>>>
>>
>>
>>
>>
>
>
> .
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-28  6:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-23 10:42 [Qemu-devel] [PATCH v2] vl: Adjust the place of calling mlockall to speedup VM's startup zhanghailiang
2014-09-26  8:35 ` zhanghailiang
2014-09-26 15:35   ` Paolo Bonzini
2014-09-28  6:05     ` zhanghailiang

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).