timespec64_to_jiffies(9)
β¨ 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 tostruct 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:
jiffies_to_msecs(9)jiffies_to_usecs(9)mktime64(9)set_normalized_timespec64(9)ns_to_timespec64(9)__msecs_to_jiffies(9)__usecs_to_jiffies(9)jiffies_to_timespec64(9)jiffies_to_clock_t(9)clock_t_to_jiffies(9)jiffies_64_to_clock_t(9)nsec_to_clock_t(9)jiffies64_to_nsecs(9)jiffies64_to_msecs(9)nsecs_to_jiffies64(9)nsecs_to_jiffies(9)timespec64_add_safe(9)get_timespec64(9)put_timespec64(9)get_old_timespec32(9)put_old_timespec32(9)get_itimerspec64(9)put_itimerspec64(9)get_old_itimerspec32(9)put_old_itimerspec32(9)
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
- 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