Re: weird kernel/ps interaction

From: Albert D. Cahalan (acahalan@cs.uml.edu)
Date: Sun Jul 02 2000 - 14:29:05 EST


> [...] date; sleep 5 & ps -e --format "lstart cmd" | grep 'sleep 5 >
> Fri Jun 30 07:13:49 CDT 2000
> [2] 19173
> Wed Jun 21 03:12:58 2000 sleep 5
> Wed Jun 21 03:12:58 2000 grep sleep 5
> 7:13am up 18 days, 8:01, 9 users, load average: 0.21, 0.31, 0.43
>
> Note the discrepancy between the current actual date and the
> date that ps reports as the process start time. I find it
> rather interesting that, if you do the math, the difference
> between the two times is pretty close to exactly half of
> the system uptime. I especially wonder if that's significant
> since the system is a dual cpu machine.
>
> System is based on a SuperMicro P6DNE (dual 200MHz PPro)
> and is running 2.2.14+raid+onstream+crypto. I've seen this
> since 2.2.5 (which is the earliest I've ever tried, it may
> have happened before that) and through 2.2.15 (haven't tried
> .16 yet, since I'm still waiting for the onstream patch for
> it). The ps package is the procps-2.0.2-2 from RedHat (the
> system was originally RH 6.0, but has had quite a few
> other modifications).

Looking at the source for Linux 2.2.8 and a pre-release procps,
I don't see how this could happen. Several glibc "features" have
messed up ps in the past (like not following standards), but I
don't have the source for that.

You could try a new procps, either from Debian's unstable branch
or from http://www.cs.uml.edu/~acahalan/linux/procps-000221.tar.gz
if you prefer a tarball. There are minor differences. The procps
used by Red Hat and many other non-Debian systems has many bugs.

According to the source I have:

/*****************************************************************/

/* on fork(), kernel does: p->start_time = jiffies; */

unsigned long seconds_since_boot = -1;
static unsigned long seconds_since_1970;
static unsigned long time_of_boot;

/* fill in pp->start_time value directly from kernel's start_time */
void foo(void){
  /* ... */
  &P->start_time, &P->vsize,
  &P->rss,
  &P->rss_rlim,
  /* ... */
}
                            
void some_init_functions(void){
  seconds_since_boot = uptime(0,0);
  seconds_since_1970 = time(NULL);
  time_of_boot = seconds_since_1970 - seconds_since_boot;
  /* ... */
}

static int pr_lstart(void){
  time_t t;
  t = (
           ((unsigned long)time_of_boot)
         + ((unsigned long)pp->start_time)
         / Hertz
  );
  return sprintf(outbuf, "%24.24s", ctime(&t));
}

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



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:11 EST