Skip to content

Unclear/contradictory requirements for Traditional Mem Balloon #228

@hcsch

Description

@hcsch

While implementing a VIRTO traditional mem balloon driver from scratch I stumbled across the following two points I considered to be somewhat unclear in the spec currently. Perhaps these can be cleared up in a future version.

Deflate on OOM

In the driver normative section there is first a general permission to use pages (after (acknowledged) deflation presumably) from the balloon if actual < num_pages.

The driver MAY use pages from the balloon when \field{num_pages} is
less than the actual number of pages in the balloon.

Immediately after that however this permission is modified regardless of whether or not the VIRTIO_BALLOON_F_DEFLATE_ON_OOM feature has been negotiated.
If VIRTIO_BALLOON_F_DEFLATE_ON_OOM has not been negotiated, the
driver MUST NOT use pages from the balloon when \field{num_pages}
is less than or equal to the actual number of pages in the
balloon.
If VIRTIO_BALLOON_F_DEFLATE_ON_OOM has been negotiated, the
driver MAY use pages from the balloon when \field{num_pages}
is less than or equal to the actual number of pages in the
balloon if this is required for system stability
(e.g. if memory is required by applications running within
the guest).

Here the condition is also actual <= num_pages instead of actual < num_pages.

If a driver implements the feature and it is negotiated, it must not use (or deflate?) pages unless the device requests it by changing num_pages. However if the feature has not been implemented it is not as clear as it could be that pages may not be used. Is the first general permission simply a forgotten remainder from a previous spec version? Is it left in to document that drivers implementing an older version of the spec may use pages even without the feature?

inflateq/deflateq submission format

The format for submission of the pages to the inflateq/deflateq is described as a "32-bit array". Perhaps this should be rephrased to an "array of le32 elements" or something similar for clarity. Linux seem to implement it as such.

\item The driver constructs an array of addresses of unused memory
pages. These addresses are divided by 4096\footnote{This is historical, and independent of the guest page size.
} and the descriptor
describing the resulting 32-bit array is added to the inflateq.

For legacy versions behaviour does not seem to be described by the spec on this point. Linux seems to use guest-endian elements in that case.
https://github.com/torvalds/linux/blob/aef17cb3d3c43854002956f24c24ec8e1a0e3546/drivers/virtio/virtio_balloon.c#L238-L239

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions