public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Albert Cahalan <albert@users.sf.net>
To: George Anzinger <george@mvista.com>
Cc: Albert Cahalan <albert@users.sourceforge.net>,
	David Ford <david+powerix@blue-labs.org>,
	linux-kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: /proc or ps tools bug?  2.6.3, time is off
Date: 25 Feb 2004 14:16:02 -0500	[thread overview]
Message-ID: <1077736561.10393.486.camel@cube> (raw)
In-Reply-To: <403D0986.8040405@mvista.com>

George Anzinger writes:
> Albert Cahalan wrote:
>>  On Wed, 2004-02-25 at 11:28, George Anzinger wrote:

>>> As to small drifts of ~170 PPM, they are caused by code
>>> (ps I would guess) that assumes that jiffies is exactly
>>> 1/HZ whereas it is NOT in the 2.6.* kernel.  The size of
>>> the jiffie that the kernel uses is returned by:
>>>
>>> struct timespec tv;
>>> :
>>> :
>>> clock_res(CLOCK_REALTIME, &tv);
>>>
>>> This will be in nanoseconds (and must be as that is what the wall clock is in).
>>
>> This is NOT sane. Remeber that procps doesn't get to see HZ.
>> Only USER_HZ is available, as the AT_CLKTCK ELF note.
>
> May be, I did not do this, but only cleaned up the internal
> notion of jiffy so timers would work more correctly.  If you
> go back to HZ=100, every thing works better in this regard.
>
> On the other hand, what practical difference does it make?
> Almost no user code even looks at USER_HZ.  Its just things
> like ps and friends as far as I can tell...  Possibly we
> should just fix the utilities to use the above call to get
> the jiffie size...  I don't know the full history, but was
> USER_HZ invented by the 2.5 changes?

USER_HZ was invented by the 2.5 changes.

Linus has decreed that USER_HZ is part of the ABI.
For some reason (ARM port or stubborn glibc hacker?)
he has allowed USER_HZ to be exposed via an ELF note.
Prior to that, he'd refused all attempts to get HZ
exported through /proc/sys and similar.

I'm OK with any integer value as long as I can get it.
On older kernels procps will guess HZ from the uptime
and clock ticks, since there is a long history of
people running with non-standard HZ values.

Since the ABI is that USER_HZ==100, the kernel is
currently in violation. Perhaps the HZ-to-USER_HZ
conversion needs to be redone.

USER_HZ appears in SCSI ioctls, network stats,
an old clock ("clocks"? "times"?) syscall...

>> I think the way to fix this is to skip or add a tick
>> every now and then, so that the long-term HZ is exact.
>
> This is REAL problem for any code that wants to use
> more exact time/ timers than the 1/HZ.  See, for example,
> the high res patch (signature).  You can not just throw
> in an extra tick every so often.

You're just considering short-term time scales.
The extra ticks, over a period of many days, lead
you to the exact time.

I suppose it would be possible to have things both ways.
Raw jiffies is as it is today. Then we have a correction
factor that gets adjusted as needed to ensure that we can
get long-term-exact 1/HZ ticks as:  jiffies + correction

>> Another way is to simply choose between pure old-style
>> tick-based timekeeping and pure new-style cycle-based
>> (TSC or ACPI) timekeeping. Systems with uncooperative
>> hardware have to use the old-style time keeping. This
>> should simply the code greatly.
>
> Hm, the reason 1/HZ is not used is that the x86 hardware
> (PIT, to be exact) can not give a good 1/1000 value...

If using the PIT:

a. no broken attempt at high-res timekeeping
b. add or skip whole ticks as needed for timekeeping

Common timekeeping tasks don't fit neatly on jiffie
ticks anyway. You need 16.683 ticks per NTSC field, etc.

When you fully push timekeeping onto the TSC, ACPI
timer, or PowerPC bus counter, then you can have a
relatively crud-free high-res implementation.




  reply	other threads:[~2004-02-25 21:37 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-25  1:58 /proc or ps tools bug? 2.6.3, time is off David Ford
2004-02-25  1:54 ` Albert Cahalan
2004-02-25  5:10   ` David Ford
2004-02-25  3:27     ` Albert Cahalan
2004-02-25 16:28       ` George Anzinger
2004-02-25 16:04         ` Albert Cahalan
2004-02-25 20:45           ` George Anzinger
2004-02-25 19:16             ` Albert Cahalan [this message]
2004-02-25 21:10           ` George Anzinger
2004-02-26  1:52             ` john stultz
2004-02-26 23:06               ` George Anzinger
2004-02-26 23:10                 ` john stultz
2004-02-27  0:20                   ` George Anzinger
2004-04-13 22:38                     ` john stultz
2004-04-13 22:59                       ` George Anzinger
2004-04-14 12:10                       ` Tim Schmielau
2004-04-14 17:03                         ` George Anzinger
2004-04-14 18:28                         ` john stultz
2004-04-15 10:37                           ` Petri Kaukasoina
2004-04-15 11:05                             ` Tim Schmielau
2004-04-15 16:14                               ` Petri Kaukasoina
2004-05-01 13:51                                 ` Tim Schmielau
2004-05-02  1:41                                   ` Andrew Morton
2004-05-02  1:59                                     ` Tim Schmielau
2004-05-04  2:40                                       ` john stultz
2004-05-04  6:12                                         ` Tim Schmielau
2004-05-04 14:59                                           ` john stultz
2004-05-04 16:50                                             ` Tim Schmielau
2004-05-07  0:33                                             ` George Anzinger
2004-05-07  1:21                                               ` john stultz
2004-05-07 20:41                                                 ` George Anzinger
2004-05-07 21:38                                                   ` john stultz
2004-02-26 23:14               ` George Anzinger
2004-02-25  9:14 ` Petri Kaukasoina
2004-02-25  9:18   ` Petri Kaukasoina
2004-02-25 21:39   ` David Ford

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=1077736561.10393.486.camel@cube \
    --to=albert@users.sf.net \
    --cc=albert@users.sourceforge.net \
    --cc=david+powerix@blue-labs.org \
    --cc=george@mvista.com \
    --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