Commit 03718ae0 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fine tune the time conversion to eliminate conversion errors.

From: George Anzinger <george@mvista.com>

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.
parent 80cfa786
...@@ -148,14 +148,14 @@ struct timezone { ...@@ -148,14 +148,14 @@ struct timezone {
#endif #endif
#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29) #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19) #define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC))\ #define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\
/ (u64)TICK_NSEC)) TICK_NSEC -1) / (u64)TICK_NSEC))
#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC))\ #define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\
/ (u64)TICK_NSEC)) TICK_NSEC -1) / (u64)TICK_NSEC))
#define USEC_CONVERSION \ #define USEC_CONVERSION \
((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC)) \ ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\
/ (u64)TICK_NSEC)) TICK_NSEC -1) / (u64)TICK_NSEC))
/* /*
* USEC_ROUND is used in the timeval to jiffie conversion. See there * USEC_ROUND is used in the timeval to jiffie conversion. See there
* for more details. It is the scaled resolution rounding value. Note * for more details. It is the scaled resolution rounding value. Note
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment