On 10/06/2017 15:54, ??6????A wrote: > Hello Qemu-devel, > > Recently I'm trying to study vm memory allocation on qemu-kvm environment. > I found some interesting here: > > I have create a 8GB(8388608 k) memory guest using Centos 7. but when I using > dmesg to show the init memory, > it was 9437184 k,around 9216MB. I would like to know the gap?
> I know qemu will init two memory region: > system_memory = g_malloc(sizeof(*system_memory)); > and system_io = g_malloc(sizeof(*system_io)); > > Does those gap point to the region of system_io ? No, these are two different address spaces. Guest RAM is allocated by memory_region_allocate_system_memory as a single region of the size you specified. The guest memory map doesn't place all the memory contiguously. For the "pc" machine type, from 3GB to 4GB there is a hole for memory mapped registers of PCI devices. Linux reports this hole as "absent" memory: [ 0.000000] Memory: 7372140k/9437184k available (6244k kernel code, 1049100k absent, 1015944k reserved, 4178k data, 1604k init) Note that Linux 3.11 or newer doesn't report absent pages anymore (commit 46a841329a6c, "mm/x86: prepare for removing num_physpages and simplify mem_init()", 2013-07-03). Thanks, Paolo