From owner-freebsd-arch Sat Feb 16 12:33:35 2002 Delivered-To: freebsd-arch@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 36E1637B417; Sat, 16 Feb 2002 12:33:28 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id g1GKXOf13029; Sat, 16 Feb 2002 12:33:24 -0800 (PST) (envelope-from dillon) Date: Sat, 16 Feb 2002 12:33:24 -0800 (PST) From: Matthew Dillon Message-Id: <200202162033.g1GKXOf13029@apollo.backplane.com> To: Poul-Henning Kamp 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? ) References: <6988.1013844797@critter.freebsd.dk> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :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 /* * TESTGTOD.C */ #include #include #include #include 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