From: Alexandre DERUMIER Subject: Re: [BUG] Balloon malfunctions with memory hotplug Date: Sat, 28 Feb 2015 12:50:07 +0100 (CET) Message-ID: <1436002744.2482176.1425124207575.JavaMail.zimbra@oxygem.tv> References: <20150226142629.749f4f1f@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: pkrempa@redhat.com, zhang zhanghailiang , kvm , "Michael S. Tsirkin" , qemu-devel , amit shah , Igor Mammedov To: Luiz Capitulino Return-path: In-Reply-To: <260321994.2482175.1425124149538.JavaMail.zimbra@oxygem.tv> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org Hi,=20 I think they was already reported some month ago, and a patch was submitted to the mailing list (but waiting that memory unpl= ug was merged before apply it) http://lists.gnu.org/archive/html/qemu-devel/2014-11/msg02362.html ----- Mail original ----- De: "Luiz Capitulino" =C3=80: "qemu-devel" Cc: "kvm" , "Igor Mammedov" , "zh= ang zhanghailiang" , pkrempa@redhat.com, "E= ric Blake" , "Michael S. Tsirkin" , "ami= t shah" Envoy=C3=A9: Jeudi 26 F=C3=A9vrier 2015 20:26:29 Objet: [BUG] Balloon malfunctions with memory hotplug Hello,=20 Reproducer:=20 1. Start QEMU with balloon and memory hotplug support:=20 # qemu [...] -m 1G,slots=3D2,maxmem=3D2G -balloon virtio=20 2. Check balloon size:=20 (qemu) info balloon=20 balloon: actual=3D1024=20 (qemu)=20 3. Hotplug some memory:=20 (qemu) object_add memory-backend-ram,id=3Dmem1,size=3D1G=20 (qemu) device_add pc-dimm,id=3Ddimm1,memdev=3Dmem1=20 4. This is step is _not_ needed to reproduce the problem,=20 but you may need to online memory manually on Linux so=20 that it becomes available in the guest=20 5. Check balloon size again:=20 (qemu) info balloon=20 balloon: actual=3D1024=20 (qemu)=20 BUG: The guest now has 2GB of memory, but the balloon thinks=20 the guest has 1GB=20 One may think that the problem is that the balloon driver is=20 ignoring hotplugged memory. This is not what's happening. If=20 you do balloon your guest, there's nothing stopping the=20 balloon driver in the guest from ballooning hotplugged memory.=20 The problem is that the balloon device in QEMU needs to know=20 the current amount of memory available to the guest.=20 Before memory hotplug this information was easy to obtain: the=20 current amount of memory available to the guest is the memory the=20 guest was booted with. This value is stored in the ram_size global=20 variable in QEMU and this is what the balloon device emulation=20 code uses today. However, when memory is hotplugged ram_size is=20 _not_ updated and the balloon device breaks.=20 I see two possible solutions for this problem:=20 1. In addition to reading ram_size, the balloon device in QEMU=20 could scan pc-dimm devices to account for hotplugged memory.=20 This solution was already implemented by zhanghailiang:=20 http://lists.gnu.org/archive/html/qemu-devel/2014-11/msg02362.html=20 It works, except that on Linux memory hotplug is a two-step=20 procedure: first memory is inserted then it has to be onlined=20 from user-space. So, if memory is inserted but not onlined=20 this solution gives the opposite problem: the balloon device=20 will report a larger memory amount than the guest actually has.=20 Can we live with that? I guess not, but I'm open for discussion.=20 If QEMU could be notified when Linux makes memory online, then=20 the problem would be gone. But I guess this can't be done.=20 2. Modify the balloon driver in the guest to inform the balloon=20 device on the host about the current memory available to the=20 guest. This way, whenever the balloon device in QEMU needs=20 to know the current amount of memory in the guest, it asks=20 the guest. This drops any usage of ram_size in the balloon=20 device=20 I'm not completely sure this is feasible though. For example,=20 what happens if the guest reports a memory amount to QEMU and=20 right after this more memory is plugged?=20 Besides, this solution is more complex than solution 1 and=20 won't address older guests.=20 Another important detail is that, I *suspect* that a very similar=20 bug already exists with 32-bit guests even without memory=20 hotplug: what happens if you assign 6GB to a 32-bit without PAE=20 support? I think the same problem we're seeing with memory=20 hotplug will happen and solution 1 won't fix this, although=20 no one seems to care about 32-bit guests...=20 --=20 To unsubscribe from this list: send the line "unsubscribe kvm" in=20 the body of a message to majordomo@vger.kernel.org=20 More majordomo info at http://vger.kernel.org/majordomo-info.html=20