src/virtio/balloon.bend checks
raw source on the hub · import 0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/balloon.bend as Balloon
5 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
Types
type Part source · line 121 · raw
Data
Part@block:U32 -> @mask:U32 -> Part
type Bal source · line 124 · raw
Data
Bal@target:U32 -> @actual:U32 -> @partial:List<&2, Part> -> Bal
type Took source · line 153 · 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 195 · raw
Data
Inflated@bal:Bal -> @free:List<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov> -> Inflated
type BalPass source · line 238 · raw
Data
A pass with the device's state.
BalPass@q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> @bal:Bal -> @used:Bool -> BalPass
Definitions
def Balloon.features source · line 24 · raw
0x3c5aa333777d8e9208888ca3a048f4c7/src/lib/u64.U64
def Balloon.queues source · line 27 · raw
Nat
def Balloon.report_queue source · line 30 · raw
U32
def Balloon.config source · line 33 · raw
List<&2, U32>
def Balloon.align source · line 38 · raw
U32
The release granule: 64 KiB covers the host page sizes in use (4, 16 and 64 KiB).
def Balloon.inside source · line 43 · raw
@+addr:0x3c5aa333777d8e9208888ca3a048f4c7/src/lib/u64.U64 -> @+len:U32 -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov
The whole granules inside [addr, addr+len): none (len 0) when there are none.
def Balloon.len source · line 48 · raw
@+i:0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov -> U32
def Balloon.ranges source · line 54 · raw
@ds:List<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Desc> -> List<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov>
The granules of every descriptor of a buffer, the empty ones dropped.
def Balloon.free source · line 65 · raw
@-R:Type -> @go:Bool -> @+rs:List<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov> -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Unit>
def Balloon.serve source · line 72 · raw
@-R:Type -> @release:Bool -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> @c:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Chain -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, 0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq>
def Balloon.step source · line 80 · raw
@-R:Type -> @release:Bool -> @r:Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Maybe<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Bool)>) -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Bool)>
def Balloon.go source · line 89 · raw
@fuel:Nat -> @-R:Type -> @+release:Bool -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> @used:Bool -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Bool)>
def Balloon.process source · line 100 · raw
@-R:Type -> @+sel:U32 -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Pair(0x3c5aa333777d8e9208888ca3a048f4c7/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 115 · raw
0x3c5aa333777d8e9208888ca3a048f4c7/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 64 KiB block's memory once
all its 16 pages are in the balloon: it keeps, per block that is partly
in, a 16-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 118 · raw
U32
def Balloon.new source · line 127 · raw
Bal
def Balloon.config_of source · line 131 · raw
@+b:Bal -> List<&2, U32>
The config space of a state: num_pages (the target), actual.
def Balloon.set_target source · line 136 · raw
@+b:Bal -> @+pages:U32 -> Bal
def Balloon.target source · line 141 · raw
@+b:Bal -> U32
def Balloon.actual source · line 146 · raw
@+b:Bal -> U32
def Balloon.none source · line 156 · raw
U32
def Balloon.take.add source · line 159 · raw
@+p:Part -> @+t:Took -> Took
def Balloon.take source · line 164 · raw
@ps:List<&2, Part> -> @+block:U32 -> @+bit:U32 -> Took
def Balloon.give source · line 176 · raw
@ps:List<&2, Part> -> @+block:U32 -> @+bit:U32 -> List<&2, Part>
def Balloon.bit source · line 188 · raw
@+pfn:U32 -> U32
def Balloon.block_iov source · line 192 · raw
@+block:U32 -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov
The released blocks of an inflate, as guest ranges.
def Balloon.inflate.one source · line 198 · raw
@+t:Took -> @+ta:U32 -> @+a:U32 -> @+free:List<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Iov> -> Inflated
def Balloon.inflate source · line 204 · 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 214 · raw
@pfns:List<&2, U32> -> @+b:Bal -> Bal
Pages out of the balloon.
def Balloon.pfns source · line 224 · 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 241 · raw
@-R:Type -> @+i:Inflated -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Bal>
def Balloon.on_pfns source · line 248 · raw
@-R:Type -> @+inflate:Bool -> @+b:Bal -> @+pfns:List<&2, U32> -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Bal>
def Balloon.pfn_serve source · line 257 · raw
@-R:Type -> @+inflate:Bool -> @+b:Bal -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> @c:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Chain -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, Pair(0x3c5aa333777d8e9208888ca3a048f4c7/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 266 · raw
@-R:Type -> @+inflate:Bool -> @+b:Bal -> @r:Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Maybe<&2, 0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Bal) -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>) -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>
def Balloon.pfn_split source · line 275 · raw
@-R:Type -> @qb:Pair(0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq, Bal) -> @k:(@_:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> @_:Bal -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>) -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>
def Balloon.pfn_go source · line 280 · raw
@fuel:Nat -> @-R:Type -> @+inflate:Bool -> @+b:Bal -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> @used:Bool -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>
def Balloon.pass.report source · line 291 · raw
@-R:Type -> @+b:Bal -> @r:Pair(0x3c5aa333777d8e9208888ca3a048f4c7/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 296 · raw
@-R:Type -> @report:Bool -> @+sel:U32 -> @+b:Bal -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>
def Balloon.pass source · line 303 · raw
@-R:Type -> @+sel:U32 -> @+b:Bal -> @q:0x3c5aa333777d8e9208888ca3a048f4c7/src/virtio/queue.Vq -> 0x3c5aa333777d8e9208888ca3a048f4c7/src/vmm/abi.Op<R, BalPass>