Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp438599rdb; Thu, 5 Oct 2023 10:06:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0mUXbFllOLz/rkaidkAG5Az/EO82LHAFmWI8guppAu/gJ/y+JW0OgmWFo8y9RRafA4PjR X-Received: by 2002:a17:90a:8d01:b0:271:9c57:1c9a with SMTP id c1-20020a17090a8d0100b002719c571c9amr5796729pjo.21.1696525597920; Thu, 05 Oct 2023 10:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525597; cv=none; d=google.com; s=arc-20160816; b=oR4hMz9m6Oawdi6Q3QiBPCUUdGYNt3Tw0jIwOnsXihMqxzikZY1VB9f5hfMECAUNsa Q8dAnYK7Nd92qt0FwkxEEFHtGNq2zADmd+UxFAHzwTEkMegPNWg/NX7ZC40GhsuICFnJ 6YxysU+qmhr6NxLwEc1McaNii/ic3CqVemOXuZU6NlddhvaspkLuNMhau063TW4N8dvE 8CAlzQOvY93FXG0nexC3Rs5VnROn3Q1s6BZb5eNk/I3bjo3nDfKMCDwCavSOp95bUtLC CGzoTgDDlfeSYz7cJO5ahD3MeaFmGG1kc6gOJLpg3/zdpTir98mGp/9dtZ7Mgp9DHu/n 4NEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=ets5PYkEN00cN7wgOm2RwQsLcoaUgwsPfQGHKYG1F6g=; fh=C6wpuZU8qxAq2wB6UbozVpFtgaiwQ3zkwL2N1OZCq18=; b=Y9VZn86DZJxBHYh/EYnVVXBj6tzvqirjs23ioh51Kyd6nyzePXWv87d/QEwalTrUuK PlHt0Wgx57txtGyP6WbIm3WeeT8fZ69b62CNWGeIgsPST1EAH7578H31vSp1wFRj62j2 5y1TWIAy44TBOXzbbHX0MnhzYcgFWfdqb9TpwT76Ecj+nYKL6lJxLudkmN207sntISkG NBw2uEFf5KCyXrbcHCLgbkwKjJbOnIjdHXNTx/z8GKB05IkKwbLjwjc3bnoKjJgIgxfG Vrs4xAOhD7ZfF7ZOxCZgUfjdB0OXM4OPgdI2oe2faMNAlMgwM0pRbBpuNugcVJrQaAgc w6MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N0VUEXtr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bk10-20020a17090b080a00b00277374d74afsi4006265pjb.12.2023.10.05.10.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N0VUEXtr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E6139809FA50; Sun, 24 Sep 2023 17:28:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbjIXX7e (ORCPT + 99 others); Sun, 24 Sep 2023 19:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbjIXX7d (ORCPT ); Sun, 24 Sep 2023 19:59:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56463E8 for ; Sun, 24 Sep 2023 16:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695599925; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ets5PYkEN00cN7wgOm2RwQsLcoaUgwsPfQGHKYG1F6g=; b=N0VUEXtr0AZhVLjjPVU4v94tWsDLMCxSn9xIIhBXdJ7/NqmCwlWsmj2YTXiRhlyEEnAkHu AmvcR2WlJvH0Em3LdVZ7ZCXk6g9AII+NSce2r+WpQUiFGCQpI5BkOEWSjYuvkGsak32Puy 3pZ12SpE5wA6aAKMTMDveczR0tsm4LA= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-wLJ9tVN7O06TolqwfWoeIA-1; Sun, 24 Sep 2023 19:58:43 -0400 X-MC-Unique: wLJ9tVN7O06TolqwfWoeIA-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-2748327f37dso3715990a91.0 for ; Sun, 24 Sep 2023 16:58:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695599922; x=1696204722; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ets5PYkEN00cN7wgOm2RwQsLcoaUgwsPfQGHKYG1F6g=; b=Np5SkTWBKkeVUvBbD/UQI+tEK2zrdg/q/r/+JWt89hXLT+6VgDTn2zU4oVhuzIyxXj yQiiV0Au5Tur7U/DtOPEOT3th4SScFQSgc2tRi/TZRqK7Xhsch7ldXtBuRlKSaYBdiFG 8Xt+2G/rWeOTa85nS/QRbmZS/EWH2pn7cnuIFfZ0HiuRkLaP+fxsbUApAvRUoPsVC/Zx sXJYM/gyonoFUQEBg83C8f/dv/ccOCkJ1drc6x4+d35/ULLE984Jbe0sEUAGxDRd/I4V 34p1+Ykh5rhLgeWjp3sBthhUcv+P9GAor7LSSmf0xL5RBBrpj4Kgke3cfh4Pz14kThhI CQhw== X-Gm-Message-State: AOJu0YzshuflS5wbQSw1fBTNmxQS6a0a99RimlKSYjaflZlFn5tnuHI7 z0gUzftQAsofA2MBBkp9fkPcDWfyekokG6pSux8vMHbcsuJQ/nsTD8hZirYCp4ULB/r1iZVU1nf XTAv4p2QHRybMWG8COnxUKIRyMK6MzJyA X-Received: by 2002:a17:90a:2ca1:b0:26d:ae3:f6a6 with SMTP id n30-20020a17090a2ca100b0026d0ae3f6a6mr2819269pjd.18.1695599922199; Sun, 24 Sep 2023 16:58:42 -0700 (PDT) X-Received: by 2002:a17:90a:2ca1:b0:26d:ae3:f6a6 with SMTP id n30-20020a17090a2ca100b0026d0ae3f6a6mr2819265pjd.18.1695599921841; Sun, 24 Sep 2023 16:58:41 -0700 (PDT) Received: from ?IPV6:2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5? ([2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5]) by smtp.gmail.com with ESMTPSA id y9-20020a17090a16c900b002772faee740sm1216900pje.5.2023.09.24.16.58.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 24 Sep 2023 16:58:40 -0700 (PDT) Message-ID: <9efb4685-7c28-d51d-fd5b-aa2de8e5ded2@redhat.com> Date: Mon, 25 Sep 2023 09:58:35 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2] virtio_balloon: Fix endless deflation and inflation on arm64 Content-Language: en-US From: Gavin Shan To: virtualization@lists.linux-foundation.org Cc: xuanzhuo@linux.alibaba.com, mst@redhat.com, linux-kernel@vger.kernel.org, zhenyzha@redhat.com, shan.gavin@gmail.com, David Hildenbrand References: <20230831011007.1032822-1-gshan@redhat.com> In-Reply-To: <20230831011007.1032822-1-gshan@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 24 Sep 2023 17:28:04 -0700 (PDT) Hi David and Michael, On 8/31/23 11:10, Gavin Shan wrote: > The deflation request to the target, which isn't unaligned to the > guest page size causes endless deflation and inflation actions. For > example, we receive the flooding QMP events for the changes on memory > balloon's size after a deflation request to the unaligned target is > sent for the ARM64 guest, where we have 64KB base page size. > > /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ > -accel kvm -machine virt,gic-version=host -cpu host \ > -smp maxcpus=8,cpus=8,sockets=2,clusters=2,cores=2,threads=1 \ > -m 1024M,slots=16,maxmem=64G \ > -object memory-backend-ram,id=mem0,size=512M \ > -object memory-backend-ram,id=mem1,size=512M \ > -numa node,nodeid=0,memdev=mem0,cpus=0-3 \ > -numa node,nodeid=1,memdev=mem1,cpus=4-7 \ > : \ > -device virtio-balloon-pci,id=balloon0,bus=pcie.10 > > { "execute" : "balloon", "arguments": { "value" : 1073672192 } } > {"return": {}} > {"timestamp": {"seconds": 1693272173, "microseconds": 88667}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272174, "microseconds": 89704}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272175, "microseconds": 90819}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272176, "microseconds": 91961}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272177, "microseconds": 93040}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073676288}} > {"timestamp": {"seconds": 1693272178, "microseconds": 94117}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073676288}} > {"timestamp": {"seconds": 1693272179, "microseconds": 95337}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272180, "microseconds": 96615}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073676288}} > {"timestamp": {"seconds": 1693272181, "microseconds": 97626}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272182, "microseconds": 98693}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073676288}} > {"timestamp": {"seconds": 1693272183, "microseconds": 99698}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272184, "microseconds": 100727}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272185, "microseconds": 90430}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > {"timestamp": {"seconds": 1693272186, "microseconds": 102999}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073676288}} > : > > > Fix it by aligning the target up to the guest page size, 64KB in this > specific case. With this applied, no flooding QMP events are observed > and the memory balloon's size can be stablizied to 0x3ffe0000 soon > after the deflation request is sent. > > { "execute" : "balloon", "arguments": { "value" : 1073672192 } } > {"return": {}} > {"timestamp": {"seconds": 1693273328, "microseconds": 793075}, \ > "event": "BALLOON_CHANGE", "data": {"actual": 1073610752}} > { "execute" : "query-balloon" } > {"return": {"actual": 1073610752}} > > Signed-off-by: Gavin Shan > Tested-by: Zhenyu Zhang > --- > v2: Align @num_pages up to the guest page size in towards_target() > directly as David suggested. > --- > drivers/virtio/virtio_balloon.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > If the patch looks good, could you please merge this to Linux 6.6.rc4 since it's something needed by our downstream. I hope it can land upstream as early as possible, thanks a lot. > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 5b15936a5214..2d5d252ef419 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -395,7 +395,11 @@ static inline s64 towards_target(struct virtio_balloon *vb) > virtio_cread_le(vb->vdev, struct virtio_balloon_config, num_pages, > &num_pages); > > - target = num_pages; > + /* > + * Aligned up to guest page size to avoid inflating and deflating > + * balloon endlessly. > + */ > + target = ALIGN(num_pages, VIRTIO_BALLOON_PAGES_PER_PAGE); > return target - vb->num_pages; > } > Thanks, Gavin