Part 6 of 6 · 3 min read
Exercises
Easy
Easy 1: Overcommit (20 minutes)
A host has 32 cores and runs guests with 80 vCPUs in total. What is the overcommit ratio?
Done when: 2.5 to 1.
Hint
vCPUs divided by cores.
Easy 2: Nested walk (20 minutes)
How many references does a nested walk need for 3 guest levels and 3 host levels?
Done when: (3 + 1) x (3 + 1) - 1 = 15.
Hint
apply the formula.
Easy 3: Which table (20 minutes)
Who controls the GVA to GPA mapping, and who controls GPA to HPA?
Done when: the guest kernel, and the hypervisor.
Hint
the guest sees GPAs as real.
Medium
Medium 1: Extra references (45 minutes)
A workload has a TLB miss rate of 2 per cent. Compute the data references per access for a native 4-level system and a 4 by 4 nested system, and the ratio.
Done when: 0.98 + 0.02 x 5 = 1.08 and 0.98 + 0.02 x 25 = 1.48, ratio 1.37.
Hint
use the formula of Section 3 with miss rate 0.02.
Medium 2: Find the balloon (45 minutes)
On a Linux VM, list /sys/bus/virtio/devices with the device type and driver of each, and say which one is the balloon. If your machine is not a VM, say what you found instead.
Done when: a list with type 0x0005 and virtio_balloon for the balloon, or an explanation of the empty directory.
Hint
cat device and readlink driver for each entry.
Medium 3: How much to reclaim (45 minutes)
A host has 128 GiB and guests use 141 GiB at peak. How much must be reclaimed, and what share of that could come from a guest with 20 GiB of cache if it gives up half of it?
Done when: 13 GiB needed, and 10 GiB from the cache, which is 10 / 13 = 77 per cent.
Hint
141 - 128 = 13.
Hard
Hard 1: Shadow or nested (90 minutes)
Compare shadow tables and nested paging for (a) a program that starts many processes quickly and (b) a program that reads a very large array at random. Which design is better for each, and why?
Done when: (a) nested, since page-table writes do not trap; (b) shadow, since walks are short, with a note that huge pages change the balance.
Hint
think of what each design makes costly.
Hard 2: Walk formula (90 minutes)
Derive (g + 1) x (h + 1) - 1: each of the g guest table reads needs the address of the guest table itself translated by h host levels, plus the final GPA also needs translating.
Done when: g reads of guest tables each cost h host references plus one read of the entry itself, and the final translation costs h more, giving g x (h + 1) + h = (g + 1)(h + 1) - 1.
Hint
draw the 2D walk for g = 2, h = 2.
Hard 3: A balloon policy (90 minutes)
Write a policy for a host to decide which guest to inflate: what data from the stats queue it needs, and when to stop and swap instead.
Done when: a policy that uses free memory and cache per guest, takes from the guest with the most cache, and stops when guests have no cache and swapping or migration is needed.
Hint
the least harm comes from pages the guest does not need.