bauerchen 037fb5eb39 mem-prealloc: optimize large guest startup
[desc]:
    Large memory VM starts slowly when using -mem-prealloc, and
    there are some areas to optimize in current method;

    1、mmap will be used to alloc threads stack during create page
    clearing threads, and it will attempt mm->mmap_sem for write
    lock, but clearing threads have hold read lock, this competition
    will cause threads createion very slow;

    2、methods of calcuating pages for per threads is not well;if we use
    64 threads to split 160 hugepage,63 threads clear 2page,1 thread
    clear 34 page,so the entire speed is very slow;

    to solve the first problem,we add a mutex in thread function,and
    start all threads when all threads finished createion;
    and the second problem, we spread remainder to other threads,in
    situation that 160 hugepage and 64 threads, there are 32 threads
    clear 3 pages,and 32 threads clear 2 pages.

[test]:
    320G 84c VM start time can be reduced to 10s
    680G 84c VM start time can be reduced to 18s

Signed-off-by: bauerchen <bauerchen@tencent.com>
Reviewed-by: Pan Rui <ruippan@tencent.com>
Reviewed-by: Ivan Ren <ivanren@tencent.com>
[Simplify computation of the number of pages per thread. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-02-25 09:18:01 +01:00
..
2018-09-25 15:50:15 +02:00
2020-02-22 08:26:47 +00:00
2018-10-02 18:47:55 +02:00
2020-01-06 18:41:32 +04:00
2019-08-16 13:31:52 +02:00
2020-02-19 11:17:40 +01:00
2019-09-11 08:46:17 +02:00
2020-01-02 16:29:32 +04:00
2019-12-18 08:36:15 +01:00
2016-02-04 17:01:04 +00:00
2018-12-20 10:29:08 +01:00
2019-12-17 19:33:52 +01:00
2018-08-24 20:26:37 +02:00
2018-06-29 12:32:10 +02:00