~/bend-docscommunity

src/virtio/balloon.bend checks

raw source on the hub · import 0xe9825c4430d87f4e4f8bae43f6c7aee3/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 122 · raw

Data

type Bal source · line 125 · raw

Data

type Took source · line 154 · 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).

type Inflated source · line 196 · raw

Data

type BalPass source · line 239 · raw

Data

A pass with the device's state.

type AutoSt source · line 336 · 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.

type StatsPass source · line 362 · raw

Data

Definitions

def Balloon.features source · line 25 · raw

0xe9825c4430d87f4e4f8bae43f6c7aee3/src/lib/u64.U64

def Balloon.queues source · line 28 · raw

Nat

def Balloon.report_queue source · line 31 · raw

U32

def Balloon.config source · line 34 · raw

List<&2, U32>

def Balloon.align source · line 39 · raw

U32

The release granule: 64 KiB covers the host page sizes in use (4, 16 and 64 KiB).

def Balloon.inside source · line 44 · raw

@+addr:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/lib/u64.U64 -> @+len:U32 -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Iov

The whole granules inside [addr, addr+len): none (len 0) when there are none.

def Balloon.len source · line 49 · raw

@+i:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Iov -> U32

def Balloon.ranges source · line 55 · raw

@ds:List<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Desc> -> List<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Iov>

The granules of every descriptor of a buffer, the empty ones dropped.

def Balloon.free source · line 66 · raw

@-R:Type -> @go:Bool -> @+rs:List<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Iov> -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Unit>

def Balloon.serve source · line 73 · raw

@-R:Type -> @release:Bool -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> @c:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Chain -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq>

def Balloon.step source · line 81 · raw

@-R:Type -> @release:Bool -> @r:Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Maybe<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Bool)>) -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Bool)>

def Balloon.go source · line 90 · raw

@fuel:Nat -> @-R:Type -> @+release:Bool -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> @used:Bool -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Bool)>

def Balloon.process source · line 101 · raw

@-R:Type -> @+sel:U32 -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/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 116 · raw

0xe9825c4430d87f4e4f8bae43f6c7aee3/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 119 · raw

U32

def Balloon.new source · line 128 · raw

Bal

def Balloon.config_of source · line 132 · raw

@+b:Bal -> List<&2, U32>

The config space of a state: num_pages (the target), actual.

def Balloon.set_target source · line 137 · raw

@+b:Bal -> @+pages:U32 -> Bal

def Balloon.target source · line 142 · raw

@+b:Bal -> U32

def Balloon.actual source · line 147 · raw

@+b:Bal -> U32

def Balloon.none source · line 157 · raw

U32

def Balloon.take.add source · line 160 · raw

@+p:Part -> @+t:Took -> Took

def Balloon.take source · line 165 · raw

@ps:List<&2, Part> -> @+block:U32 -> @+bit:U32 -> Took

def Balloon.give source · line 177 · raw

@ps:List<&2, Part> -> @+block:U32 -> @+bit:U32 -> List<&2, Part>

def Balloon.bit source · line 189 · raw

@+pfn:U32 -> U32

def Balloon.block_iov source · line 193 · raw

@+block:U32 -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Iov

The released blocks of an inflate, as guest ranges.

def Balloon.inflate.one source · line 199 · raw

@+t:Took -> @+ta:U32 -> @+a:U32 -> @+free:List<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Iov> -> Inflated

def Balloon.inflate source · line 205 · 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 215 · raw

@pfns:List<&2, U32> -> @+b:Bal -> Bal

Pages out of the balloon.

def Balloon.pfns source · line 225 · 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 242 · raw

@-R:Type -> @+i:Inflated -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Bal>

def Balloon.on_pfns source · line 249 · raw

@-R:Type -> @+inflate:Bool -> @+b:Bal -> @+pfns:List<&2, U32> -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Bal>

def Balloon.pfn_serve source · line 258 · raw

@-R:Type -> @+inflate:Bool -> @+b:Bal -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> @c:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Chain -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/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 267 · raw

@-R:Type -> @+inflate:Bool -> @+b:Bal -> @r:Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Maybe<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Bal) -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>) -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>

def Balloon.pfn_split source · line 276 · raw

@-R:Type -> @qb:Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Bal) -> @k:(@_:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> @_:Bal -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>) -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>

def Balloon.pfn_go source · line 281 · raw

@fuel:Nat -> @-R:Type -> @+inflate:Bool -> @+b:Bal -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> @used:Bool -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>

def Balloon.pass.report source · line 292 · raw

@-R:Type -> @+b:Bal -> @r:Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/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 297 · raw

@-R:Type -> @report:Bool -> @+sel:U32 -> @+b:Bal -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>

def Balloon.pass source · line 304 · raw

@-R:Type -> @+sel:U32 -> @+b:Bal -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, BalPass>

def Balloon.offered_auto source · line 317 · raw

0xe9825c4430d87f4e4f8bae43f6c7aee3/src/lib/u64.U64

def Balloon.queues_auto source · line 320 · raw

Nat

def Balloon.stats_queue source · line 323 · raw

U32

def Balloon.logical source · line 327 · 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 339 · raw

AutoSt

def Balloon.auto_manual source · line 342 · raw

@+a:AutoSt -> @+manual:Bool -> AutoSt

def Balloon.auto_held source · line 347 · raw

@+a:AutoSt -> U32

def Balloon.auto_on source · line 352 · raw

@+a:AutoSt -> Bool

def Balloon.auto_target source · line 359 · raw

@+asked:Bool -> @+manual:Bool -> @+st:0xe9825c4430d87f4e4f8bae43f6c7aee3/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 365 · raw

@-R:Type -> @+b:Bal -> @a:AutoSt -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> @c:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Chain -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, StatsPass>

def Balloon.stats.got source · line 373 · raw

@-R:Type -> @+b:Bal -> @+a:AutoSt -> @r:Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, Maybe<&2, 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Chain>) -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, StatsPass>

def Balloon.stats_pass source · line 382 · raw

@-R:Type -> @+b:Bal -> @+a:AutoSt -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/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 388 · raw

@-R:Type -> @skip:Bool -> @+h:U32 -> @+k:Bool -> @+manual:Bool -> @+st:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/balauto.Stats -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/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 396 · raw

@-R:Type -> @+a:AutoSt -> @q:0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq -> 0xe9825c4430d87f4e4f8bae43f6c7aee3/src/vmm/abi.Op<R, Pair(Pair(0xe9825c4430d87f4e4f8bae43f6c7aee3/src/virtio/queue.Vq, AutoSt), Bool)>