timecounter_cyc2time(9)
β¨ timecounter_cyc2time β Kernel API Manual β¨
okay bestie, welcome to timecounter_cyc2time(9) π this is the little Kernel API Manual page that teaches you how to turn a cycle counter reading into the same time base as the values timecounter_read() gives you. it's giving "time travel but make it nanoseconds" π°οΈβ¨
πΈ NAME πΈ
timecounter_cyc2time β convert a cycle counter to same time base as values returned by timecounter_read()
like literally, that's the whole job. it takes a cycle count and lines it up with the same clock vibe as timecounter_read()'s output π«Ά
π SYNOPSIS π
u64 timecounter_cyc2time (const struct timecounter *tc , u64
cycle_tstamp );
that's the signature, copy it exactly, no cap π
π« ARGUMENTS π«
tcβ Pointer to time counter. that's yourconst struct timecounter *, the main character of this whole operation πcycle_tstampβ a value returned bytc->cc->read. yes, exactly that, don't improvise π
π₯ DESCRIPTION π₯
so here's the tea β cycle counts that are converted correctly as long as they fall into the interval [-1/2 max cycle count, +1/2 max cycle count], with "max cycle count" == cs->mask+1.
read that again, because the range is the whole plot twist π it's centered on zero, half the max in each direction, cs->mask+1 wide in total.
and why do we care? because this allows conversion of cycle counter values which were generated in the past. like, values from before the initial time stamp. retroactive glow-up β¨ this is literally the function's whole personality.
β RETURN β
cycle counter converted to nanoseconds since the initial time stamp π
yep. nanoseconds. since the initial time stamp. that's the return value, an u64, no cap π«Ά
π¦ SEE ALSO π¦
- Kernel file
./include/linux/timecounter.h struct cyclecounter(9)struct timecounter(9)cyclecounter_cyc2ns(9)timecounter_adjtime(9)timecounter_init(9)timecounter_read(9)
go read the whole squad, they're all iconic π
that's the page bestie!! every flag, every value, every path β all of it, untouched, just with way more sparkle ππ
signed off with love from the ./include/linux directory, vintage October 2026, source/version timecounter_cyc2time(9) β mwah π
π¦ 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