src/virtio/balloon.bend checks
raw source on the hub · import 0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/balloon.bend as Balloon
6 imports
import Base import ../lib/u64.bend as U import ../lib/bytes.bend as B import ../vmm/abi.bend as V import ./queue.bend as Q import ./balauto.bend as A
Types
type Part source · line 124 · raw
Data
Part@block:U32 -> @mask:U32 -> Part
type Bal source · line 127 · raw
Data
Bal@target:U32 -> @actual:U32 -> @partial:List<&2, Part> -> Bal
type Took source · line 156 · raw
Data
A page into its block's mask: the masks after it, and the block when it is now whole (U32 max when not).
Took@parts:List<&2, Part> -> @whole:U32 -> Took
type Inflated source · line 215 · raw
Data
Inflated@bal:Bal -> @free:List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov> -> Inflated
type BalPass source · line 258 · raw
Data
A pass with the device's state.
BalPass@q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @bal:Bal -> @used:Bool -> BalPass
type AutoSt source · line 355 · raw
Data
What the automatic balloon keeps: the stats buffer the driver posted and
the device holds (its head; Auto.none() when none), whether the host asked
for the statistics it will bring (only an answer moves the target: the
first buffer, posted at the driver's start, does not), whether a target
was set by hand (balloon MiB: the automatic balloon stands aside), and
the latest statistics.
AutoSt@held:U32 -> @asked:Bool -> @manual:Bool -> @stats:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/balauto.Stats -> AutoSt
type StatsPass source · line 381 · raw
Data
StatsPass@q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @bal:Bal -> @auto:AutoSt -> StatsPass
Definitions
def Balloon.features source · line 28 · raw
0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64
def Balloon.queues source · line 31 · raw
Nat
def Balloon.report_queue source · line 34 · raw
U32
def Balloon.config source · line 37 · raw
List<&2, U32>
def Balloon.align source · line 41 · raw
U32
The release granule: 16 KiB, macOS's host page.
def Balloon.inside source · line 46 · raw
@+addr:0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64 -> @+len:U32 -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov
The whole granules inside [addr, addr+len): none (len 0) when there are none.
def Balloon.len source · line 51 · raw
@+i:0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov -> U32
def Balloon.ranges source · line 57 · raw
@ds:List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Desc> -> List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov>
The granules of every descriptor of a buffer, the empty ones dropped.
def Balloon.free source · line 68 · raw
@-R:Type -> @go:Bool -> @+rs:List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov> -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Unit>
def Balloon.serve source · line 75 · raw
@-R:Type -> @release:Bool -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @c:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Chain -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, 0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq>
def Balloon.step source · line 83 · raw
@-R:Type -> @release:Bool -> @r:Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Maybe<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bool)>) -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bool)>
def Balloon.go source · line 92 · raw
@fuel:Nat -> @-R:Type -> @+release:Bool -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @used:Bool -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bool)>
def Balloon.process source · line 103 · raw
@-R:Type -> @+sel:U32 -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bool)>
Queue sel's pass: the reporting queue releases what each buffer names; the others return their buffers. At most 256 buffers per pass.
def Balloon.offered source · line 118 · raw
0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64
Inflate and deflate (Virtio 1.2 5.5.6), with VIRTIO_BALLOON_F_DEFLATE_ON_OOM
(bit 2) offered too (Balloon.offered): the host sets num_pages, a target
in 4 KiB pages (balloon MiB on the control socket: Balloon.set_target);
the guest gives pages to the balloon on the inflate queue and takes them
back on the deflate queue, each buffer an array of u32 page frame numbers
(4 KiB pages, at most Balloon.max_pfns() of them read per buffer). The
device counts them (actual) and lets go of a 16 KiB block's memory once
all its 4 pages are in the balloon: it keeps, per block that is partly
in, a 4-bit mask of the pages that are. A deflated page leaves its mask;
one of a block already released is not tracked again (its memory reads
zeros when the guest touches it), so the device never releases a block
with a page the guest still has.
def Balloon.max_pfns source · line 121 · raw
U32
def Balloon.new source · line 130 · raw
Bal
def Balloon.config_of source · line 134 · raw
@+b:Bal -> List<&2, U32>
The config space of a state: num_pages (the target), actual.
def Balloon.set_target source · line 139 · raw
@+b:Bal -> @+pages:U32 -> Bal
def Balloon.target source · line 144 · raw
@+b:Bal -> U32
def Balloon.actual source · line 149 · raw
@+b:Bal -> U32
def Balloon.none source · line 159 · raw
U32
def Balloon.take.add source · line 162 · raw
@+p:Part -> @+t:Took -> Took
def Balloon.take source · line 167 · raw
@ps:List<&2, Part> -> @+block:U32 -> @+bit:U32 -> Took
def Balloon.give source · line 179 · raw
@ps:List<&2, Part> -> @+block:U32 -> @+bit:U32 -> List<&2, Part>
def Balloon.bit source · line 191 · raw
@+pfn:U32 -> U32
def Balloon.parts16.q source · line 198 · raw
@+b:U32 -> @+m:U32 -> @+q:U32 -> @+rest:List<&2, Part> -> List<&2, Part>
A snapshot taken with 64 KiB blocks (state tags 7 and 8): each mask of 16 pages as the masks of its four 16 KiB blocks (none for an empty quarter). A quarter all in the balloon was not released then: it keeps a whole mask and stays until deflated.
def Balloon.parts16 source · line 202 · raw
@ps:List<&2, Part> -> List<&2, Part>
def Balloon.block_iov source · line 212 · raw
@+block:U32 -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov
The released blocks of an inflate, as guest ranges.
def Balloon.inflate.one source · line 218 · raw
@+t:Took -> @+ta:U32 -> @+a:U32 -> @+free:List<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Iov> -> Inflated
def Balloon.inflate source · line 224 · raw
@pfns:List<&2, U32> -> @+i:Inflated -> Inflated
Pages into the balloon: the state after them, and the blocks now whole.
def Balloon.deflate source · line 234 · raw
@pfns:List<&2, U32> -> @+b:Bal -> Bal
Pages out of the balloon.
def Balloon.pfns source · line 244 · raw
@fuel:Nat -> @bs:List<&2, U32> -> List<&2, U32>
The u32 page numbers of a buffer's bytes (little-endian).
def Balloon.on_inflated source · line 261 · raw
@-R:Type -> @+i:Inflated -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Bal>
def Balloon.on_pfns source · line 268 · raw
@-R:Type -> @+inflate:Bool -> @+b:Bal -> @+pfns:List<&2, U32> -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Bal>
def Balloon.pfn_serve source · line 277 · raw
@-R:Type -> @+inflate:Bool -> @+b:Bal -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @c:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Chain -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bal)>
One inflate or deflate buffer: its page numbers read (at most max_pfns), counted, the whole blocks released; returned with length 0.
def Balloon.pfn_step source · line 286 · raw
@-R:Type -> @+inflate:Bool -> @+b:Bal -> @r:Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Maybe<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bal) -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>) -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>
def Balloon.pfn_split source · line 295 · raw
@-R:Type -> @qb:Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bal) -> @k:(@_:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @_:Bal -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>) -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>
def Balloon.pfn_go source · line 300 · raw
@fuel:Nat -> @-R:Type -> @+inflate:Bool -> @+b:Bal -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @used:Bool -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>
def Balloon.pass.report source · line 311 · raw
@-R:Type -> @+b:Bal -> @r:Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Bool) -> BalPass
A queue's pass with the device's state: 2 reports free pages; 0 inflates, 1 deflates.
def Balloon.pass.go source · line 316 · raw
@-R:Type -> @report:Bool -> @+sel:U32 -> @+b:Bal -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>
def Balloon.pass source · line 323 · raw
@-R:Type -> @+sel:U32 -> @+b:Bal -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, BalPass>
def Balloon.offered_auto source · line 336 · raw
0x5fb57f1b8ad4cb61031f616c44af7445/src/lib/u64.U64
def Balloon.queues_auto source · line 339 · raw
Nat
def Balloon.stats_queue source · line 342 · raw
U32
def Balloon.logical source · line 346 · raw
@+stats:Bool -> @+sel:U32 -> U32
The driver's number for one of ours (stats: it accepted the stats queue).
def Balloon.auto_new source · line 358 · raw
AutoSt
def Balloon.auto_manual source · line 361 · raw
@+a:AutoSt -> @+manual:Bool -> AutoSt
def Balloon.auto_held source · line 366 · raw
@+a:AutoSt -> U32
def Balloon.auto_on source · line 371 · raw
@+a:AutoSt -> Bool
def Balloon.auto_target source · line 378 · raw
@+asked:Bool -> @+manual:Bool -> @+st:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/balauto.Stats -> @+b:Bal -> Bal
The target after a stats buffer: moved only when the host asked for it and no target was set by hand.
def Balloon.stats.serve source · line 384 · raw
@-R:Type -> @+b:Bal -> @a:AutoSt -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> @c:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Chain -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, StatsPass>
def Balloon.stats.got source · line 392 · raw
@-R:Type -> @+b:Bal -> @+a:AutoSt -> @r:Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, Maybe<&2, 0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Chain>) -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, StatsPass>
def Balloon.stats_pass source · line 401 · raw
@-R:Type -> @+b:Bal -> @+a:AutoSt -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, StatsPass>
The stats queue's pass: the buffer the driver posted is read and held (the host returns it when it wants fresh statistics: Balloon.poll).
def Balloon.poll.go source · line 407 · raw
@-R:Type -> @skip:Bool -> @+h:U32 -> @+k:Bool -> @+manual:Bool -> @+st:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/balauto.Stats -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, AutoSt), Bool)>
Asking for fresh statistics: the held buffer returned (used length 0); the driver posts it again with new values. Nothing when none is held or a target was set by hand.
def Balloon.poll source · line 415 · raw
@-R:Type -> @+a:AutoSt -> @q:0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq -> 0x5fb57f1b8ad4cb61031f616c44af7445/src/vmm/abi.Op<R, Pair(Pair(0x5fb57f1b8ad4cb61031f616c44af7445/src/virtio/queue.Vq, AutoSt), Bool)>