From: George Anzinger The time conversion code is erroring on the side of a bit too small. The attached patch forces any error to be on the high side. The current code will convert 1 nanosecond to zero jiffies (standard says that should be 1). It also is around 1 nanosecond late on each roll to the next jiffie. I have done some error checks with this patch applied and get the following errors in PPB ( Parts Per Billion): HZ nano sec conversion microsecond conversion 1000 315 45 1024 227 40 100 28 317 In all cases the error is on the high side, which means that the final shift will, most likely, eliminate the error bits. --- 25-akpm/include/linux/time.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff -puN include/linux/time.h~time-rounding-accuracy include/linux/time.h --- 25/include/linux/time.h~time-rounding-accuracy Tue Jan 27 12:45:38 2004 +++ 25-akpm/include/linux/time.h Tue Jan 27 12:45:38 2004 @@ -148,14 +148,14 @@ struct timezone { #endif #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29) #define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19) -#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC))\ - / (u64)TICK_NSEC)) +#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\ + TICK_NSEC -1) / (u64)TICK_NSEC)) -#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC))\ - / (u64)TICK_NSEC)) +#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\ + TICK_NSEC -1) / (u64)TICK_NSEC)) #define USEC_CONVERSION \ - ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC)) \ - / (u64)TICK_NSEC)) + ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\ + TICK_NSEC -1) / (u64)TICK_NSEC)) /* * USEC_ROUND is used in the timeval to jiffie conversion. See there * for more details. It is the scaled resolution rounding value. Note _