linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: George Anzinger <george@mvista.com>
To: akpm@osdl.org
Cc: eric.piel@tremplin-utc.net, Corey Minyard <minyard@acm.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] Fine tune the time conversion to eliminate conversion errors.
Date: Tue, 27 Jan 2004 01:31:04 -0800	[thread overview]
Message-ID: <40162FD8.3090600@mvista.com> (raw)
In-Reply-To: <1074979873.4012e421714b1@mailetu.utc.fr>

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

Andrew,

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.

-- 
George Anzinger   george@mvista.com
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml

[-- Attachment #2: time.h-2.6.1-1.0.patch --]
[-- Type: text/plain, Size: 1309 bytes --]

--- linux-2.6.1-org/include/linux/time.h	2003-08-11 13:48:55.000000000 -0700
+++ linux/include/linux/time.h	2004-01-27 00:29:12.000000000 -0800
@@ -148,14 +148,14 @@
 #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

      parent reply	other threads:[~2004-01-27  9:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-24 21:31 [PATCH] Incorrect value for SIGRTMAX eric.piel
2004-01-24 22:30 ` Andrew Morton
2004-01-24 22:37   ` eric.piel
2004-01-25  9:21     ` George Anzinger
2004-01-25 10:28       ` eric.piel
2004-01-27  9:19 ` [PATCH] Incorrect value for SIGRTMAX, MIPS nonsense removed, timer_gettime fix George Anzinger
2004-01-27 18:46   ` Andrew Morton
2004-01-27 20:32     ` George Anzinger
2004-01-27  9:31 ` George Anzinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40162FD8.3090600@mvista.com \
    --to=george@mvista.com \
    --cc=akpm@osdl.org \
    --cc=eric.piel@tremplin-utc.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).