diff --git a/README.md b/README.md index e87b74a3..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) @@ -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..270f8763 100644 --- a/docs/index.html +++ b/docs/index.html @@ -335,7 +335,12 @@
quark_event_dump(3), + quark_get_boottime(3), quark_process_iter(3), quark_process_lookup(3), quark_queue_block(3), @@ -438,6 +450,8 @@
| June 16, 2025 | +August 14, 2026 | Linux |
quark_event_dump(3), + quark_get_boottime(3), quark_process_iter(3), quark_process_lookup(3), quark_queue_block(3), @@ -438,6 +450,8 @@
| June 16, 2025 | +August 14, 2026 | Linux |
| QUARK_GET_BOOTTIME(3) | +Library Functions Manual | +QUARK_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, 2026 | +Linux | +
QQ_THREAD_EVENTS| August 6, 2026 | +August 14, 2026 | Linux |
| QUARK_TIME_TO_WALLCLOCK(3) | +Library Functions Manual | +QUARK_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: + time of + quark_event, + proc_time_boot + and + exit_time_event + of quark_process, as well as + established_time + and + close_time + 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. 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
+ flags, 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.
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 14, 2026 | +Linux | +
| QUARK_UPDATE_BOOTTIME(3) | +Library Functions Manual | +QUARK_UPDATE_BOOTTIME(3) | +
quark_update_boottime —
+ refetch the boottime epoch used for wallclock
+ translation
#include
+ <quark.h>
int
+
+ quark_update_boottime(void);
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:
+CLOCK_REALTIME minus
+ CLOCK_BOOTTIME: slewing adjusts both clocks at the
+ same rate, so the delta only moves when the clock is stepped.CLOCK_REALTIME armed with
+ TFD_TIMER_CANCEL_ON_SET, which becomes readable
+ when the clock is stepped.The boottime epoch is shared by every queue in the process.
+ quark_update_boottime,
+ 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.
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 14, 2026 | +Linux | +