From owner-freebsd-threads@FreeBSD.ORG Wed Mar 3 23:28:42 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 081CE16A4CE for ; Wed, 3 Mar 2004 23:28:42 -0800 (PST) Received: from liberty.onthenet.com.au (liberty.OntheNet.com.au [203.22.124.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 787FD43D39 for ; Wed, 3 Mar 2004 23:28:41 -0800 (PST) (envelope-from grehan@freebsd.org) Received: from freebsd.org (CPE-30-38.dsl.onthenet.net [203.144.30.38]) i247SdZG089171; Thu, 4 Mar 2004 17:28:40 +1000 (EST) (envelope-from grehan@freebsd.org) Message-ID: <4046DB3B.9000604@freebsd.org> Date: Thu, 04 Mar 2004 17:31:07 +1000 From: Peter Grehan User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3.1) Gecko/20030524 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org Subject: Re: User-space context switch and floating-point X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2004 07:28:42 -0000 > So if the caller saves the registers before pthread_mutex_lock(), why > do they also need to be saved by _thr_getcontext (which may be a > result of pthread_mutex_lock() in this example)? I was a bit vague. Here's relevant text from the SVR4 PPC ABI: "Registers r1, r14 through r31, and f14 through f31 are nonvolatile; that is, they "belong" to the calling function. A called function shall save these registers values before it changes them, restoring their values before it returns. Registers r0, r3 through r12, f0 through f13, and the special purpose registers CTR and XER are volatile; that is, they are not preserved across function calls." and: "r3 through r10 and f1 through f8: These sets of volatile registers may be modified across function invocations and shall therefore be presumed by the calling function to be destroyed. They are used for passing parameters to the called function; see Parameter Passing in this chapter. In addition, registers r3, r4, and f1 are used to return values from the called function, as described in Return Values." So as a context-save function, you have to assume that f14-31 are being used by the caller and save them. Problem is, these regs are 64-bits on PPC, touching them will cause an FP trap and from then on force full kernel FP save/restore for that proc's td, which is big performance hit for the majority of non-FP threads userland threads. The Altivec register file is a bit better since it has a register to inform context switch code which of the 32 128-bit registers are in use. later, Peter.