Nasty suprise with uptime
Review
Quoted 8 lines · Tim Schmielau
(quoted diff) +8
-0+ static unsigned long jiffies_hi = 0; + static unsigned long jiffies_last = INITIAL_JIFFIES; + unsigned long jiffies_tmp; + + jiffies_tmp = jiffies; /* avoid races */ + if (jiffies_tmp < jiffies_last) /* We have a wrap */ + jiffies_hi++; + jiffies_last = jiffies_tmp;
There is very small race - if two processes will call get_jiffies64() at same time, they can both happen to test jiffies_tmp < jiffies_last with old jiffies_last - incrementing jiffies_hi twice :-( This race window is only few microseconds every 497 days, but if we want correct kernel...
Best regards,
Petr Vandrovec [email protected]