Pool recycling of pageout'd regions: validate syscall costs and residency semantics

Aperta
#1 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
linux, rust

Direzione di ricerca

Start at ThreadLocalStealer::deallocate and run the listed experiments across the representative allocation sizes, measuring first-touch time, mincore residency, AnonHugePages in /proc/self/smaps, and syscall overhead for each advisory. Done means comparing the four mitigation proposals on Linux 5.15+ and recording whether the data supports a runtime change or documentation-only approach.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Context

When a user allocates a region, writes to it, calls pageout (MADV_PAGEOUT), and then deallocates, the pool recycles the (now-cold) allocation. The next caller that writes to the recycled region pays page-fault cost on first access. The pool's implicit contract ("cheap to re-hand-out") is violated silently.

Current deallocation path:

  1. Drop routes through ThreadLocalStealer::deallocate → worker queue.
  2. Eventually either handed out again, or moved to the global injector and later cleared by the background worker via MADV_FREE (Linux) / MADV_DONTNEED (other).
  3. MADV_FREE on pageout'd pages is a no-op — the pages are already gone.

Pages can also lose THP backing silently. MADV_COLD / MADV_PAGEOUT may split a transparent huge page to operate on a sub-range; splits are not automatically reversed.

Experiments to run

Measure, in isolation, with representative allocation sizes (2 MiB, 16 MiB, 128 MiB, 1 GiB):

  • Baseline write cost on a freshly-mmaped anonymous region with MADV_HUGEPAGE: first-touch fault cost, bandwidth for full write-through.
  • Post-MADV_PAGEOUT cost: pageout a resident region, re-write it. Measure fault cost and whether THP is still in effect (/proc/self/smaps → AnonHugePages).
  • Post-MADV_COLD cost: same, but just marking cold. Does re-touch rebuild THP?
  • Post-MADV_DONTNEED cost: does the kernel re-fault into huge pages, or small pages?
  • Post-MADV_FREE (then reclaimed) cost: pressure the kernel into reclaiming, then re-touch.
  • Syscall overhead of MADV_DONTNEED / MADV_FREE / mincore per call, as a function of region size.

Track per-scenario:

  • Time to first-touch the region after the advisory.
  • Residency after re-touch (via mincore).
  • Huge-page status after re-touch.

Mitigation proposals to compare

  1. Every dealloc runs MADV_DONTNEED on the region before it re-enters the pool. Guarantees the next caller faults into fresh (presumably THP-backed) pages. Costs one syscall per dealloc.
    • Open question: after MADV_DONTNEED, does the next touch fault into a huge page, or small pages? Empirically the kernel has flip-flopped on this across versions.
  2. MADV_DONTNEED only on promotion to the global injector. Thread-local reuse skips it (fast path for allocate-then-dealloc-then-allocate within one thread). Cross-thread handoffs pay the cost.
  3. mincore-gated decision. Call mincore first; only MADV_DONTNEED if a significant fraction of the region is non-resident (heuristic: user recently pageout'd). Adds a syscall but may be cheaper than unconditional MADV_DONTNEED on huge regions.
  4. Status quo + documentation. pageout's doc warns callers that deallocating a pageout'd region hands cold memory to the next caller. No runtime mitigation.

Decision inputs

  • Absolute syscall cost vs. absolute page-fault cost at representative sizes.
  • Whether MADV_DONTNEED reliably rebuilds THP on re-touch under current kernels (5.15+ target).
  • Whether mincore's cost scales acceptably for our size classes (up to 128 GiB).

Scope

Investigation only for 0.1.x. If experiments point to a clear winner, ship the mitigation in a minor release. Until then, rely on the (yet-to-add) doc warning on pageout.

Lingua principale
Rust
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.