From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zang Hongyong Subject: Re: [PATCH] kvm tools: Make the whole guest memory mergeable Date: Fri, 16 Dec 2011 17:33:19 +0800 Message-ID: <4EEB105F.9050307@huawei.com> References: <1323997263-2031-1-git-send-email-zanghongyong@huawei.com> <1324014621.4496.3.camel@lappy> <4EEAED0E.5050106@huawei.com> <1324020188.4496.17.camel@lappy> <4EEB031B.2020806@huawei.com> <1324025135.4496.31.camel@lappy> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7BIT Cc: kvm@vger.kernel.org, penberg@kernel.org, xiaowei.yang@huawei.com, hanweidong@huawei.com, wusongwei@huawei.com, kongbo@huawei.com To: Sasha Levin Return-path: Received: from szxga01-in.huawei.com ([119.145.14.64]:57574 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751233Ab1LPJeM (ORCPT ); Fri, 16 Dec 2011 04:34:12 -0500 Received: from huawei.com (szxga05-in [172.24.2.49]) by szxga05-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LWA008FLIKZ9V@szxga05-in.huawei.com> for kvm@vger.kernel.org; Fri, 16 Dec 2011 17:34:11 +0800 (CST) Received: from szxrg01-dlp.huawei.com ([172.24.2.119]) by szxga05-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LWA006Y5IKTAY@szxga05-in.huawei.com> for kvm@vger.kernel.org; Fri, 16 Dec 2011 17:34:11 +0800 (CST) In-reply-to: <1324025135.4496.31.camel@lappy> Sender: kvm-owner@vger.kernel.org List-ID: 于 2011/12/16,星期五 16:45, Sasha Levin 写道: > On Fri, 2011-12-16 at 16:36 +0800, Zang Hongyong wrote: >> 于 2011/12/16,星期五 15:23, Sasha Levin 写道: >>> On Fri, 2011-12-16 at 15:02 +0800, Zang Hongyong wrote: >>>> 于 2011/12/16,星期五 13:50, Sasha Levin 写道: >>>>> On Fri, 2011-12-16 at 09:01 +0800, zanghongyong@huawei.com wrote: >>>>>> If a guest's ram_size exceeds KVM_32BIT_GAP_START, the corresponding kvm tool's >>>>>> virtual address size should be (ram_size + KVM_32BIT_GAP_SIZE), rather than ram_size. >>>>> You're right. >>>>> >>>>> There are more places than just the madvise() code which make the same >>>>> error you've spotted (for example, the memslot allocation code), so >>>>> instead of trying to fix all of them I'd suggest to just update ram_size >>>>> in kvm__arch_init() before allocating everything - that should fix all >>>>> of them at once. >>>>> >>>> Yes. There are other scenarios with the same error. >>>> However ram_size sometimes means real guest ram size, and sometimes >>>> means virtual address >>>> size of kvm tool's user space. Shall we define a new variable? >>> Let's keep it simple. If the user requests more than RAM than >>> KVM_32BIT_GAP_START just increase it by KVM_32BIT_GAP_SIZE, this way >>> mapped size == guest size always (we can madvise(MADV_DONTNEED) the gap >>> in the mmapped ram). >>> >>> Since a user which requests more than KVM_32BIT_GAP_START will have to >>> be on 64bit host anyway, there shouldn't be any issue with that. >>> >> Do you mean increase *kvm->ram_size* by KVM_32BIT_GAP_SIZE? >> but sometimes kvm->ram_size stands for guest physical ram size (for >> example in kvm__init_ram() code). > Yup, kvm->ram_size. > > If the user requested more than KVM_32BIT_GAP_START, we pretty much have > to create the gap, so instead of playing around with different > interpretations of ram_size, lets add the gap size - this will let us > have just one ram_size. > > mmap()ing extra space for the gap is free, and that was the plan in the > first place (we just got the math wrong :) ). > > Do you see an issue with increasing kvm->ram_size? > Yes, it will cause some problems after simply increase the kvm->ram_size. For examples: In kvm__init_ram() code we use kvm->ram_size to calculate the size of the second RAM range from 4GB to the end of RAM (phys_size = kvm->ram_size - phys_size;), so after increase the kvm->ram_size, it will goes wrong. This problem also happens in e820_setup() code and load_bzimage() code.