Problem
GNU coreutils timeout fails on DragonOS because it creates its POSIX timer with CLOCK_REALTIME:
timeout: warning: timer_create: Invalid argument
This warning was observed while running the LMbench TCP loopback latency wrapper under QEMU, but it is intermittently observable through that path: on some runs timeout succeeds via a fallback and the wrapper completes without the warning. The underlying kernel limitation is deterministic and is best reproduced with the C API below.
Authoritative reproduction (C API, confirmed in guest)
Run the following inside a DragonOS guest (not on the Linux host):
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
static void try_timer(clockid_t clock_id, const char *name)
{
timer_t timer_id;
if (timer_create(clock_id, NULL, &timer_id) == 0) {
printf("%s: OK\n", name);
timer_delete(timer_id);
return;
}
printf("%s: failed: errno=%d (%s)\n",
name, errno, strerror(errno));
}
int main(void)
{
try_timer(CLOCK_MONOTONIC, "CLOCK_MONOTONIC");
try_timer(CLOCK_REALTIME, "CLOCK_REALTIME");
return 0;
}
Cross-compile for the guest (x86_64, glibc 2.39) and run on the guest. Confirmed output on DragonOS x86_64/QEMU:
CLOCK_MONOTONIC: OK
CLOCK_REALTIME: failed: errno=22 (Invalid argument)
So timer_create(CLOCK_REALTIME, NULL, &timerid) deterministically returns EINVAL. With sevp == NULL, this is the standard default SIGEV_SIGNAL / SIGALRM behavior; it does not require SIGEV_THREAD.
Secondary reproduction (coreutils timeout)
Inside a DragonOS guest:
/usr/local/bin/timeout 1s /bin/true 2>&1
echo "exit=$?"
May print timeout: warning: timer_create: Invalid argument (intermittent; timeout can still complete via fallback). The LMbench end-to-end path is:
make test-benchmark
grep -n -C 3 "timer_create: Invalid argument" serial_opt.txt
The warning, when present, appears in the tcp_loopback_lat case; lat_tcp can still print a numeric latency, and the benchmark runner may accept that sample.
Root cause
kernel/src/process/posix_timer.rs currently accepts only CLOCK_MONOTONIC in timer_create, returning EINVAL for CLOCK_REALTIME. GNU coreutils calls:
timer_create(CLOCK_REALTIME, NULL, &timerid)
Expected behavior
timer_create(CLOCK_REALTIME, NULL, &timerid) should succeed when the requested notification mode is already supported, so standard coreutils timeout works.
Scope
Supporting CLOCK_REALTIME alongside the existing CLOCK_MONOTONIC path should be sufficient for this compatibility case. Timer semantics should follow the selected clock and preserve the existing notification behavior.
Related work checked
None appears to cover rejecting CLOCK_REALTIME in timer_create.
Environment
- DragonOS x86_64 in QEMU (KVM)
- GNU coreutils
timeout
- LMbench 3.0-a9 TCP loopback latency benchmark
- Guest glibc 2.39, x86_64-linux-gnu cross-compiled repro binary
Problem
GNU coreutils
timeoutfails on DragonOS because it creates its POSIX timer withCLOCK_REALTIME:This warning was observed while running the LMbench TCP loopback latency wrapper under QEMU, but it is intermittently observable through that path: on some runs
timeoutsucceeds via a fallback and the wrapper completes without the warning. The underlying kernel limitation is deterministic and is best reproduced with the C API below.Authoritative reproduction (C API, confirmed in guest)
Run the following inside a DragonOS guest (not on the Linux host):
Cross-compile for the guest (x86_64, glibc 2.39) and run on the guest. Confirmed output on DragonOS x86_64/QEMU:
So
timer_create(CLOCK_REALTIME, NULL, &timerid)deterministically returnsEINVAL. Withsevp == NULL, this is the standard defaultSIGEV_SIGNAL/SIGALRMbehavior; it does not requireSIGEV_THREAD.Secondary reproduction (coreutils timeout)
Inside a DragonOS guest:
May print
timeout: warning: timer_create: Invalid argument(intermittent;timeoutcan still complete via fallback). The LMbench end-to-end path is:make test-benchmark grep -n -C 3 "timer_create: Invalid argument" serial_opt.txtThe warning, when present, appears in the
tcp_loopback_latcase;lat_tcpcan still print a numeric latency, and the benchmark runner may accept that sample.Root cause
kernel/src/process/posix_timer.rscurrently accepts onlyCLOCK_MONOTONICintimer_create, returningEINVALforCLOCK_REALTIME. GNU coreutils calls:Expected behavior
timer_create(CLOCK_REALTIME, NULL, &timerid)should succeed when the requested notification mode is already supported, so standard coreutilstimeoutworks.Scope
Supporting
CLOCK_REALTIMEalongside the existingCLOCK_MONOTONICpath should be sufficient for this compatibility case. Timer semantics should follow the selected clock and preserve the existing notification behavior.Related work checked
SIGEV_THREAD/SIGEV_THREAD_IDNone appears to cover rejecting
CLOCK_REALTIMEintimer_create.Environment
timeout