Files
mac_linuxgpu/scripts/test-hrtimer.sh
T
geramyloveless 285ef4bc61 linuxu: hrtimer on the timer service
Implement hrtimer_setup(), hrtimer_start_range_ns(), hrtimer_try_to_cancel(),
hrtimer_cancel(), hrtimer_active(), hrtimer_forward(),
hrtimer_cb_get_time() and __hrtimer_get_remaining() in linuxu/src/timer.c.
The existing worker thread now serves both timer_list (jiffies) and
hrtimer (nanosecond deadlines on CLOCK_MONOTONIC, CLOCK_REALTIME or
CLOCK_BOOTTIME), sleeping until the earliest of either.

Semantics follow kernel/time/hrtimer.c: the timer is dequeued before
its callback, HRTIMER_RESTART re-enqueues it at the expiry the callback
forwarded to, try_to_cancel() returns -1 while the callback runs,
hrtimer_cancel() waits for it, and a NORESTART timer is not touched after
its callback returns. drm_vblank's timer-based vblank and amdgpu_vkms use
this; the hrtimer stubs that called them unreachable are gone.

scripts/test-hrtimer.sh covers one-shot and periodic timers, forward
overrun arithmetic, cancel while running, the drm_vblank
active/try_to_cancel loop and coexistence with timer_list timers. The
timer service test now links timekeeping.c for the clocks.
2026-10-02 20:56:19 -07:00

13 lines
536 B
Bash

#!/usr/bin/env bash
# hrtimer on the linuxu timer service, under ASan/UBSan.
set -euo pipefail
cd "$(dirname "$0")/.."
test_dir=$(mktemp -d)
trap 'rm -rf "$test_dir"' EXIT
clang -w -std=gnu11 -g -O1 -D__KERNEL__ -include linux/autoconf.h \
-fsanitize=address,undefined -fno-sanitize-recover=all \
-ffunction-sections -fdata-sections -Ilinuxu/headers \
linuxu/tests/test_hrtimer.c linuxu/src/timer.c linuxu/src/shims/timekeeping.c linuxu/src/bug.c \
-Wl,-dead_strip -lpthread -o "$test_dir/test_hrtimer"
"$test_dir/test_hrtimer"