From e832bca069f910e12213d424aa75d7496c6c7d1f Mon Sep 17 00:00:00 2001 From: Nicholas Berlin Date: Fri, 14 Aug 2026 10:21:52 -0400 Subject: [PATCH 1/4] Document the boottime calls Manpages for quark_update_boottime(3), quark_get_boottime(3) and quark_time_to_wallclock(3), listed in quark(7), with the HTML docs and README.md regenerated. The pages document which times are expressed since boot, that btime comes from /proc/stat and moves on clock steps, and two common ways of detecting a step. --- README.md | 14 +++- docs/index.html | 11 ++- docs/quark.7.html | 11 ++- docs/quark_get_boottime.3.html | 84 ++++++++++++++++++++++ docs/quark_time_to_wallclock.3.html | 95 ++++++++++++++++++++++++ docs/quark_update_boottime.3.html | 107 ++++++++++++++++++++++++++++ quark.7 | 9 +++ quark_get_boottime.3 | 48 +++++++++++++ quark_time_to_wallclock.3 | 67 +++++++++++++++++ quark_update_boottime.3 | 87 ++++++++++++++++++++++ 10 files changed, 530 insertions(+), 3 deletions(-) create mode 100644 docs/quark_get_boottime.3.html create mode 100644 docs/quark_time_to_wallclock.3.html create mode 100644 docs/quark_update_boottime.3.html create mode 100644 quark_get_boottime.3 create mode 100644 quark_time_to_wallclock.3 create mode 100644 quark_update_boottime.3 diff --git a/README.md b/README.md index e87b74a3..bbdca317 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,18 @@ block for an unspecified amount of time. basic queue statistics. +[quark\_time\_to\_wallclock(3)](https://elastic.github.io/quark/quark_time_to_wallclock.3.html) + +translate a time since boot to wallclock. + +[quark\_update\_boottime(3)](https://elastic.github.io/quark/quark_update_boottime.3.html) + +refetch the boottime epoch after a system clock change. + +[quark\_get\_boottime(3)](https://elastic.github.io/quark/quark_get_boottime.3.html) + +get the boottime epoch. + [quark\_queue\_close(3)](https://elastic.github.io/quark/quark_queue_close.3.html) close a queue. @@ -346,7 +358,7 @@ close a queue. # [SEE ALSO](#SEE_ALSO) -[quark\_event\_dump(3)](https://elastic.github.io/quark/quark_event_dump.3.html), [quark\_process\_iter(3)](https://elastic.github.io/quark/quark_process_iter.3.html), [quark\_process\_lookup(3)](https://elastic.github.io/quark/quark_process_lookup.3.html), [quark\_queue\_block(3)](https://elastic.github.io/quark/quark_queue_block.3.html), [quark\_queue\_close(3)](https://elastic.github.io/quark/quark_queue_close.3.html), [quark\_queue\_get\_epollfd(3)](https://elastic.github.io/quark/quark_queue_get_epollfd.3.html), [quark\_queue\_get\_event(3)](https://elastic.github.io/quark/quark_queue_get_event.3.html), [quark\_queue\_get\_stats(3)](https://elastic.github.io/quark/quark_queue_get_stats.3.html), [quark\_queue\_open(3)](https://elastic.github.io/quark/quark_queue_open.3.html), [quark-btf(8)](https://elastic.github.io/quark/quark-btf.8.html), [quark-mon(8)](https://elastic.github.io/quark/quark-mon.8.html), [quark-test(8)](https://elastic.github.io/quark/quark-test.8.html) +[quark\_event\_dump(3)](https://elastic.github.io/quark/quark_event_dump.3.html), [quark\_get\_boottime(3)](https://elastic.github.io/quark/quark_get_boottime.3.html), [quark\_process\_iter(3)](https://elastic.github.io/quark/quark_process_iter.3.html), [quark\_process\_lookup(3)](https://elastic.github.io/quark/quark_process_lookup.3.html), [quark\_queue\_block(3)](https://elastic.github.io/quark/quark_queue_block.3.html), [quark\_queue\_close(3)](https://elastic.github.io/quark/quark_queue_close.3.html), [quark\_queue\_get\_epollfd(3)](https://elastic.github.io/quark/quark_queue_get_epollfd.3.html), [quark\_queue\_get\_event(3)](https://elastic.github.io/quark/quark_queue_get_event.3.html), [quark\_queue\_get\_stats(3)](https://elastic.github.io/quark/quark_queue_get_stats.3.html), [quark\_queue\_open(3)](https://elastic.github.io/quark/quark_queue_open.3.html), [quark\_time\_to\_wallclock(3)](https://elastic.github.io/quark/quark_time_to_wallclock.3.html), [quark\_update\_boottime(3)](https://elastic.github.io/quark/quark_update_boottime.3.html), [quark-btf(8)](https://elastic.github.io/quark/quark-btf.8.html), [quark-mon(8)](https://elastic.github.io/quark/quark-mon.8.html), [quark-test(8)](https://elastic.github.io/quark/quark-test.8.html) # [LICENSE](#LICENSE) diff --git a/docs/index.html b/docs/index.html index 56c8222a..cdccefeb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -412,6 +412,12 @@

block for an unspecified amount of time.
quark_queue_get_stats(3)
basic queue statistics.
+
quark_time_to_wallclock(3)
+
translate a time since boot to wallclock.
+
quark_update_boottime(3)
+
refetch the boottime epoch after a system clock change.
+
quark_get_boottime(3)
+
get the boottime epoch.
quark_queue_close(3)
close a queue.
@@ -430,6 +436,7 @@

quark_event_dump(3), + quark_get_boottime(3), quark_process_iter(3), quark_process_lookup(3), quark_queue_block(3), @@ -438,6 +445,8 @@

quark_queue_get_event(3), quark_queue_get_stats(3), quark_queue_open(3), + quark_time_to_wallclock(3), + quark_update_boottime(3), quark-btf(8), quark-mon(8), quark-test(8)

@@ -454,7 +463,7 @@

- +
June 16, 2025August 3, 2026 Linux
diff --git a/docs/quark.7.html b/docs/quark.7.html index 56c8222a..cdccefeb 100644 --- a/docs/quark.7.html +++ b/docs/quark.7.html @@ -412,6 +412,12 @@

block for an unspecified amount of time.
quark_queue_get_stats(3)
basic queue statistics.
+
quark_time_to_wallclock(3)
+
translate a time since boot to wallclock.
+
quark_update_boottime(3)
+
refetch the boottime epoch after a system clock change.
+
quark_get_boottime(3)
+
get the boottime epoch.
quark_queue_close(3)
close a queue.
@@ -430,6 +436,7 @@

quark_event_dump(3), + quark_get_boottime(3), quark_process_iter(3), quark_process_lookup(3), quark_queue_block(3), @@ -438,6 +445,8 @@

quark_queue_get_event(3), quark_queue_get_stats(3), quark_queue_open(3), + quark_time_to_wallclock(3), + quark_update_boottime(3), quark-btf(8), quark-mon(8), quark-test(8)

@@ -454,7 +463,7 @@

- +
June 16, 2025August 3, 2026 Linux
diff --git a/docs/quark_get_boottime.3.html b/docs/quark_get_boottime.3.html new file mode 100644 index 00000000..e763d058 --- /dev/null +++ b/docs/quark_get_boottime.3.html @@ -0,0 +1,84 @@ + + + + + + + QUARK_GET_BOOTTIME(3) + + + + + + + + +
QUARK_GET_BOOTTIME(3)Library Functions ManualQUARK_GET_BOOTTIME(3)
+
+
+

+

quark_get_boottime — + get the boottime epoch used for wallclock + translation

+
+
+

+

#include + <quark.h>

+

u64 +
+ quark_get_boottime(void);

+
+

+quark_get_boottime returns the internal boottime epoch: + the wallclock time of boot in nanoseconds since the Unix epoch, as fetched + from the btime field of /proc/stat. btime has a + resolution of one second. +

The epoch is fetched when the first queue is opened and refetched + only by + quark_update_boottime(3). + It is what + quark_time_to_wallclock(3) + adds to a time since boot, exposed for users that prefer to do the + translation themselves.

+
+

+

The boottime epoch in nanoseconds since the Unix epoch, zero if a + queue was never opened.

+
+
+

+

quark_event_dump(3), + quark_process_iter(3), + quark_process_lookup(3), + quark_queue_block(3), + quark_queue_close(3), + quark_queue_default_attr(3), + quark_queue_get_epollfd(3), + quark_queue_get_event(3), + quark_queue_get_stats(3), + quark_queue_open(3), + quark_time_to_wallclock(3), + quark_update_boottime(3), + quark(7), + quark-btf(8), + quark-mon(8), + quark-test(8)

+
+
+

+

quark_get_boottime appeared in quark 0.8, + when all times handed out by quark switched from nanoseconds since the Unix + epoch to nanoseconds since boot.

+
+
+ + + + + +
August 5, 2026Linux
+ + diff --git a/docs/quark_time_to_wallclock.3.html b/docs/quark_time_to_wallclock.3.html new file mode 100644 index 00000000..a1c621d2 --- /dev/null +++ b/docs/quark_time_to_wallclock.3.html @@ -0,0 +1,95 @@ + + + + + + + QUARK_TIME_TO_WALLCLOCK(3) + + + + + + + + +
QUARK_TIME_TO_WALLCLOCK(3)Library Functions ManualQUARK_TIME_TO_WALLCLOCK(3)
+
+
+

+

quark_time_to_wallclock — + translate a time since boot to wallclock

+
+
+

+

#include + <quark.h>

+

u64 +
+ quark_time_to_wallclock(u64 + time_since_boot);

+
+

+quark_time_to_wallclock translates + time_since_boot from nanoseconds since boot to + nanoseconds since the Unix epoch by adding the internal boottime epoch, see + quark_get_boottime(3). +

All times handed out by quark are suitable inputs: + of + quark_event, + + and + + of quark_process, as well as + + and + + of quark_socket. These fields are expressed as + nanoseconds since boot since quark 0.8, in earlier versions they were + nanoseconds since the Unix epoch and needed no translation.

+

Times since boot are immune to system clock changes, wallclock + times are not. Translate at the last moment, when a time leaves the system + for display or storage, and keep the epoch fresh with + quark_update_boottime(3) + if the clock may be stepped while running.

+
+

+

time_since_boot expressed in nanoseconds + since the Unix epoch.

+
+
+

+

quark_event_dump(3), + quark_get_boottime(3), + quark_process_iter(3), + quark_process_lookup(3), + quark_queue_block(3), + quark_queue_close(3), + quark_queue_default_attr(3), + quark_queue_get_epollfd(3), + quark_queue_get_event(3), + quark_queue_get_stats(3), + quark_queue_open(3), + quark_update_boottime(3), + quark(7), + quark-btf(8), + quark-mon(8), + quark-test(8)

+
+
+

+

quark_time_to_wallclock appeared in quark + 0.8, when all times handed out by quark switched from nanoseconds since the + Unix epoch to nanoseconds since boot.

+
+
+ + + + + +
August 5, 2026Linux
+ + diff --git a/docs/quark_update_boottime.3.html b/docs/quark_update_boottime.3.html new file mode 100644 index 00000000..dd707fcc --- /dev/null +++ b/docs/quark_update_boottime.3.html @@ -0,0 +1,107 @@ + + + + + + + QUARK_UPDATE_BOOTTIME(3) + + + + + + + + +
QUARK_UPDATE_BOOTTIME(3)Library Functions ManualQUARK_UPDATE_BOOTTIME(3)
+
+
+

+

quark_update_boottime — + refetch the boottime epoch used for wallclock + translation

+
+
+

+

#include + <quark.h>

+

int +
+ quark_update_boottime(void);

+
+

+All times handed out by quark are expressed in nanoseconds since boot: + of + quark_event, + + and + + of quark_process, as well as + + and + + of quark_socket. Translation to wallclock is done at the + last moment via + quark_time_to_wallclock(3), + which adds an internal boottime epoch: the wallclock time of boot, fetched + from the btime field of /proc/stat when the first + queue is opened. +

btime is derived from the current system clock, so it moves if the + clock is stepped, as when NTP corrects a clock that was wrong at boot. Since + quark has no event loop, it can not detect a step on its own: the user + should call quark_update_boottime, which refetches + btime, whenever the clock might have changed. As quark never bakes the epoch + into the times it stores or hands out, an update also corrects the + translation of times acquired before the step.

+

Two common ways of detecting a step:

+ +
+

+

Returns 0 on success, -1 if btime could not be refetched, in which + case the previous epoch is retained and errno is + set.

+
+
+

+

quark_event_dump(3), + quark_get_boottime(3), + quark_process_iter(3), + quark_process_lookup(3), + quark_queue_block(3), + quark_queue_close(3), + quark_queue_default_attr(3), + quark_queue_get_epollfd(3), + quark_queue_get_event(3), + quark_queue_get_stats(3), + quark_queue_open(3), + quark_time_to_wallclock(3), + quark(7), + quark-btf(8), + quark-mon(8), + quark-test(8)

+
+
+

+

quark_update_boottime appeared in quark + 0.8, when all times handed out by quark switched from nanoseconds since the + Unix epoch to nanoseconds since boot.

+
+
+ + + + + +
August 5, 2026Linux
+ + diff --git a/quark.7 b/quark.7 index 67004226..20916cf6 100644 --- a/quark.7 +++ b/quark.7 @@ -454,6 +454,12 @@ get a descriptor suitable for blocking. block for an unspecified amount of time. .It Xr quark_queue_get_stats 3 basic queue statistics. +.It Xr quark_time_to_wallclock 3 +translate a time since boot to wallclock. +.It Xr quark_update_boottime 3 +refetch the boottime epoch after a system clock change. +.It Xr quark_get_boottime 3 +get the boottime epoch. .It Xr quark_queue_close 3 close a queue. .El @@ -469,6 +475,7 @@ is the easiest way to get started with describes initialization options that can be useful. .Sh SEE ALSO .Xr quark_event_dump 3 , +.Xr quark_get_boottime 3 , .Xr quark_process_iter 3 , .Xr quark_process_lookup 3 , .Xr quark_queue_block 3 , @@ -477,6 +484,8 @@ describes initialization options that can be useful. .Xr quark_queue_get_event 3 , .Xr quark_queue_get_stats 3 , .Xr quark_queue_open 3 , +.Xr quark_time_to_wallclock 3 , +.Xr quark_update_boottime 3 , .Xr quark-btf 8 , .Xr quark-mon 8 , .Xr quark-test 8 diff --git a/quark_get_boottime.3 b/quark_get_boottime.3 new file mode 100644 index 00000000..149acc98 --- /dev/null +++ b/quark_get_boottime.3 @@ -0,0 +1,48 @@ +.Dd $Mdocdate$ +.Dt QUARK_GET_BOOTTIME 3 +.Os +.Sh NAME +.Nm quark_get_boottime +.Nd get the boottime epoch used for wallclock translation +.Sh SYNOPSIS +.In quark.h +.Ft u64 +.Fn quark_get_boottime "void" +.Sh DESCRIPTION +.Nm +returns the internal boottime epoch: the wallclock time of boot in +nanoseconds since the Unix epoch, as fetched from the btime field of +.Pa /proc/stat . +btime has a resolution of one second. +.Pp +The epoch is fetched when the first queue is opened and refetched only +by +.Xr quark_update_boottime 3 . +It is what +.Xr quark_time_to_wallclock 3 +adds to a time since boot, exposed for users that prefer to do the +translation themselves. +.Sh RETURN VALUES +The boottime epoch in nanoseconds since the Unix epoch, zero if a +queue was never opened. +.Sh SEE ALSO +.Xr quark_event_dump 3 , +.Xr quark_process_iter 3 , +.Xr quark_process_lookup 3 , +.Xr quark_queue_block 3 , +.Xr quark_queue_close 3 , +.Xr quark_queue_default_attr 3 , +.Xr quark_queue_get_epollfd 3 , +.Xr quark_queue_get_event 3 , +.Xr quark_queue_get_stats 3 , +.Xr quark_queue_open 3 , +.Xr quark_time_to_wallclock 3 , +.Xr quark_update_boottime 3 , +.Xr quark 7 , +.Xr quark-btf 8 , +.Xr quark-mon 8 , +.Xr quark-test 8 +.Sh HISTORY +.Nm +appeared in quark 0.8, when all times handed out by quark switched +from nanoseconds since the Unix epoch to nanoseconds since boot. diff --git a/quark_time_to_wallclock.3 b/quark_time_to_wallclock.3 new file mode 100644 index 00000000..72f4e1a2 --- /dev/null +++ b/quark_time_to_wallclock.3 @@ -0,0 +1,67 @@ +.Dd $Mdocdate$ +.Dt QUARK_TIME_TO_WALLCLOCK 3 +.Os +.Sh NAME +.Nm quark_time_to_wallclock +.Nd translate a time since boot to wallclock +.Sh SYNOPSIS +.In quark.h +.Ft u64 +.Fn quark_time_to_wallclock "u64 time_since_boot" +.Sh DESCRIPTION +.Nm +translates +.Fa time_since_boot +from nanoseconds since boot to nanoseconds since the Unix epoch by +adding the internal boottime epoch, see +.Xr quark_get_boottime 3 . +.Pp +All times handed out by quark are suitable inputs: +.Em time +of +.Vt quark_event , +.Em proc_time_boot +and +.Em exit_time_event +of +.Vt quark_process , +as well as +.Em established_time +and +.Em close_time +of +.Vt quark_socket . +These fields are expressed as nanoseconds since boot since quark 0.8, +in earlier versions they were nanoseconds since the Unix epoch and +needed no translation. +.Pp +Times since boot are immune to system clock changes, wallclock times +are not. +Translate at the last moment, when a time leaves the system for +display or storage, and keep the epoch fresh with +.Xr quark_update_boottime 3 +if the clock may be stepped while running. +.Sh RETURN VALUES +.Fa time_since_boot +expressed in nanoseconds since the Unix epoch. +.Sh SEE ALSO +.Xr quark_event_dump 3 , +.Xr quark_get_boottime 3 , +.Xr quark_process_iter 3 , +.Xr quark_process_lookup 3 , +.Xr quark_queue_block 3 , +.Xr quark_queue_close 3 , +.Xr quark_queue_default_attr 3 , +.Xr quark_queue_get_epollfd 3 , +.Xr quark_queue_get_event 3 , +.Xr quark_queue_get_stats 3 , +.Xr quark_queue_open 3 , +.Xr quark_update_boottime 3 , +.Xr quark 7 , +.Xr quark-btf 8 , +.Xr quark-mon 8 , +.Xr quark-test 8 +.Sh HISTORY +.Nm +appeared in quark 0.8, when all times handed out by quark switched +from nanoseconds since the Unix epoch to nanoseconds since boot. diff --git a/quark_update_boottime.3 b/quark_update_boottime.3 new file mode 100644 index 00000000..f81535ef --- /dev/null +++ b/quark_update_boottime.3 @@ -0,0 +1,87 @@ +.Dd $Mdocdate$ +.Dt QUARK_UPDATE_BOOTTIME 3 +.Os +.Sh NAME +.Nm quark_update_boottime +.Nd refetch the boottime epoch used for wallclock translation +.Sh SYNOPSIS +.In quark.h +.Ft int +.Fn quark_update_boottime "void" +.Sh DESCRIPTION +All times handed out by quark are expressed in nanoseconds since boot: +.Em time +of +.Vt quark_event , +.Em proc_time_boot +and +.Em exit_time_event +of +.Vt quark_process , +as well as +.Em established_time +and +.Em close_time +of +.Vt quark_socket . +Translation to wallclock is done at the last moment via +.Xr quark_time_to_wallclock 3 , +which adds an internal boottime epoch: the wallclock time of boot, +fetched from the btime field of +.Pa /proc/stat +when the first queue is opened. +.Pp +btime is derived from the current system clock, so it moves if the +clock is stepped, as when NTP corrects a clock that was wrong at boot. +Since quark has no event loop, it can not detect a step on its own: +the user should call +.Nm , +which refetches btime, whenever the clock might have changed. +As quark never bakes the epoch into the times it stores or hands out, +an update also corrects the translation of times acquired before the +step. +.Pp +Two common ways of detecting a step: +.Bl -bullet +.It +Poll the delta of +.Dv CLOCK_REALTIME +minus +.Dv CLOCK_BOOTTIME : +slewing adjusts both clocks at the same rate, so the delta only moves +when the clock is stepped. +.It +Wait on a +.Xr timerfd_create 2 +descriptor of +.Dv CLOCK_REALTIME +armed with +.Dv TFD_TIMER_CANCEL_ON_SET , +which becomes readable when the clock is stepped. +.El +.Sh RETURN VALUES +Returns 0 on success, -1 if btime could not be refetched, in which +case the previous epoch is retained and +.Va errno +is set. +.Sh SEE ALSO +.Xr quark_event_dump 3 , +.Xr quark_get_boottime 3 , +.Xr quark_process_iter 3 , +.Xr quark_process_lookup 3 , +.Xr quark_queue_block 3 , +.Xr quark_queue_close 3 , +.Xr quark_queue_default_attr 3 , +.Xr quark_queue_get_epollfd 3 , +.Xr quark_queue_get_event 3 , +.Xr quark_queue_get_stats 3 , +.Xr quark_queue_open 3 , +.Xr quark_time_to_wallclock 3 , +.Xr quark 7 , +.Xr quark-btf 8 , +.Xr quark-mon 8 , +.Xr quark-test 8 +.Sh HISTORY +.Nm +appeared in quark 0.8, when all times handed out by quark switched +from nanoseconds since the Unix epoch to nanoseconds since boot. From adbdacf6187e01b8f2c15e5a335f25b7d8afb3f4 Mon Sep 17 00:00:00 2001 From: Nicholas Berlin Date: Fri, 14 Aug 2026 12:59:53 -0400 Subject: [PATCH 2/4] Document thread-safety of the boottime calls The boottime epoch is process-wide, shared by every queue, and auditbeat updates it from one thread while others translate timestamps, which no caller-side lock can span. State explicitly that quark_update_boottime(), quark_get_boottime() and quark_time_to_wallclock() may be called from any thread without synchronization, as an exception to the queue synchronization convention in quark(7). Only true once the boottime-atomics branch merges, which makes the epoch access atomic. --- README.md | 2 +- docs/index.html | 9 +++++++-- docs/quark.7.html | 9 +++++++-- docs/quark_update_boottime.3.html | 9 ++++++++- quark.7 | 6 ++++++ quark_update_boottime.3 | 9 +++++++++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bbdca317..53609136 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ These scripts require KVM access and therefore must be executed on a host kernel - Library calls fail with -1 unless otherwise stated, and `errno` is set. - Quark returns pointers to internal state, which must not be modified and/or stored. In the case of multithreading, these pointers should not be accessed if another thread is driving quark through [quark\_queue\_get\_event(3)](https://elastic.github.io/quark/quark_queue_get_event.3.html). - No threads are created, the library is driven solely through [quark\_queue\_get\_event(3)](https://elastic.github.io/quark/quark_queue_get_event.3.html). -- Access to a `quark_queue` must be synchronized by the user in the case of multithreading. +- Access to a `quark_queue` must be synchronized by the user in the case of multithreading. The boottime epoch is the exception: [quark\_update\_boottime(3)](https://elastic.github.io/quark/quark_update_boottime.3.html), [quark\_get\_boottime(3)](https://elastic.github.io/quark/quark_get_boottime.3.html) and [quark\_time\_to\_wallclock(3)](https://elastic.github.io/quark/quark_time_to_wallclock.3.html) may be called from any thread without synchronization. # [BASIC USAGE](#BASIC_USAGE) diff --git a/docs/index.html b/docs/index.html index cdccefeb..270f8763 100644 --- a/docs/index.html +++ b/docs/index.html @@ -335,7 +335,12 @@

  • quark_queue_get_event(3).
  • Access to a quark_queue must be synchronized by the - user in the case of multithreading.
  • + user in the case of multithreading. The boottime epoch is the exception: + quark_update_boottime(3), + quark_get_boottime(3) + and + quark_time_to_wallclock(3) + may be called from any thread without synchronization.
    @@ -463,7 +468,7 @@

    - +
    August 3, 2026August 14, 2026 Linux
    diff --git a/docs/quark.7.html b/docs/quark.7.html index cdccefeb..270f8763 100644 --- a/docs/quark.7.html +++ b/docs/quark.7.html @@ -335,7 +335,12 @@

  • quark_queue_get_event(3).
  • Access to a quark_queue must be synchronized by the - user in the case of multithreading.
  • + user in the case of multithreading. The boottime epoch is the exception: + quark_update_boottime(3), + quark_get_boottime(3) + and + quark_time_to_wallclock(3) + may be called from any thread without synchronization.

    @@ -463,7 +468,7 @@

    - +
    August 3, 2026August 14, 2026 Linux
    diff --git a/docs/quark_update_boottime.3.html b/docs/quark_update_boottime.3.html index dd707fcc..4b813d51 100644 --- a/docs/quark_update_boottime.3.html +++ b/docs/quark_update_boottime.3.html @@ -63,6 +63,13 @@

    quark_get_boottime(3) and + quark_time_to_wallclock(3) + may be called from any thread without synchronization: the epoch is updated + atomically and a concurrent reader observes either the previous or the new + value.

    @@ -99,7 +106,7 @@

    - +
    August 5, 2026August 14, 2026 Linux
    diff --git a/quark.7 b/quark.7 index 20916cf6..97489df8 100644 --- a/quark.7 +++ b/quark.7 @@ -379,6 +379,12 @@ No threads are created, the library is driven solely through Access to a .Vt quark_queue must be synchronized by the user in the case of multithreading. +The boottime epoch is the exception: +.Xr quark_update_boottime 3 , +.Xr quark_get_boottime 3 +and +.Xr quark_time_to_wallclock 3 +may be called from any thread without synchronization. .El .Sh BASIC USAGE The ball starts with diff --git a/quark_update_boottime.3 b/quark_update_boottime.3 index f81535ef..fc2eeb4b 100644 --- a/quark_update_boottime.3 +++ b/quark_update_boottime.3 @@ -59,6 +59,15 @@ armed with .Dv TFD_TIMER_CANCEL_ON_SET , which becomes readable when the clock is stepped. .El +.Pp +The boottime epoch is shared by every queue in the process. +.Nm , +.Xr quark_get_boottime 3 +and +.Xr quark_time_to_wallclock 3 +may be called from any thread without synchronization: +the epoch is updated atomically and a concurrent reader observes +either the previous or the new value. .Sh RETURN VALUES Returns 0 on success, -1 if btime could not be refetched, in which case the previous epoch is retained and From 6d114fa5357088177c0f1d0c4efd480faa9a23a6 Mon Sep 17 00:00:00 2001 From: Nicholas Berlin Date: Fri, 14 Aug 2026 16:15:39 -0400 Subject: [PATCH 3/4] Document wallclock translation on QQ_MONOTONIC queues The kprobe backend stamps times with a monotonic clock that does not advance during suspend. quark_time_to_wallclock() applies unchanged, but the result lags the wallclock by the total suspended time, exactly as it did before 0.8. Spell this out in quark_time_to_wallclock(3) and point QQ_MONOTONIC in quark_queue_open(3) at it, so kprobe users know the boottime calls treat both backends the same and how to compensate if they care about suspend. --- docs/quark_queue_open.3.html | 6 ++++-- docs/quark_time_to_wallclock.3.html | 13 ++++++++++++- quark_queue_open.3 | 3 +++ quark_time_to_wallclock.3 | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/docs/quark_queue_open.3.html b/docs/quark_queue_open.3.html index e66c27bd..12e96e59 100644 --- a/docs/quark_queue_open.3.html +++ b/docs/quark_queue_open.3.html @@ -94,7 +94,9 @@

    quark_time_to_wallclock(3) + for the effect on wallclock translation.
    Include per-thread events, instead of per-process events. This option will be removed in the future, but it may be useful for @@ -170,7 +172,7 @@

    quark_update_boottime(3) if the clock may be stepped while running.

    +

    The KPROBE backend stamps times with a monotonic clock + that does not advance during suspend, relayed as + QQ_MONOTONIC on the opened queue's + , see + quark_queue_open(3). + quark_time_to_wallclock applies unchanged, but the + result lags the wallclock by the total suspended time, exactly as it did + before quark 0.8. Users that care about suspend can detect + QQ_MONOTONIC and compensate with the difference + between CLOCK_BOOTTIME and + CLOCK_MONOTONIC.

    @@ -87,7 +98,7 @@

    - +
    August 5, 2026August 14, 2026 Linux
    diff --git a/quark_queue_open.3 b/quark_queue_open.3 index 3626bad6..ba2e6ebd 100644 --- a/quark_queue_open.3 +++ b/quark_queue_open.3 @@ -101,6 +101,9 @@ when its event times are CLOCK_MONOTONIC instead of CLOCK_BOOTTIME, which only the KPROBE backend does. Monotonic times undercount by the total suspended time, users that care about suspend must compensate. +See +.Xr quark_time_to_wallclock 3 +for the effect on wallclock translation. .It Dv QQ_THREAD_EVENTS Include per-thread events, instead of per-process events. This option will be removed in the future, but it may be useful for debugging. diff --git a/quark_time_to_wallclock.3 b/quark_time_to_wallclock.3 index 72f4e1a2..4fe4c972 100644 --- a/quark_time_to_wallclock.3 +++ b/quark_time_to_wallclock.3 @@ -41,6 +41,23 @@ Translate at the last moment, when a time leaves the system for display or storage, and keep the epoch fresh with .Xr quark_update_boottime 3 if the clock may be stepped while running. +.Pp +The KPROBE backend stamps times with a monotonic clock that does not +advance during suspend, relayed as +.Dv QQ_MONOTONIC +on the opened queue's +.Em flags , +see +.Xr quark_queue_open 3 . +.Nm +applies unchanged, but the result lags the wallclock by the total +suspended time, exactly as it did before quark 0.8. +Users that care about suspend can detect +.Dv QQ_MONOTONIC +and compensate with the difference between +.Dv CLOCK_BOOTTIME +and +.Dv CLOCK_MONOTONIC . .Sh RETURN VALUES .Fa time_since_boot expressed in nanoseconds since the Unix epoch. From b639b7bf8d65d51fea0fb9952d6ef46cd7dfb2be Mon Sep 17 00:00:00 2001 From: Nicholas Berlin Date: Fri, 14 Aug 2026 16:31:08 -0400 Subject: [PATCH 4/4] Contrast slewing with steps in quark_time_to_wallclock(3) Review feedback: make explicit which clock problem the epoch refresh solves. Slewing adjusts the wallclock and the boot clock at the same rate so the epoch never moves, only a step does. --- docs/quark_time_to_wallclock.3.html | 4 +++- quark_time_to_wallclock.3 | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/quark_time_to_wallclock.3.html b/docs/quark_time_to_wallclock.3.html index a64bfff7..fec2d0ff 100644 --- a/docs/quark_time_to_wallclock.3.html +++ b/docs/quark_time_to_wallclock.3.html @@ -51,7 +51,9 @@

    quark_update_boottime(3) - if the clock may be stepped while running.

    + if the clock may be stepped while running. Gradual corrections (slewing) + adjust the wallclock and the boot clock at the same rate, leaving the epoch + untouched, only a step moves it.

    The KPROBE backend stamps times with a monotonic clock that does not advance during suspend, relayed as QQ_MONOTONIC on the opened queue's diff --git a/quark_time_to_wallclock.3 b/quark_time_to_wallclock.3 index 4fe4c972..fee8e558 100644 --- a/quark_time_to_wallclock.3 +++ b/quark_time_to_wallclock.3 @@ -41,6 +41,8 @@ Translate at the last moment, when a time leaves the system for display or storage, and keep the epoch fresh with .Xr quark_update_boottime 3 if the clock may be stepped while running. +Gradual corrections (slewing) adjust the wallclock and the boot clock +at the same rate, leaving the epoch untouched, only a step moves it. .Pp The KPROBE backend stamps times with a monotonic clock that does not advance during suspend, relayed as