From: Andrei Voropaev <avorop@mail.ru>
To: linux-kernel@vger.kernel.org
Subject: Re: with 2.6.7 setitimer called in sequence returns strange values on i686
Date: Mon, 30 Aug 2004 14:10:12 +0200 [thread overview]
Message-ID: <20040830121012.GA1938@avorop.local> (raw)
In-Reply-To: <20040824144241.GE1527@avorop.local>
On Tue, Aug 24, 2004 at 04:42:41PM +0200, Andrei Voropaev wrote:
[...]
>
> I'm using setitimer(ITIMER_REAL...) to measure time intervals.
> Everything was working fine untill I've installed 2.6.7 kernel.
[...]
>
> Previous value of 10 timer is 10.479
>
> Note the last line. I've reset timer to 10 seconds and setitimer tells
> me that there are 10.479 seconds left.
I'm not sure if it is of particular importance. After checking the
sources it appears that the problem lies with mathematic. New math makes
sure than during conversion of timeval to jiffies bigger number of
jiffies is allocated to force the requirement that timer expires not
earlier than requested. But during conversion from jiffies back to
timeval no reverse adjustment is done, so resulting timeval can be
more than original. From my standpoint this violates the requirement
that the timer is only decremented (thus reduces its value) and not
incremented.
That is why I believe that the following patch would be correct.
--- ../time.h 2004-08-30 13:59:14.000000000 +0200
+++ include/linux/time.h 2004-08-30 14:00:10.000000000 +0200
@@ -239,7 +239,7 @@
* Convert jiffies to nanoseconds and separate with
* one divide.
*/
- u64 nsec = (u64)jiffies * TICK_NSEC;
+ u64 nsec = (u64)jiffies * TICK_NSEC - (TICK_NSEC / 2);
value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec);
}
Well, this might be minor issue since normally nobody should call getitimer immidiately after setitimer, but still...
> I have one more machine with 2.6.7 kernel. But that machine is Athlon64
> and runs 64-bit kernel. There the program also runs correctly.
The above is not true. The problem appears on 64-bit kernel as well.
Just for different numbers :)
Andrei
prev parent reply other threads:[~2004-08-30 12:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-24 14:42 Andrei Voropaev
2004-08-24 15:11 ` Michael Kerrisk
2004-08-25 7:17 ` Andrei Voropaev
2004-08-30 12:10 ` Andrei Voropaev [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=20040830121012.GA1938@avorop.local \
--to=avorop@mail.ru \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®