localcru: negative time of 2360 usec for pid 33672 (fork_exit)

From: Don Bowman <don_at_sandvine.com>
Date: Sun, 13 Jun 2004 12:53:48 -0400
if you run the below test program, periodically
you will get:
localcru: negative time of 2360 usec for pid 33672 (fork_exit)

come out. On stable, you can set 'kern.timecounter.method=1'
to workaround this problem. Is there a fix for this on current?

$ cat fork_exit.c 
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/resource.h>

char buf[16384];

static int
doit()
{
    int fd;
    char fname[] = "/tmp/fe/template.XXXXXXXXXX";
    memset(buf,random(), sizeof(buf));
    fd = open(mktemp(fname), O_RDWR|O_CREAT|O_TRUNC, 0666);
    if (fd > 0)
    {
        write(fd, buf, sizeof(buf));
    }
    exit(0);

}

int
main(int argc, char **argv)
{
    unsigned int i;
    int s;
    mkdir("/tmp/fe", 0777);
    for (i = 0; ; i++)
    {
        if (fork() == 0)
        {
            doit();
        }
        if ((i % 1000) == 0)
        {
            while (waitpid(-1, &s, WNOHANG) > 0)
                ;
            system("rm /tmp/fe/*");
        }
    }
    return 0;
}
Received on Sun Jun 13 2004 - 14:54:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:57 UTC