Files
mac_linuxgpu/linuxu/tests
geramyloveless 3fb002e707 display-agent: keep the virtual display composing; capture with no frame interval
Typing on the Dell lagged: a typed character could take 200 ms to show.
A type workload (a glyph-sized mark that changes 5 to 15 times a second
at random, each change followed to its flip) put the whole delay before
the frame reaches the agent: the WindowServer lets a virtual display's
update cycle idle when nothing on it changes, and the next change waits
to be composited. A probe in another process saw the same on the virtual
display (change to frame p90 157 ms, max 203 ms) and not on the built-in
one (p90 22 ms). The agent's part (frame handler to PRESENT, 0.3 ms;
PRESENT to flip, under a refresh) was never the cause.

DisplayKeepAlive: a 2x2 point window in a corner of the virtual display
changes its opacity every refresh between two values that composite to
the same pixels, so the WindowServer composes the display each refresh;
the frames it causes change nothing and the damage filter drops them, so
nothing is copied or flipped for it (idle desktop: 20 frames presented in
12 s with or without it; the agent's CPU 0.2% -> 0.6-1.3%, 9 -> 64
wakeups/s). The capture now has no minimum frame interval, so the stream
wakes right after each composition instead of on a grid of its own.

Typing, change to flip: p50 25-33 ms, p90 134-157 ms, max 218-222 ms
(10 to 14 of ~65 changes never shown on their own) before; p50 20 ms,
p90 28 ms, max 31 ms (none) after. Scrolling runs at 58 flips/s (50.6
before). refreshDeadline 0.004 measured no better and stays unset;
--frame-interval refresh and --keep-alive off restore the old behaviour
for measuring. A mirroring process also holds a latency-critical activity
(no App Nap timer coalescing) and creates the virtual display on a
user-interactive queue.

The type workload (--workload type) reports each stage's p50, p90 and
max: change to composition, composition to frame handler, handler to
PRESENT, PRESENT to flip, change to flip. Its marks are four black or
white squares that encode the change number in binary, which the
display's colour conversion cannot shift.
2026-10-04 09:50:22 -07:00
..
2026-10-03 17:50:21 -07:00
2026-10-03 17:50:21 -07:00
2026-10-03 17:50:21 -07:00

linuxu tests

Standalone unit tests for the linuxu shim layer. Each test is a plain main() program using a local EXPECT() macro (no test framework — the dext cannot link gtest/libc-test deps).

Build & run

cd <repo>/linuxu
# host build (no DriverKit): -fsyntax-only first, then real link
clang -std=gnu11 -D__KERNEL__ -I<repo>/linuxu/headers \
  <test>.c <required shim .c files> -lpthread -o <test>
./<test>

The make test target (top-level Makefile) builds and runs all of them. Per-test required shim files:

test links with (shim sources)
test_kmemcheck kmem/kmemcheck.c kmem/kmemalloc.c kmem/string.c shims/printk.c
test_fake_mmio pci/pdev_mmio.c
test_vram amdgpu-rt/vram.c
test_irq amdgpu-rt/device.c pci/pci_stub.c shims/printk.c
test_workqueue work.c sync.c shims/printk.c
test_timer timer.c sync.c shims/printk.c
test_xarray xarray.c
test_rcu rcu.c shims/printk.c

What is REAL vs STUB

  • REAL (assertions exercise the actual algorithm): kmemcheck canaries, fake-MMIO token table + 16KB slots + readl/writel dispatch, vram bump allocator + pfn mapping, irq register/inject/unregister, workqueue (pthread worker + jiffy-delayed promotion + cancel_delayed_work_sync), timer_list (4ms reaper), xarray (node tree + xa_alloc), rcu (per-thread defer list + synchronize barrier).
  • STUB (documented, no assertions beyond "does not crash"): i2c (xfer → -ENOENT), acpi, mmu_notifier, dev_coredump, module, firmware (loader is REAL for the host build; the dext build swaps in the embedded-table path), debugfs/sysfs (table no-ops — could be extended with a test_debugfs later).

Running without a GPU

All tests run in-process on the host with no GPU, no IOKit, and no root. The fake-MMIO and vram backends use host shadow buffers; the LINUXU_DEXT compile flag switches them to the IOPCIDevice backends (compiled only for the dext bundle, not for these tests).