From: Sahil Chandna <sahilchandna@linux.microsoft.com>
To: Artem Matviychuk <asm@sysadmins.club>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Cc: "haiyangz@microsoft.com" <haiyangz@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
"decui@microsoft.com" <decui@microsoft.com>
Subject: Re: [BUG] hv_balloon: hot-add request larger than 64 GiB is truncated (page_cnt:24), host and guest memory accounting diverge by 64 GiB
Date: Thu, 26 Nov 2026 13:59:23 +0530 [thread overview]
Message-ID: <ed8b8d34-debf-4f8a-b026-0e049eede19e@linux.microsoft.com> (raw)
In-Reply-To: <5c4f93c2d38443348ef29b57547c10c0@sysadmins.club>
On 21-11-2026 14:56, Artem Matviychuk wrote:
> Hello,
>
> On a Linux guest with Dynamic Memory, a single hot-add request larger
> than 64 GiB seems to be truncated to its low 24 bits of page count.
> The host then accounts for memory the guest never added, and later
> balloons the guest far below its configured minimum.
>
> Setup
> Host: Windows Server 2022, build 10.0.20348.5756
> Guest: Debian 13, kernel 6.12.113+deb13-amd64, Generation 2 VM, 32 vCPUs
> VM memory: startup 32768 MB, minimum 32768 MB, maximum 131072 MB,
> buffer 20%, Dynamic Memory enabled
> hv_balloon: protocol version 2.0, hot_add=Y, auto_online_blocks=online,
> memory block size 128 MB
>
> What happens
> The guest commits about 105 GiB (Committed_AS) shortly after boot.
> About 50 seconds after boot the host grows the VM to its maximum.
>
> Guest log:
> Memory: 32514644K/33553344K available
> hv_vmbus: hv_mmio=[mem 0xf8000000-0xfed3ffff],[mem 0xfe0000000-0xfffffffff]
> [ 52.772118] hv_balloon: Max. dynamic memory size: 131072 MB
> No "hot_add memory failed" or "Memory hot add failed" messages.
>
> Host, same second (Hyper-V-Compute-Admin, event 10020):
> The dynamic memory balancer could not add memory to the virtual
> machine because its configured maximum has been reached
>
> Host view afterwards:
> Get-VM: MemoryAssigned 128 GiB
> Hyper-V Dynamic Memory VM counters:
> Memory Add Operations 2
> Added Memory 98526 MB
> Guest Visible Physical Memory 131072 MB
>
> Guest view afterwards:
> MemTotal 63.3 GiB, lsmem: 64G online, 0 offline
> 0x0000000000000000-0x00000000f7ffffff 3.9G
> 0x0000000100000000-0x0000000fdfffffff 59.5G
> 0x0000001000000000-0x0000001027ffffff 640M
> /sys/kernel/debug/hv-balloon:
> pages_added : 8388608 (32768 MB)
> pages_onlined : 8388608
> max_dynamic_page_count : 33554432
>
> Arithmetic
> Boot memory ends at 0x808000000. The high MMIO window starts at
> 0xfe0000000. If the host sends two hot-add requests,
> 1) 0x808000000-0xfdfffffff = 32128 MB
> 2) from 0x1000000000 upwards = 131072 - 32768 - 32128 = 66176 MB
> then request 2 is 16941056 pages, which does not fit into
> union dm_mem_page_range { struct { __u64 start_page:40;
> __u64 page_cnt:24; } finfo; ... }
> 16941056 mod 2^24 = 163840 pages = 640 MB, which is exactly the size
> of the range the guest added above the MMIO window, and
> 32128 + 640 = 32768 MB matches pages_added exactly.
> I did not capture the requests on the wire; the two sizes above are
> derived, not observed. The host counter shows 98526 MB added, which is
> 222 MB more than 131072 - 32768; I cannot explain that difference.
>
> Consequence
> The host believes the guest has 64 GiB more than it has. When the
> guest's committed memory dropped from about 107 GiB to 43 GiB, the host
> removed about 58 GiB by ballooning. The guest went from MemTotal
> 63.3 GiB to about 4-5 GiB within 10 minutes (minimum is 32768 MB) and
> stayed there, logging
> hv_balloon: Balloon request will be partially fulfilled. Balloon floor reached.
> every 5 minutes. The host reported pressure 73 and returned nothing:
> assigned 68.4 GiB, demand 50.6 GiB by its accounting. At that point:
> pages_ballooned 15634328 (59.6 GiB), MemTotal 3.9 GiB.
> This happened twice, each time after a sharp drop of Committed_AS.
>
> Control
> Another VM on the same host with the same kernel, startup 32768 MB and
> maximum 49152 MB shows no discrepancy: assigned 48 GiB, 48G online.
>
> Questions
> 1. Is page_cnt:24 the actual wire format, so that the host must not
> send a range above 2^24 - 1 pages, or does the host encode larger
> ranges differently?
> 2. The guest reports resp.page_count for what it added. The host seems
> to account the full request anyway. Is that expected?
>
> The page_cnt:24 field is the same in v6.12 and in current mainline.
> As a workaround I plan to lower the VM maximum so that no single
> hot-add range can exceed 64 GiB.
>
> I can provide full dmesg, the debugfs output and host counters, and I
> can test patches on this configuration.
>
> Thanks,
> Artem Matviichuk
Thanks Artem for reporting this issue, the numbers reported above look
correct and there is an overflow happening with page count for hot_add >
64GB as mentioned in your analysis.
I am checking on this internally and will update.
Thanks,
Sahil
prev parent reply other threads:[~2026-11-26 8:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 9:26 [BUG] hv_balloon: hot-add request larger than 64 GiB is truncated (page_cnt:24), host and guest memory accounting diverge by 64 GiB Artem Matviychuk
2026-11-26 8:29 ` Sahil Chandna [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed8b8d34-debf-4f8a-b026-0e049eede19e@linux.microsoft.com \
--to=sahilchandna@linux.microsoft.com \
--cc=asm@sysadmins.club \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox