From owner-freebsd-arch Wed Oct 4 18:46:20 2000 Delivered-To: freebsd-arch@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 5446737B66D; Wed, 4 Oct 2000 18:46:17 -0700 (PDT) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e951k0J03587; Wed, 4 Oct 2000 18:46:00 -0700 (PDT) Date: Wed, 4 Oct 2000 18:46:00 -0700 From: Alfred Perlstein To: Bruce Evans Cc: Matt Dillon , Peter Wemm , Chuck Paterson , John Baldwin , arch@FreeBSD.ORG, John Polstra , Daniel Eischen , Greg Lehey Subject: Re: Mutexes and semaphores Message-ID: <20001004184559.Q27736@fw.wintelcom.net> References: <200010041639.e94GdVR24384@earth.backplane.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i In-Reply-To: ; from bde@zeta.org.au on Thu, Oct 05, 2000 at 12:40:16PM +1100 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Bruce Evans [001004 18:40] wrote: > On Wed, 4 Oct 2000, Matt Dillon wrote: > > [Writing reordered to reply after quoted material] > > [Peter Wemm wrote] > > > :int > > :getppid(p, uap) > > : struct proc *p; > > : struct getppid_args *uap; > > :{ > > : struct proc *parent; > > : pid_t pid; > > : > > : parent = p->p_pptr; > > : pid = parent->p_pid; > > :#ifdef SMP > > : for (;;) { > > : __asm __volatile (": : : memory"); /* mb(); on x86 */ > > : if (parent == p->p_pptr) > > : break; > > : /* lost a race, our parent died and we reparented - redo */ > > : parent = p->p_pptr; > > : pid = parent->p_pid; > > : } > > :#endif > > : p->p_retval[0] = (register_t)pid; > > : return 0; > > :} > > > This is one of the few things I really hate in the linux source base. > > This seems to be only to win getppid() benchmarks. Complications like it > might be justified in inner loops of syscalls that are called somewhat > more than once at most in normal programs. It's too hard to do things > this in the thousands of places that would be necessary to get a uniform > speedup. the idea is to reduce inter-cpu communication, lock-less systems are a terrific idea but hard to get right, we have two choices: 1) do it right and _not_ cause extra lock/cpu/bus contention 2) do it right and cause extra lock/cpu/bus contention It's my opinion that something simple like getpid shouldn't cause a locked bus cycle if at all possible. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message