Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Feb 2002 12:33:24 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        arch@FreeBSD.ORG, jhb@FreeBSD.ORG, peter@wemm.org, jake@locore.ca
Subject:   gettimeofday() and crhold()/crfree() (was Re: gettimeofday() and copyout(). Is copyout() MPSAFE on non-i386 archs? )
Message-ID:  <200202162033.g1GKXOf13029@apollo.backplane.com>
References:   <6988.1013844797@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
:Make sure to run something which abuses gettimeofday() for select,
:maybe netscape or some other multi-threaded nightmare.
:
:-- 
:Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
:phk@FreeBSD.ORG         | TCP/IP since RFC 956

    I can run some backplane database stuff, that's fairly select/gettimeofday
    intensive.

    This is what I am running right now (see below).  When combined with the
    /bin/ps change I just comitted and gdb'ing -k kernel.debug /dev/mem to
    look at where the process is getting stuck when running two of them on an
    SMP system.  It looks like it is mainly getting stuck in the 
    mtx_lock(&Giant) call around the crfree() call in trap.c (the syscall
    code).

    Does anyone mind if I fix the credential code?  Locking Giant for
    every syscall doesn't make any sense, nor does calling FREE() inside
    crfree() or embedding an internal mutex in the ucred.  It can all
    be done with mtxpool-protected credentials and a ucred freelist.  It
    would take me less then an hour to fix it but I don't want to step on
    any toes if someone else is already on it.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>

/*
 * TESTGTOD.C
 */

#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int ac, char **av)
{
    struct timeval tv1;
    struct timeval tv2;
    int count= 0;
    int count_sec = 0;
    pid_t pid = getpid();

    gettimeofday(&tv1, NULL);
    for (;;) {
	int us;

	gettimeofday(&tv2, NULL);
	++count_sec;
	us = (tv2.tv_usec + 1000000 - tv1.tv_usec) + (tv2.tv_sec - tv1.tv_sec - 1) * 1000000;
	if (us > 1000000)
	    break;
    }

    gettimeofday(&tv1, NULL);
    for (;;) {
	gettimeofday(&tv2, NULL);
	++count;
	if (count == count_sec) {
	    int us = (tv2.tv_usec + 1000000 - tv1.tv_usec) + (tv2.tv_sec - tv1.tv_sec - 1) * 1000000;
	    printf("pid %d gtod/sec %d\n", (int)pid, (int)((int64_t)count * 1000000 / us));
	    count = 0;
	    tv1 = tv2;
	}
    }
    return(0);
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202162033.g1GKXOf13029>