From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 24 21:17:57 2007 Return-Path: Delivered-To: FreeBSD-Hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A53DF16A41B for ; Wed, 24 Oct 2007 21:17:57 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 6391A13C4B7 for ; Wed, 24 Oct 2007 21:17:57 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.1/8.14.1) with ESMTP id l9OLCMqp021268; Wed, 24 Oct 2007 15:12:23 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 24 Oct 2007 15:15:13 -0600 (MDT) Message-Id: <20071024.151513.-713548131.imp@bsdimp.com> To: Danovitsch@vitsch.net From: "M. Warner Losh" In-Reply-To: <200710222211.51590.Danovitsch@vitsch.net> References: <200710222211.51590.Danovitsch@vitsch.net> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: FreeBSD-Hackers@FreeBSD.org Subject: Re: Floating point in interrupt handler X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2007 21:17:57 -0000 In message: <200710222211.51590.Danovitsch@vitsch.net> "Daan Vreeken [PA4DAN]" writes: : But what I haven't found is a description of exactly what the kernel is : missing to allow floating point operations to be done there. FPU context is assumed to only change in user processes. You'd have to fix the FPU state saving code to cope with it changing everywhere, or you'd have to explicitly put the goo to save/restore it around the FP you want to do in the kernel. You had also make sure that the floating point exceptions never trap, since trapping inside the kernel has very limited support. You'll have to fix the problems that this would cause, or force the FPU into a state where it never traps. Sure, maybe you can make it happen. However, you are in for much pain and suffering. The kernel isn't a general purpose computing environment, and trying to pretend it is will lead to suffering. Especially inside of an interrupt handler. It is less bad if this is an ithread, but could be quite painful if you want to do this inside of a fast interrupt handler to reduce latency. I'd recommend strongly against trying this and revaluate your true need for FP in the kernel. From your other mail, you don't seem open to this answer. If you don't take it, you are setting yourself up for a lot of pain and suffering. It is your choice, however. If you do manage to pull it of, I'd be very interested in see what things I didn't know to warn you about... Warner