On 2/23/2017 3:31 PM, Paolo Bonzini wrote: > > > On 23/02/2017 10:56, Jitendra Kolhe wrote: >> if (sigsetjmp(sigjump, 1)) { >> - error_setg(errp, "os_mem_prealloc: Insufficient free host memory " >> - "pages available to allocate guest RAM\n"); >> + memset_thread_failed = true; > > This sigsetjmp is not needed, no one can siglongjmp to it. > > The SIG_UNBLOCK/SIG_BLOCK in the main thread is not necessary, either. > >> } else { >> - int i; >> size_t hpagesize = qemu_fd_getpagesize(fd); >> size_t numpages = DIV_ROUND_UP(memory, hpagesize); >> >> - /* MAP_POPULATE silently ignores failures */ >> - for (i = 0; i < numpages; i++) { >> - memset(area + (hpagesize * i), 0, 1); >> - } >> + /* touch pages simultaneously */ >> + touch_all_pages(area, hpagesize, numpages, smp_cpus); > > ... and now touch_all_pages can just return memset_thread_failed, which > simplifies the code a bit. >
sure, will make change accordingly. - Jitendra > Paolo > >> + } >> + if (memset_thread_failed) { >> + error_setg(errp, "os_mem_prealloc: Insufficient free host memory " >> + "pages available to allocate guest RAM"); >> }