timespec64_to_jiffies(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ timespec64_to_jiffies(9) ✨

okay bestie, so this is a page straight out of the Kernel API Manual β€” yes the real one, the timespec64_to_jiffies(9) one πŸ’… β€” and it's literally just about turning a timespec64 into jiffies. that's it. that's the whole vibe. let's get into it πŸŽ€


🌸 NAME 🌸

timespec64_to_jiffies β€” convert a timespec64 value to jiffies πŸ¦‹


✨ SYNOPSIS ✨

unsigned long timespec64_to_jiffies (const struct timespec64 *value );

πŸ“ ARGUMENTS πŸ“

  • value β€” pointer to struct timespec64. that's your input, bestie, it's a pointer, don't forget the * πŸ™ˆ

πŸ’– DESCRIPTION πŸ’–

so like, the TICK_NSEC - 1 rounds the value up to the next resolution. that's the whole trick ✨

and listen β€” a remainder subtract here would NOT do the right thing, because the resolution values don't fall on second boundaries. so like, this line:

nsec -= nsec % TICK_NSEC;

is NOT a correct resolution rounding. periodt. πŸ’€

also quick heads up: because of the small error in the multiplier here, this rounding is incorrect for sufficiently large values of tv_nsec β€” but well formed timespecs should have tv_nsec < NSEC_PER_SEC, so we're OK 🫢 (vibe check passed, ngl).

rather, we just shift the bits off the right πŸ‘‘

and the >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) is what converts the scaled nsec value to a scaled second value. that's the conversion, lowkey iconic 🌈


πŸ”₯ RETURN πŸ”₯

jiffies value ⭐


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./kernel/time/time.c, plus the whole friend group:


and that's the whole page, bestie 🧚 go convert some timespecs, you got this πŸ’œ

this one lives in ./kernel/time and it's the October 2026 edition of the Kernel API Manual β€” mwah, catch you in the next manpage πŸ’‹πŸ’–
πŸ“¦ where this page comes from