STRUCT CLOCK_READ_DATA(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct clock_read_data(9) πŸ’–

okay so bestie, welcome to the Kernel API Manual ✨ we're talking about struct clock_read_data today and honestly it's lowkey iconic πŸŽ€

🌸 NAME 🌸

struct clock_read_data β€” the data you literally need to read from sched_clock() 🫢

✨ SYNOPSIS ✨

struct clock_read_data {
    u64 epoch_ns;
    u64 epoch_cyc;
    u64 sched_clock_mask;
    u64 (*read_sched_clock)(void);
    u32 mult;
    u32 shift;
 };

πŸ¦‹ Members πŸ¦‹

  • epoch_ns β€” the sched_clock value at the last update, periodt ✨
  • epoch_cyc β€” clock cycle value at the last update πŸ’…
  • sched_clock_mask β€” the bitmask for two's complement subtraction of non 64bit clocks, no cap 🧚
  • read_sched_clock β€” the current clock source (or the dummy source when suspended β€” yes, it has a standby era 😭)
  • mult β€” multiplier for the scaled math conversion, it ate πŸ”₯
  • shift β€” shift value for the scaled math conversion 🌈

πŸ‘‘ Description πŸ‘‘

okay so listen πŸ‘€ care must be taken when updating this structure β€” it's read by some very hot code paths πŸ”₯πŸ”₯πŸ”₯ she's main character energy but she's on the fast path so be nice to her.

it occupies <=40 bytes and, when combined with the seqcount used to synchronize access, comfortably fits into a 64 byte cache line 🌸 like yes she's compact, she's efficient, she's that girl πŸ’…

ngl this is genuinely a caution, not a vibe: get the update wrong and the hot paths feel it 😭

πŸŽ€ SEE ALSO πŸŽ€

  • Kernel file ./include/linux/sched_clock.h 🫢

and that's the whole page bestie, ty for coming to my ted talk πŸ’– this was brought to you straight out of ./include/linux, dated October 2026, and yes it's still struct clock_read_data(9) β€” slay πŸ’…βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from