---
title: Problem set 7
heading: "Problem set 7: memory systems, virtualization, networks and security"
eyebrow: S4 · Problem set 7
type: problems
---

::: hook
These problems use lessons 20 to 37: multicore cache hierarchies, the cache lab, virtualization, memory bandwidth and NUMA, on-chip networks, and hardware security. They lean on Little's law, the √2 rule and the queueing intuition of the earlier lessons.
:::

::: pool
pick: 12

::: check
kind: parts
given: n = 4 | 5; m = 4 | 5

## A guest uses {n}-level page tables on a host with {m}-level nested tables. Huge pages in both remove one level from each.

::: part
answer: (n + 1)*(m + 1) - 1
unit: accesses
tolerance: 0

### How many accesses can a TLB miss take?

::: misses
- [any] $(n + 1)(m + 1) - 1$.
:::
:::

::: part
answer: n*m - 1
unit: accesses
tolerance: 0

### And with huge pages in both dimensions?

::: misses
- [any] Use n − 1 and m − 1 levels.
:::
:::
:::

::: check
kind: parts
given: E = 20000 | 100000; t = 1 | 3; c = 16 | 32

## A VM causes {E} exits a second at {t} µs each, on a {c}-core host running one such VM per core.

::: part
answer: E*t/1e6*100
unit: %
tolerance: 0.5%

### What fraction of each core goes to exits?

::: misses
- [any] Exits per second × cost.
:::
:::

::: part
answer: c*E*t/1e6
unit: cores
tolerance: 0.5%

### How many cores' worth is that across the host?

::: misses
- [any] Per-core fraction × cores.
:::
:::
:::

::: check
kind: parts
given: b = 0.25 | 1 | 2; i = 1.5 | 3; f = 2.5 | 3.5; c = 8 | 12; R = 4800 | 6400; n = 64 | 128

## Each core moves {b} bytes from memory per instruction at IPC {i} and {f} GHz; the server has {c} channels at {R} MT/s (8 bytes wide) for {n} cores.

::: part
answer: b*i*f
unit: GB/s
tolerance: 0.5%

### What bandwidth does each core need?

::: misses
- [any] Bytes per instruction × IPC × clock.
:::
:::

::: part
answer: c*R*8/1000/n
unit: GB/s
tolerance: 0.5%

### What is each core's share?

::: misses
- [any] Peak over cores.
:::
:::
:::

::: check
kind: parts
given: B = 100 | 300; L = 80 | 120; m = 10 | 24

## A chip's memory delivers {B} GB/s at {L} ns, in 64-byte lines; each core can keep {m} misses in flight.

::: part
answer: B*L/64
unit: lines
tolerance: 0.5%

### How many misses must be in flight for full bandwidth?

::: misses
- [any] Bandwidth × latency ÷ line.
:::
:::

::: part
answer: ceil(B*L/(64*m) - 1e-9)
unit: cores
tolerance: 0

### How many cores does that take?

::: misses
- [any] Round up lines in flight over each core's MSHRs.
:::
:::
:::

::: check
kind: parts
given: a = 85 | 100; b = 140 | 190; r = 0.2 | 0.5

## Local memory takes {a} ns and remote {b} ns; a thread makes {r} of its accesses remote.

::: part
answer: (1 - r)*a + r*b
unit: ns
tolerance: 0.5%

### What is its average latency?

::: misses
- [any] Weighted average.
:::
:::

::: part
answer: ((1 - r)*a + r*b)/a
tolerance: 0.5%

### How much slower is that than all-local?

::: misses
- [any] Average over local.
:::
:::
:::

::: check
kind: parts
given: D = 0.5 | 4; e = 5 | 15; N = 2 | 10; f = 5 | 20

## A kernel moves {D} GB from DRAM at {e} pJ per bit and performs {N} × 10⁹ operations at {f} pJ each.

::: part
answer: D*8e9*e*1e-12 + N*1e9*f*1e-12
unit: J
tolerance: 0.5%

### What energy does it use in all?

::: misses
- [N*1e9*f*1e-12] Add the data movement.
- [any] Bits × energy + operations × energy.
:::
:::

::: part
answer: D*8e9*e*1e-12/(D*8e9*e*1e-12 + N*1e9*f*1e-12)*100
unit: %
tolerance: 0.5%

### What share is data movement?

::: misses
- [any] Movement over total.
:::
:::
:::

::: check
kind: parts
given: k = 4 | 8 | 12; r = 2 | 3; L = 64 | 128; b = 16 | 32

## A {k} × {k} mesh has {r}-cycle routers and 1-cycle links {b} bytes wide; packets carry {L} bytes.

::: part
answer: 2*k/3*(r + 1) + L/b
unit: cycles
tolerance: 0.5%

### What is the zero-load latency at the average distance?

::: misses
- [any] $H(t_r + t_w) + L/b$.
:::
:::

::: part
answer: 4/k*b
unit: bytes/cycle
tolerance: 0.5%

### What injection rate per node saturates it under uniform traffic, in bytes per cycle?

::: misses
- [any] $4/k$ flits per node per cycle × flit size.
:::
:::
:::

::: check
kind: parts
given: w = 1 | 2; r = 3 | 4; c = 1 | 2; s = 4 | 8

## A link's credit loop: {w} cycle(s) across, {r} through the next router, {c} for the credit's return. Each virtual channel has {s} buffers.

::: part
answer: w + r + c
unit: cycles
tolerance: 0

### What is the credit round trip?

::: misses
- [any] Sum the three.
:::
:::

::: part
answer: (s/(w + r + c) - (s/(w + r + c) - 1)*step(s/(w + r + c) - 1))*100
unit: %
tolerance: 0.5%

### What fraction of the link can one virtual channel use?

::: misses
- [any] Buffers over round trip, at most 100%.
:::
:::
:::

::: check
kind: parts
given: f = 2 | 3 | 4; c = 1000 | 4000; e = 0.02 | 0.1 | 0.25

## A cache covert channel sends a symbol every {c} cycles at {f} GHz and misreads {e} of them.

::: part
answer: f*1e9/c*(1 + e*log(e)/log(2) + (1 - e)*log(1 - e)/log(2))
unit: bits/s
tolerance: 0.5%

### What information rate can it reach with ideal coding?

::: misses
- [f*1e9/c*(1 - e)] Errors cost more than their fraction: use $1 - H(e)$.
- [any] Symbol rate × $(1 - H(e))$.
:::
:::
:::

::: check
kind: parts
given: s = 5000 | 20000; p = 150 | 300; f = 3 | 5; K = 16 | 32

## A Spectre round takes {s} cycles of setup plus 256 probes of {p} cycles, at {f} GHz; the target is a {K}-byte key.

::: part
answer: f*1e9/(s + 256*p)
unit: bytes/s
tolerance: 0.5%

### How fast does it leak?

::: misses
- [any] Clock over cycles per byte.
:::
:::

::: part
answer: K*(s + 256*p)/(f*1e9)*1e6
unit: µs
tolerance: 0.5%

### How long does the key take?

::: misses
- [any] Bytes × cycles per byte ÷ clock.
:::
:::
:::

::: check
kind: parts
given: t = 40 | 50; W = 32 | 64; n = 20000 | 100000

## DRAM rows cycle in {t} ns with a {W} ms refresh window; a victim row flips after {n} neighbor activations.

::: part
answer: W*1e-3/(t*1e-9)
tolerance: 0.5%

### How many activations fit in a window?

::: misses
- [any] $W/t_{RC}$.
:::
:::

::: part
answer: n/(W*1e-3/(t*1e-9))*100
unit: %
tolerance: 0.5%

### What fraction of the window does an attack need?

::: misses
- [any] Threshold over the activations available.
:::
:::
:::

::: check
kind: parts
given: N = 8 | 16; L = 1 | 2; C = 16 | 32 | 64; k = 4 | 6; a = 10 | 14; t = 2 | 3

## {N} cores each have an {L} MB private L2 under a {C} MB L3 sliced over a {k} × {k} mesh ({a}-cycle slices, {t} cycles per hop).

::: part
answer: C + N*L
unit: MB
tolerance: 0.5%

### How much distinct data fits if the L3 is exclusive?

::: misses
- [C] An exclusive L3 adds to the L2s' capacity.
- [any] L3 plus all the L2s.
:::
:::

::: part
answer: a + 2*(2*k/3)*t
unit: cycles
tolerance: 0.5%

### What is the average latency to an L3 slice?

::: misses
- [any] Slice + round trip at the average distance.
:::
:::
:::

::: check
kind: parts
given: W = 8 | 16; S = 16 | 64; m = 0.01 | 0.04; s = 2 | 4 | 8

## A {S} MB, {W}-way LLC with 64-byte lines uses tree pseudo-LRU. A program that misses {m} alone shares it equally among {s} programs.

::: part
answer: (W - 1)*S*1024*1024/(64*W)/8/1024
unit: KB
tolerance: 0.5%

### How much replacement state does the cache hold?

::: misses
- [any] W − 1 bits per set.
:::
:::

::: part
answer: m*sqrt(s)
tolerance: 0.5%

### What miss rate does the program see when sharing?

::: misses
- [any] $m\sqrt s$ by the √2 rule.
:::
:::
:::

::: check
kind: parts
given: d = 1 | 2 | 4; e = 2 | 3; D = 10 | 50

## A side channel through the L1 can be closed two ways: flushing the L1 on every context switch, at {d} µs per flush with {D} thousand switches a second; or partitioning the cache, which multiplies a program's miss rate by {e}. The program spends 10% of its time in cache stalls before partitioning.

::: part
answer: d*D*1000/1e6*100
unit: %
tolerance: 0.5%

### What does flushing cost, as a fraction of a core?

::: misses
- [any] Switches per second × cost.
:::
:::

::: part
answer: 10*(e - 1)
unit: %
tolerance: 0.5%

### How much more time does partitioning add, if stalls grow in proportion to the miss rate?

::: misses
- [any] The 10% stall share grows by the factor, minus one.
:::
:::
:::
:::
