Re: 2.6.1: process start times by procps

From: Petri Kaukasoina
Date: Thu Jan 29 2004 - 09:40:52 EST


Thanks for answering,

On Wed, Jan 28, 2004 at 06:21:52PM -0800, john stultz wrote:
> On Tue, 2004-01-27 at 07:52, Petri Kaukasoina wrote:
> > I made an experiment shown below. I know nothing about kernel programming,
> > so this is probably not correct, but at least btime seemed to stay constant.
> > (I don't believe this fixes procps, though. If HZ if off by 180 ppm then I
> > guess ps can't possibly get its calculations involving HZ right. But at
> > least the bootup time reported by procinfo stays constant.)
>
>
> Uh, what does your /etc/ntp/drift file show?

ntp.drift is -22.251 on linux-2.6.1. But on linux-2.4.24 it stabilizes at
about -5.4.

> The basic equation is:
> btime ~= gettimeodfay() - uptime
>
> Thus if your time of day is adjusted by NTP, btime will change as well.
> Uptime is calculated calculated by jiffies/HZ, and HZ is not NTP
> adjusted, so if your system is running 180ppm too fast or slow, btime
> would be expected to change.
>

Yes, on linux-2.2.24 I can see that /proc/uptime is just the jiffies and
btime is current time - jiffies. But in linux-2.6.1 /proc/uptime is now
do_posix_clock_monotonic_gettime(), whatever that means, and /proc/uptime
gives a correct value. But btime is still gettimeofday-jiffies and it does
not stay constant. My patch changed btime to be
gettimeofday-do_posix_clock_monotonic_gettime() and after that it stays
constant.

In other words, on linux-2.2.24, if I print the current time with 'date +%s'
and subtract uptime (/proc/uptime) from that, I do get the same number that
is in the btime field in /proc/stat. But not on linux-2.6.1 without my
patch. (ntp running in both cases.)

> I'm not yet sure how that is related to the ps start time being wrong.

I guess it's not. The relative error was just the same in both. On
linux-2.2.24, ps start time is correct but on linux-2.6.1 it shows times in
future. How much in future, about minute per four days of uptime. But if I
multiply Hertz by e.g. 1.000172 in the ps source, then I get the right
results on linux-2.6.1.

I'll do an experiment and boot to linux-2.6.1 without ntpd next...

Thanks,

-Petri
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/