P2: later
An appendix to the milestone.
P2: after the move, before the first publish
-
A timer and a futex table live in a crate named for inter-process communication. Finding: the crate root calls itself "the decision core of the kernel's IPC" and then lists a timer and futex wait queues. A stranger looking for either would not look here, and one who arrives for the rendezvous meets two subsystems that are not communication between processes. The four share a reason to be together, which the note states and the README should. They are the four things the kernel's IPC-tables lock protects. Each is a safe state machine over the same
Unqueued<T>tokens with the same proof shape. Evidence:src/lib.rslines 1 to 2;notes/inter-process-communication.md("The timer", "The futex queues"). Change: the milestone's D2 decides, provisionally, that the four stay together until the publish review; the README states their shared reason. Door: two-way until the first publish (the crate name is a claim about its contents). Effort: XS to document, M to split. -
The one-queue invariant could hold by construction. Finding:
Rendezvousholds twoQueue<T>(three words each), au32and abool, about 56 bytes on a 64-bit target (counted, not measured), and three harnesses exist to show that at most one queue is non-empty. seL4's endpoint has one queue and a state tag, so the property needs no proof.enum Waiting<T> { Nobody, Senders(Queue<T>), Receivers(Queue<T>) }beside the count and the flag would makeone_queue_invariant_holdstrivially true, remove about 16 bytes per object, and leavesend,receiveandsignalas amatchon the tag. The cost is rewriting the seed, the three invariant harnesses and theremove_*pair, and the kernel's debug dump. Evidence:src/rendezvous.rslines 48 to 62 and 180 to 182;src/verification.rsseed. Change: an option for the maintainer, not a must. If taken, before publish, since it changes which proofs the README lists. Door: two-way (the layout lives in kernel pages, not on any wire). Effort: M. -
Futexesas a stranger reads it. Finding, one line each:- The const parameter is
B; parameters follow the naming rules, andBUCKETSis the word the documentation uses. Futexes<T, 0>compiles and panics on the firstpark(% BwithB == 0). Aconst { assert!(B > 0) }innewrefuses it at compile time.queued()returns a count; std's spelling islen.waiters()takes&mut selfto count, becauseQueuehas no iterator; aQueue::iteryieldingNonNull<T>inintrusive_queue(a pointer walk that dereferences nothing but the link) would makewaitersandtake's scan read-only. That change lands in the dependency.- The type is a plural noun;
FutexTablenames the thing (Linux'sfutex_hash_buckettable,parking_lot_core's hash table).Key::spaceis a generic word for the address space's name;address_spacesays which. Evidence:src/futex.rslines 47 to 57, 76 to 80, 132 to 150. Change: the renames go in the package (item 1); theconstassertion and the iterator are the maintainer's. Door: the names are one-way at publish; the assertion and the iterator two-way. Effort: S.
- The const parameter is
-
Timer::deadlineanswers with a sentinel. Finding:deadline()returnsNEVER(u64::MAX) for "nothing armed", andearliestfolds the same sentinel. The kernel needs the sentinel at exactly one place, theAtomicU64cache, and nowhere else. Std's spelling of "maybe" isOption<u64>. A timer armed at exactlyu64::MAXand a disarmed one are then distinguishable, which today they are not (the documentation says so and calls it the same thing said the other way round). Evidence:src/timer.rslines 47 to 49, 111 to 114, 150 to 152. Change:deadline() -> Option<u64>,earliest(...) -> Option<u64>, andNEVERkept for the kernel's cache word withloweredandis_dueunchanged. The three timer harnesses adapt in a few lines. Door: one-way at publish (a public signature). Effort: S. -
The pending count's saturation has no host test. Finding:
Rendezvous::signalsaturatespendingatu32::MAXand no test reaches it; the proofs reach it only through Kani's overflow check (item 8).tests.rsis inside the crate and can sete.pending = u32::MAXdirectly, as the notification test does for its word. Evidence:src/rendezvous.rsline 318;src/tests.rs. Change: one test: saturate, signal, assert the count stays unchanged andreceivestill drains one. A likely kill for one of item 9's survivors. Door: two-way. Effort: XS. -
Five copies of the test node. Finding: the node struct
N(orT), itsunsafe impl Node, and amintortokenhelper appear five times:tests.rs,verification.rs, the notification tests and proofs, and the futex tests. Each copy carries its own SAFETY paragraph for the same two obligations. Evidence:src/tests.rslines 9 to 31;src/verification.rslines 4 to 32;src/notification.rslines 256 to 283 and 396 to 415;src/futex.rslines 157 to 190. Change: one#[cfg(any(test, kani))] mod test_nodewith the struct, the impl and the two helpers, and the two obligations stated once above it. Door: two-way. Effort: S. -
Documentation details a stranger trips on. Finding: the futex module heads its examples
# EXAMPLESwhile the others write# Examples, rustdoc's convention.Key::addresssays "4-aligned" and nothing in the type enforces it; the kernel checks before it builds a key.Notification::is_idleignores the word andRendezvous::is_idleignores the count, which both say. A reader comparing the twodebug_countstuples still meets(usize, usize, u32)and(usize, u64)with no field names. A small struct with named fields reads better in a hang dump and costs nothing. Evidence:src/futex.rslines 10 and 51;src/rendezvous.rsline 192;src/notification.rsline 163. Change: the heading, "4-aligned, which the caller checks", and named diagnostic structs if the kernel's dump code is willing. Door: two-way. Effort: XS. -
Two Kani toolchain warnings the README would otherwise have to explain. Finding:
cargo kaniprintstrailing semicolon in macro used in expression positiontwice, at anassert!used as a match-arm expression; Kani's ownassertmacro raises it. Braces around the arm body remove the warning. Evidence:src/notification.rsline 364;src/verification.rsline 117. Change:Signal::ToBound(_) => { assert!(!had_waiter && bound) }and the same at the other site. Door: two-way. Effort: XS.