ktime_get_real_seconds(9)
π ktime_get_real_seconds β kernel API manual, bestie edition π
okay so this one's a little function from the kernel API manual (ktime_get_real_seconds(9)) and honestly? she's lowkey iconic for how much she does with so little. let's get into it π«Ά
β¨ NAME β¨
ktime_get_real_seconds β bestie, all she does is get the seconds portion of CLOCK_REALTIME and honestly that's enough π
πΈ SYNOPSIS πΈ
time64_t ktime_get_real_seconds (void );
look at her. no mess. no drama. just a time64_t coming back at you π
π¦ ARGUMENTS π¦
voidβ no arguments. none. zero. she takes nothing from you, she just gives π literally the healthiest relationship in the whole kernel fr fr
π DESCRIPTION π
okay so what she returns is the wall clock seconds since 1970. that's it, that's the whole vibe. epoch-based, seconds-only, no nanoseconds crumbs left on the table β
now here's where the architecture tea gets real π΅:
- on 64bit systems the fast access to
tk->xtime_secis preserved β she just goes straight in there, no cap, main character energy β¨ - on 32bit systems the access must be protected with the sequence counter to provide "atomic" access to the 64bit
tk->xtime_secvalue. yes, "atomic" in quotes β that's the manpage's quotes, not mine, and you should respect them π
so if you're on 32bit, please don't go reading tk->xtime_sec raw like it's a public feed. she needs her sequence counter. it's giving "locked door for a reason" π
π SEE ALSO π
the whole friend group, and I mean the whole friend group β she does not show up alone π
the kernel file ./kernel/time/timekeeping.c plus:
struct tk_fast(9)tk_setup_internals(9)update_fast_timekeeper(9)ktime_get_mono_fast_ns(9)ktime_get_raw_fast_ns(9)ktime_get_boot_fast_ns(9)ktime_get_tai_fast_ns(9)ktime_get_real_fast_ns(9)halt_fast_timekeeper(9)pvclock_gtod_register_notifier(9)pvclock_gtod_unregister_notifier(9)timekeeping_forward_now(9)ktime_get_real_ts64(9)ktime_mono_to_any(9)ktime_get_raw(9)ktime_get_ts64(9)ktime_get_seconds(9)__ktime_get_real_seconds(9)ktime_get_snapshot_id(9)adjust_historical_crosststamp(9)ktime_real_to_base_clock(9)get_device_system_crosststamp(9)timekeeping_clocksource_has_base(9)do_settimeofday64(9)__timekeeping_inject_offset(9)timekeeping_notify(9)ktime_get_raw_ts64(9)timekeeping_valid_for_hres(9)timekeeping_max_deferment(9)read_persistent_clock64(9)read_persistent_wall_and_boot_offset(9)__timekeeping_inject_sleeptime(9)timekeeping_inject_sleeptime64(9)timekeeping_resume(9)update_wall_time(9)getboottime64(9)ktime_get_coarse_real_ts64_mg(9)ktime_get_real_ts64_mg(9)ktime_get_update_offsets_now(9)random_get_entropy_fallback(9)do_adjtimex(9)hardpps(9)ktime_get_aux(9)ktime_get_aux_ts64(9)
like I said. the whole group chat. π
and that's the whole page, bestie β no crumbs left behind π this lil drop came out of ./kernel/time in October 2026, and it's filed under ktime_get_real_seconds(9) forever and ever. go forth and get those seconds ππ
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms