virtio-balloon: proposal — free page reporting hold
Hi all,
I'd like to propose a new virtio-balloon feature bit and would appreciate feedback on the semantics and naming.
Problem: On Windows, there is no driver-visible free page list — free pages live on OS-internal lists, so a driver implementing free page reporting must allocate pages out (via the Windows kernel API MmAllocatePagesForMdlEx), report them, and then return them to the OS. Measurements show that returning the pages to the OS itself re-touches them, and each touch is a fresh page fault on the host, so the host-side reclaim effect collapses back immediately; report-then-release is therefore not workable on Windows. What does work is report-then-hold: keep the reported pages allocated inside the driver — where the guest cannot touch them — and only hand them back when the guest actually needs memory (low-memory conditions / rising demand), effectively an adaptive balloon driven by the reporting queue. Measurements on a 4 GB Windows guest: steady-state host RSS 1.65 GB with ~2.4 GB parked, full re-park within seconds after load drops. Note that in this scheme the driver alone decides how much to hold and when to hand pages back — the host never directs the hold; it only observes what is reported (and, with the optional stats tag below, how much is held). Why a new bit: Free Page Reporting in the current spec (virtio v1.4 cs01, section 5.5.6.7) says: "Reported free pages can be reused by the driver after the reporting request has been acknowledged without notifying the device", and the described flow assumes the driver eventually "put[s] them back to free page lists in the guest operating system". This wording is permissive — a driver that defers the reuse does not violate it — but it also says nothing about it: with a single negotiated feature, a driver that releases immediately and a driver that holds pages are indistinguishable to the host. A host that wants to treat reported memory as reclaimable for overcommit accounting cannot tell which behavior it got. A dedicated bit removes this ambiguity with zero migration cost: old drivers never accept it, so existing deployments stay unaffected in both directions.
Spec reference (section 5.5.6.7, unchanged since v1.2):
https://docs.oasis-open.org/virtio/virtio/v1.4/cs01/virtio-v1.4-cs01.html <https://docs.oasis-open.org/virtio/virtio/v1.4/cs01/virtio-v1.4-cs01.html >
Proposal:
- VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD (bit 6, name open for discussion): when negotiated, the driver MAY keep reported pages off the guest free lists after the acknowledgement, and only return them when the guest needs them.
- Device MUST NOT offer HOLD unless REPORTING is also offered; driver MUST NOT accept HOLD unless REPORTING is negotiated. Why the dependency: HOLD is not a standalone mechanism, it modifies what the driver may do with pages it has already reported — and reported pages only exist inside the reporting flow. Without REPORTING there is no reporting virtqueue and no reported pages, so there is nothing for the "hold" semantics to apply to. On the host side the bit is equally tied to REPORTING: the host reclaims the corresponding memory when a report arrives, so without REPORTING the bit would have no observable effect at all. Existing virtio practice has the same pattern of features that may only be negotiated together (e.g. VIRTIO_NET_F_MQ requires VIRTIO_NET_F_CTRL_VQ).
- Optional: a new tag in the stats virtqueue (e.g. held-pages) so the host can observe how much memory is currently held rather than reported-and-released.
Reference implementation: A small QEMU patch (uapi define + DEFINE_PROP_BIT("free-page-reporting-hold") + a realize-time dependency check) is attached, verified with the four offer combinations, including rejection of hold-without-reporting at startup. The guest side is a Windows reporting driver that allocates pages via MmAllocatePagesForMdlEx and parks the reported MDLs instead of returning them via MmFreePagesFromMdl right away; it negotiates REPORTING, ignores the unknown new bit, and the measurements above come from this driver.
Prior art: VIRTIO_BALLOON_F_DEFLATE_ON_OOM already uses negotiation to declare a driver-side policy the device does not participate in; this proposal follows the same pattern.
Thoughts on the semantics, the dependency direction, and the naming (alternatives: F_REPORTING_HOLD, F_PAGE_REPORTING_DEFERRED_REUSE) are very welcome.
Thanks,
JianMing
From 04b8d09081c1bc92e9eb4dcbd372c4439bde5206 Mon Sep 17 00:00:00 2001
From: Zhang JianMing <[email protected]>
Date: Mon, 17 Aug 2026 19:09:16 +0800
Subject: [PATCH RFC] virtio-balloon: add experimental free-page-reporting-hold
feature bit
Reference implementation for the proposed VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD feature bit, posted as an attachment to the virtio-comment discussion. Experimental, not for merge until the spec discussion settles the semantics and the final feature number.
The new bit tells the driver that it may keep reported pages off its free page lists after the host has acked the report, reusing them only when needed, instead of returning them to the free lists right away. On Windows guests the immediate return defeats reporting altogether:
the Windows memory manager touches every page it frees, so reported pages are instantly dirtied and reclaimed by the guest.
- new define in the standard headers copy (not the kernel uapi)
- "free-page-reporting-hold" property, default off
- realize-time check: hold requires free-page-reporting
No behavior change unless the property is explicitly enabled.
--- hw/virtio/virtio-balloon.c | 16 ++++++++++++++++ include/standard-headers/linux/virtio_balloon.h | 6 ++++++ 2 files changed, 22 insertions(+)
hw/virtio/virtio-balloon.c +16 -0
@@ -872,6 +872,14 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)VirtIOBalloon *s =VIRTIO_BALLOON (dev);int ret; +if (virtio_has_feature (s->host_features, +VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD ) && + !virtio_has_feature (s->host_features,VIRTIO_BALLOON_F_REPORTING )) { +error_setg (errp, +"'free-page-reporting-hold' requires 'free-page-reporting'" ); +return ; + } +virtio_init (vdev,VIRTIO_ID_BALLOON ,virtio_balloon_config_size (s)); ret = qemu_add_balloon_handler(virtio_balloon_to_target,
@@ -1050,6 +1058,14 @@ static const Property virtio_balloon_properties[] = { VIRTIO_BALLOON_F_PAGE_POISON, true),DEFINE_PROP_BIT ("free-page-reporting" , VirtIOBalloon, host_features,VIRTIO_BALLOON_F_REPORTING , false), +/* +* EXPERIMENTAL (pending virtio spec discussion): may only be enabled +* together with free-page-reporting. Tells the driver it is allowed to +* hold reported pages and only reuse them when needed, instead of +* returning them to the guest free page lists right away. +*/ +DEFINE_PROP_BIT ("free-page-reporting-hold" , VirtIOBalloon, host_features, + VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD, false),/* QEMU 4.0 accidentally changed the config size even when free-page-hint * is disabled, resulting in QEMU 3.1 migration incompatibility. This * property retains this quirk for QEMU 4.1 machine types.
include/standard-headers/linux/virtio_balloon.h +6 -0
@@ -37,6 +37,12 @@#define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3/* VQ to report free pages */ #define VIRTIO_BALLOON_F_PAGE_POISON 4/* Guest is using page poisoning */ #define VIRTIO_BALLOON_F_REPORTING 5/* Page reporting virtqueue */ +/* +* EXPERIMENTAL (pending virtio spec discussion, not yet in kernel uapi): +* driver may hold reported pages after ack instead of returning them to the +* guest free page lists right away, and only reuse them when needed. +*/ +#define VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD 6/* Size of a PFN in the balloon interface. */ #define VIRTIO_BALLOON_PFN_SHIFT 12
Signature · 1 line
2.43.0
RFC PATCH 1/1 balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
From: Zhang JianMing <[email protected]>
Define a new balloon feature bit which lets the driver announce that it will retain reported pages after the reporting request has been acknowledged, instead of returning them to the guest free page lists immediately, and reuse them only when needed.
The current text of the Free Page Reporting section already allows the driver to "reuse the reported free pages when needed" after acknowledgement, but the device cannot observe whether a given driver will return the pages immediately or keep them. The new bit makes this explicit and negotiated, in the same informational spirit as VIRTIO_BALLOON_F_PAGE_POISON. It adds no new driver obligation and requires no new device action.
Motivation: on guests whose memory manager touches every freed page (e.g. Windows), pages returned to the guest free lists immediately after a report are dirtied again within seconds, and the host-side benefit of the report is lost. Retaining reported pages inside the driver preserves it; measurements and a reference QEMU patch were posted to the virtio-comment list on 2026-08-17.
---
Hi all,
Following up on the proposal from 2026-08-17 ("virtio-balloon:
proposal - free page reporting hold") with a concrete spec change, now as a patch against the current master.
Additional notes beyond the commit message:
- Feature bit number: bit 6 is the next free bit in the current master. I am aware of the balloon DEVICE_INIT* series discussed on this list in April/May; if any of those lands first and takes bit 6, this patch should be renumbered accordingly; happy to rebase.
- Implementation status: a reference QEMU patch (property "free-page-reporting-hold", default off, requires free-page-reporting) was included with the original proposal. A Windows virtio-balloon driver prototype retains reported pages and releases them gradually under memory pressure.
Comments welcome, in particular on the bit number, the feature name, and whether the device normative statement is strong enough.
--- device-types/balloon/description.tex | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
device-types/balloon/description.tex +14 -0
@@ -48,6 +48,10 @@ guest memory statistics to the host. Configuration field \field{poison_val} is valid. \item[ VIRTIO_BALLOON_F_PAGE_REPORTING(5) ] The device has support for free page reporting. A virtqueue for reporting free guest memory is present. +\item[ VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD(6) ] A hint to the device, that + the driver will retain the reported pages after the reporting request + has been acknowledged, instead of returning them to the guest free page + lists immediately. The driver will reuse such pages only when needed. \end{description}
@@ -598,6 +602,11 @@ pages are reported is up to the driver. \end{enumerate} +If the VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD feature has been negotiated, +the driver may retain the reported pages after the reporting request has +been acknowledged, instead of returning them to the guest free page lists +immediately, and reuse them only when needed. + \drivernormative{\paragraph}{Free Page Reporting}{Device Types / Memory Balloon Device / Device Operation / Free Page Reporting} Normative statements in this section apply if the
@@ -629,6 +638,11 @@ If the VIRTIO_BALLOON_F_PAGE_POISON feature has not been negotiated, the device MAY modify the contents of any page supplied in a report request before acknowledging that request by using the reporting_vq descriptor. +If the VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD feature has been negotiated, +the device MUST NOT assume that a reported page is returned to the guest +free page lists at any particular time after the reporting request has been +acknowledged. + If the VIRTIO_BALLOON_F_PAGE_POISON feature has been negotiated, the device MUST NOT modify the the content of a reported page to a value other than \field{poison_val}.
Signature · 1 line
2.23.0.windows.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
回复:[PATCH RFC] balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
Quoted 2 lines · David Hildenbrand
This sounds like a driver policy / implementation detail. What exactly is a hypervisor/device supposed to do with that information?
Hi David,
Thanks for the review.
You are right that the current feature description is written from the
guest side only: it states what the driver does, but not what the
device/hypervisor can rely on.
At the device/hypervisor level, the answer is: nothing. Processing of a
report is unchanged -- the request is acknowledged and the corresponding
host memory is discarded, exactly as today. Even the way back is
standard: once the driver releases a held page, the first guest access
to it faults the memory back in through ordinary demand paging, with no
special action required.
What the information changes for the host depends on the type of guest.
For guests that do not touch free pages (Linux), reported pages stay
clean after they are returned, until they are reallocated. The
difference only exists for the other class of guests, whose memory
manager re-touches free pages (Windows being the typical example):
- If such a guest implemented free page reporting under the current
semantics -- returning pages to the free list after the report -- the
returned pages are re-touched immediately and everything faults back
in on the host side quickly; the report has effectively bought
nothing. Handing that memory to another guest or counting it as
available in placement decisions is accidental overselling.
- With HOLD, the reported pages are on no free list, so the guest
cannot reference them. Return is triggered only by real need: while
memory is plentiful nothing comes back, and under pressure pages come
back as needed. For the first time, the host can treat memory released
by such a guest the way it already treats pages reported by Linux and
balloon pages.
So the bit does not change what the balloon handler does; for this
class of guests, it turns a host-side release that is undone quickly
into one that holds until the guest actually needs the memory.
Thanks,
JianMing
------------------------------------------------------------------
发件人:David Hildenbrand (Arm) <[email protected]>
发送时间:2026年8月25日(周二) 22:24
收件人:zhangjianming<[email protected]>; "virtio-comment"<[email protected]>
抄 送:mst<[email protected]>; "alexander.duyck"<[email protected]>; cohuck<[email protected]>; yvugenfi<[email protected]> 主 题:Re: [PATCH RFC] balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
Quoted 55 lines · On 8/25/26 12:50, [email protected] wrote:
From: Zhang JianMing <[email protected]>
Define a new balloon feature bit which lets the driver announce that it will retain reported pages after the reporting request has been acknowledged, instead of returning them to the guest free page lists immediately, and reuse them only when needed.
The current text of the Free Page Reporting section already allows the driver to "reuse the reported free pages when needed" after acknowledgement, but the device cannot observe whether a given driver will return the pages immediately or keep them. The new bit makes this explicit and negotiated, in the same informational spirit as
VIRTIO_BALLOON_F_PAGE_POISON. It adds no new driver obligation and requires no new device action.Motivation: on guests whose memory manager touches every freed page (e.g. Windows), pages returned to the guest free lists immediately after a report are dirtied again within seconds, and the host-side benefit of the report is lost. Retaining reported pages inside the driver preserves it; measurements and a reference QEMU patch were posted to the virtio-comment list on 2026-08-17.
Signed-off-by Zhang JianMing <[email protected]>---
Hi all,Following up on the proposal from 2026-08-17 ("virtio-balloon:
proposal - free page reporting hold") with a concrete spec change, now as a patch against the current master.Additional notes beyond the commit message:
- Feature bit number: bit 6 is the next free bit in the current master. I am aware of the balloon DEVICE_INIT* series discussed on this list in April/May; if any of those lands first and takes bit 6, this patch should be renumbered accordingly; happy to rebase.
- Implementation status: a reference QEMU patch (property "free-page-reporting-hold", default off, requires free-page-reporting) was included with the original proposal. A Windows virtio-balloon driver prototype retains reported pages and releases them gradually under memory pressure.
Comments welcome, in particular on the bit number, the feature name, and whether the device normative statement is strong enough.
---
device-types/balloon/description.tex | 14 ++++++++++++++1 file changed, 14 insertions(+)device-types/balloon/description.tex +0
-0@@ -48,6 +48,10 @@ guest memory statistics to the host.
Quoted 7 lines
Configuration field \field{poison_val} is valid.
\item[VIRTIO_BALLOON_F_PAGE_REPORTING(5)] The device has support for free page reporting. A virtqueue for reporting free guest memory is present. +\item[VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD(6)] A hint to the device, that
+ the driver will retain the reported pages after the reporting request
+ has been acknowledged, instead of returning them to the guest free page
+ lists immediately. The driver will reuse such pages only when needed.
This sounds like a driver policy / implementation detail. What exactly is a hypervisor/device supposed to do with that information?
Signature · 2 lines
Cheers, David
A message that is not in the archive (sent off-list or not yet received): [email protected]
回复:回复:[PATCH RFC] balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
Quoted 6 lines · David Hildenbrand
This really sounds to me like just doing the right thing in OSes that blindly touch memory immediately after freeing the pages back to the OS. Consider it a bugfix in the guest OS driver to actually support free page reporting properly.
So I don't see a reason to define a feature flag for this behavior.
Hi David,
Agreed -- hold is simply the right way for a driver to implement free
page reporting on such guests, not a protocol capability.
The one thing we would like to confirm is whether the current text
permits this. Our reading: step 4 of the reporting sequence in section
5.5.6.7 says the driver "can reuse the reported free pages when
needed", and the "(e.g., by putting them back to free page lists...)"
that follows is merely an example; the driver normative section has no
requirement to return them. Under this reading, hold is already within
the current semantics.
If that reading is correct, we are happy to drop the feature bit and
simply implement this in the Windows driver -- a bugfix, as you put it.
One concern remains: the sequence names only one way of handling the
reported pages (putting them back to the free page lists), which reads
easily as the default behavior, and someone may raise the same
question later. If you think it is worthwhile, we could propose a
minimal text clarification -- adding "retaining them until they are
needed" as another example; if not, the text can stay as it is.
The original motivation for the bit was to make this behavioral
difference explicit at the protocol level; taking the bugfix route, the
difference can simply be left to each driver.
Thanks,
JianMing
------------------------------------------------------------------
发件人:David Hildenbrand (Arm) <[email protected]>
发送时间:2026年8月26日(周三) 15:42
收件人:zhangjianming<[email protected]>; "virtio-comment"<[email protected]>
抄 送:mst<[email protected]>; "alexander.duyck"<[email protected]>; cohuck<[email protected]>; yvugenfi<[email protected]> 主 题:Re: 回复:[PATCH RFC] balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
Quoted 5 lines · zhangjianming
Quoted 2 lines · David Hildenbrand
This sounds like a driver policy / implementation detail. What exactly is a hypervisor/device supposed to do with that information?
Hi David,
Hi,
Quoted 6 lines
Thanks for the review.
You are right that the current feature description is written from the guest side only: it states what the driver does, but not what the device/hypervisor can rely on.
Exactly. There is no value in the hypervisor knowing about that, really.
Quoted 28 lines
At the device/hypervisor level, the answer is: nothing. Processing of a report is unchanged -- the request is acknowledged and the corresponding host memory is discarded, exactly as today. Even the way back is
standard: once the driver releases a held page, the first guest access to it faults the memory back in through ordinary demand paging, with no special action required.What the information changes for the host depends on the type of guest. For guests that do not touch free pages (Linux), reported pages stay clean after they are returned, until they are reallocated. The difference only exists for the other class of guests, whose memory manager re-touches free pages (Windows being the typical example):
- If such a guest implemented free page reporting under the current semantics -- returning pages to the free list after the report -- the returned pages are re-touched immediately and everything faults back in on the host side quickly; the report has effectively bought nothing. Handing that memory to another guest or counting it as available in placement decisions is accidental overselling.
- With HOLD, the reported pages are on no free list, so the guest cannot reference them. Return is triggered only by real need: while memory is plentiful nothing comes back, and under pressure pages come back as needed. For the first time, the host can treat memory released by such a guest the way it already treats pages reported by Linux and balloon pages.
Quoted 3 lines
So the bit does not change what the balloon handler does; for this class of guests, it turns a host-side release that is undone quickly into one that holds until the guest actually needs the memory.
This really sounds to me like just doing the right thing in OSes that blindly touch memory immediately after freeing the pages back to the OS. Consider it a bugfix in the guest OS driver to actually support free page reporting properly.
So I don't see a reason to define a feature flag for this behavior.
Signature · 2 lines
Cheers, David
A message that is not in the archive (sent off-list or not yet received): [email protected]
回复:回复:回复:[PATCH RFC] balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
Quoted 4 lines · David Hildenbrand
That matches my understanding.
I'd only do that if that implementation option really matters. So far, it's hard for me to imagine why it would matter.
Hi David,
Understood -- we'll leave the text as it is, drop the feature bit, and
simply implement this in the Windows driver.
Thanks for confirming the reading.
Best regards,
JianMing
------------------------------------------------------------------
发件人:David Hildenbrand (Arm) <[email protected]>
发送时间:2026年8月26日(周三) 17:08
收件人:zhangjianming<[email protected]>; "virtio-comment"<[email protected]>
抄 送:mst<[email protected]>; "alexander.duyck"<[email protected]>; cohuck<[email protected]>; yvugenfi<[email protected]> 主 题:Re: 回复:回复:[PATCH RFC] balloon: add VIRTIO_BALLOON_F_PAGE_REPORTING_HOLD
Quoted 9 lines · zhangjianming
Quoted 6 lines · David Hildenbrand
This really sounds to me like just doing the right thing in OSes that blindly touch memory immediately after freeing the pages back to the OS. Consider it a bugfix in the guest OS driver to actually support free page reporting properly.
So I don't see a reason to define a feature flag for this behavior.
Hi David,
Hi,
Quoted 11 lines
Agreed -- hold is simply the right way for a driver to implement free page reporting on such guests, not a protocol capability.
The one thing we would like to confirm is whether the current text permits this. Our reading: step 4 of the reporting sequence in section 5.5.6.7 says the driver "can reuse the reported free pages when needed", and the "(e.g., by putting them back to free page lists...)" that follows is merely an example; the driver normative section has no requirement to return them. Under this reading, hold is already within the current semantics.
That matches my understanding.
Quoted 10 lines
If that reading is correct, we are happy to drop the feature bit and simply implement this in the Windows driver -- a bugfix, as you put it.
One concern remains: the sequence names only one way of handling the reported pages (putting them back to the free page lists), which reads easily as the default behavior, and someone may raise the same question later. If you think it is worthwhile, we could propose a minimal text clarification -- adding "retaining them until they are needed" as another example; if not, the text can stay as it is.
I'd only do that if that implementation option really matters. So far, it's hard for me to imagine why it would matter.
Signature · 2 lines
Cheers, David