From owner-freebsd-arch@FreeBSD.ORG Tue May 25 11:30:02 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C3DF916A4CE for ; Tue, 25 May 2004 11:30:02 -0700 (PDT) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 76F2F43D39 for ; Tue, 25 May 2004 11:30:00 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) i4PITj7Z093922; Tue, 25 May 2004 11:29:45 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.9p2/8.12.9/Submit) id i4PITjbp093921; Tue, 25 May 2004 11:29:45 -0700 (PDT) (envelope-from dillon) Date: Tue, 25 May 2004 11:29:45 -0700 (PDT) From: Matthew Dillon Message-Id: <200405251829.i4PITjbp093921@apollo.backplane.com> To: Alan Cox References: <20040525065410.GA23877@cs.rice.edu> cc: arch@freebsd.org Subject: Re: Network Stack Locking X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2004 18:30:02 -0000 :>:Sounds a lot like a lot of the Mach IPC optimizations, including their use :>:of continuations during IPC to avoid a full context switch. :>: :>:Robert N M Watson FreeBSD Core Team, TrustedBSD Projects :>:robert@fledge.watson.org Senior Research Scientist, McAfee Research :> :> Well, I like the performance aspects of a continuation mechanism, but :> I really dislike the memory overhead. Even a minimal stack is :> expensive when you multiply it by potentially hundreds of thousands :> of 'blocking' entities such as PCBs.. say, a TCP output stream. :> Because of this the overhead and cache pollution generated by the :> continuation mechanism increases as system load increases rather :> then decreases. : :When the explicit continuation mechanism was used, the thread's stack :was freed when the thread blocked and a new stack allocated when the :thread was restarted. Here is a URL: :http://citeseer.ist.psu.edu/draves91using.html. Notice the mention of :space reduction in the abstract. It's worth reading. : :Alan Ah, now I understand. The continuation is an exit from the procedure. This sounds very similar to an interrupt mechanism I designed about a decade ago. Instead of saving and restoring the interrupt context for the interrupt thread, the thread switch was special-cased to basically create a context (by pushing a procedure call on the stack) on switch-in and to throw it away on switch-out (which was always at the end of the interrupt routine). I extended the same mechanism down into 'userland' by creating a 'waitforever()' system call which basically did nothing but wait for and dispatch signal vectors (most of the programs were event oriented and had no main loop). The nice thing about this was that no context had to be saved while the program was sitting in waitforever(), or restored when the program returned from a signal handler. This more then doubled scheduler performance (which on a 10MHz 68000 was important). In many ways, the continuation mechanism and the message queue mechanism appear to be nearly identical. If an explicit exit from a procedure is required to optimize the stack with the continuation mechanism, then that isn't much different then moving the message to an event queue and returning to the message processing loop. Neither case allows you to save stack context or to save the current procedural stacking level, and both mechanisms allow you to reuse your current stack to handle multiple messages/continuations. -Matt Matthew Dillon