From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932211AbWG3L11 (ORCPT ); Sun, 30 Jul 2006 07:27:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932240AbWG3L11 (ORCPT ); Sun, 30 Jul 2006 07:27:27 -0400 Received: from nz-out-0102.google.com ([64.233.162.200]:26924 "EHLO nz-out-0102.google.com") by vger.kernel.org with ESMTP id S932211AbWG3L10 (ORCPT ); Sun, 30 Jul 2006 07:27:26 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=KfZkB5EuCIQmMMEQsuc95a2vc4rlYYjb1FLcojoboJiDBhKsoPs0m3oFU1Um2s3NGX/2MTmxMBYbZpoDus3xUBI6TxttLLrbGRUQAY93S5iL5ZxqNi9vKmsAK6RUHZvW4ERrbb/SeHtN25jVwHyhpeg1StZgPGP76pWqO5I6AZU= Message-ID: <44CC97A4.8050207@gmail.com> Date: Sun, 30 Jul 2006 13:27:09 +0159 From: Jiri Slaby User-Agent: Thunderbird 2.0a1 (X11/20060724) MIME-Version: 1.0 To: Linux Kernel Mailing List Subject: FP in kernelspace Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hello, I have a driver written for 2.4 + RT patches with FP support. I want it to work in 2.6. How to implement FP? Has anybody developped some "protocol" between KS and US yet? If not, could somebody point me, how to do it the best -- with low latency. The device doesn't generate irqs *), I need to quickly respond to timer call, because interval between two posts of data to the device has to be equal as much as possible (BTW is there any way how to gain up to 5000Hz). I've one idea: have a thread with RT priority and wake the app in US waiting in read of character device when timer ticks, post a struct with 2 floats and operation and wait in write for the result. App computes, writes the result, we are woken and can post it to the device. But I'm afraid it would be tooo slow. *) I don't know how to persuade it (standard PLX chip with unknown piece of logic behind) to generate, because official driver is closed and _very_ expensive. Old (2.4) driver was implemented with RT thread and timer, where FP is implemented within RT and computed directly in KS. So 2 questions are: 1) howto FP in kernel 2) howto precise timer (may mingo RT patches help?) 3) any way to have faster ticks (up to 5000Hz)? Any suggestions, please? thanks, -- Jiri Slaby faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932276AbWG3LbQ (ORCPT ); Sun, 30 Jul 2006 07:31:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932272AbWG3LbP (ORCPT ); Sun, 30 Jul 2006 07:31:15 -0400 Received: from nz-out-0102.google.com ([64.233.162.192]:54368 "EHLO nz-out-0102.google.com") by vger.kernel.org with ESMTP id S932269AbWG3LbN (ORCPT ); Sun, 30 Jul 2006 07:31:13 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=QJyppndoVrSWXAC9ZritpxksuM6TPqy+tHO5k0LTFUBV+kG5tPHCYCJaJyw30n2ZRJfLXF+nqjtPOwsJdkmWpyORRD73iizp2LrqJ+C8lTqrPy64c5FDVKhjYBiM+P+r5EZMzuF1p1LZyq1gZL5tbZOPegu6kPMQJhobhYZ/Wlw= Message-ID: <44CC9885.8030506@gmail.com> Date: Sun, 30 Jul 2006 13:30:54 +0159 From: Jiri Slaby User-Agent: Thunderbird 2.0a1 (X11/20060724) MIME-Version: 1.0 To: Jiri Slaby CC: Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <44CC97A4.8050207@gmail.com> In-Reply-To: <44CC97A4.8050207@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Jiri Slaby wrote: > Hello, > > I have a driver written for 2.4 + RT patches with FP support. I want it > to work in 2.6. How to implement FP? Has anybody developped some > "protocol" between KS and US yet? If not, could somebody point me, how > to do it the best -- with low latency. One more thing, it can't be table-precomputed, positions are read from the device, needs to be recomputed and pushed back. regards, -- Jiri Slaby faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750858AbWG3OdA (ORCPT ); Sun, 30 Jul 2006 10:33:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750853AbWG3OdA (ORCPT ); Sun, 30 Jul 2006 10:33:00 -0400 Received: from pentafluge.infradead.org ([213.146.154.40]:2009 "EHLO pentafluge.infradead.org") by vger.kernel.org with ESMTP id S1750835AbWG3Oc7 (ORCPT ); Sun, 30 Jul 2006 10:32:59 -0400 Subject: Re: FP in kernelspace From: Arjan van de Ven To: Jiri Slaby Cc: Linux Kernel Mailing List In-Reply-To: <44CC97A4.8050207@gmail.com> References: <44CC97A4.8050207@gmail.com> Content-Type: text/plain Organization: Intel International BV Date: Sun, 30 Jul 2006 16:32:57 +0200 Message-Id: <1154269977.2941.21.camel@laptopd505.fenrus.org> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-SRS-Rewrite: SMTP reverse-path rewritten from by pentafluge.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2006-07-30 at 13:27 +0159, Jiri Slaby wrote: > > I have a driver written for 2.4 + RT patches with FP support. I want > it to work > in 2.6. How to implement FP? Has anybody developped some "protocol" > between KS > and US yet? If not, could somebody point me, how to do it the best -- > with low > latency. > The device doesn't generate irqs *), I need to quickly respond to > timer call, > because interval between two posts of data to the device has to be > equal as much > as possible (BTW is there any way how to gain up to 5000Hz). > I've one idea: have a thread with RT priority and wake the app in US > waiting in > read of character device when timer ticks, post a struct with 2 floats > and > operation and wait in write for the result. App computes, writes the > result, we > are woken and can post it to the device. But I'm afraid it would be > tooo slow. real floating point in the kernel is basically no-go; especially if you enable preemption. The entire floating point exception, context save and restore engine is designed with the assumption of no kernel space FPU usage... and there are a LOT of nasty corner cases to deal with... and so far the kernel decided to cheap out on many of those by just not allowing kernel FPU use (mmx is easier so that can be dealt with). Volume 3 of the Intel architecture manuals are a good start if you want to know what some of these corner cases are... -- if you want to mail me at work (you don't), use arjan (at) linux.intel.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932320AbWG3OkP (ORCPT ); Sun, 30 Jul 2006 10:40:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932324AbWG3OkP (ORCPT ); Sun, 30 Jul 2006 10:40:15 -0400 Received: from fw5.argo.co.il ([194.90.79.130]:18955 "EHLO argo2k.argo.co.il") by vger.kernel.org with ESMTP id S932320AbWG3OkN (ORCPT ); Sun, 30 Jul 2006 10:40:13 -0400 Message-ID: <44CCC4CA.6000208@argo.co.il> Date: Sun, 30 Jul 2006 17:40:10 +0300 From: Avi Kivity User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Jiri Slaby CC: Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <44CC97A4.8050207@gmail.com> In-Reply-To: <44CC97A4.8050207@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jul 2006 14:40:11.0609 (UTC) FILETIME=[0FD4C490:01C6B3E6] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Jiri Slaby wrote: > > Hello, > > I have a driver written for 2.4 + RT patches with FP support. I want > it to work > in 2.6. How to implement FP? Has anybody developped some "protocol" > between KS > and US yet? If not, could somebody point me, how to do it the best -- > with low > latency. > The device doesn't generate irqs *), I need to quickly respond to > timer call, > because interval between two posts of data to the device has to be > equal as much > as possible (BTW is there any way how to gain up to 5000Hz). > I've one idea: have a thread with RT priority and wake the app in US > waiting in > read of character device when timer ticks, post a struct with 2 floats > and > operation and wait in write for the result. App computes, writes the > result, we > are woken and can post it to the device. But I'm afraid it would be > tooo slow. > > *) I don't know how to persuade it (standard PLX chip with unknown > piece of > logic behind) to generate, because official driver is closed and _very_ > expensive. Old (2.4) driver was implemented with RT thread and timer, > where FP > is implemented within RT and computed directly in KS. > > So 2 questions are: > 1) howto FP in kernel > kernel_fpu_begin(); c = d * 3.14; kernel_fpu_end(); -- error compiling committee.c: too many arguments to function From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751131AbWG3Oyt (ORCPT ); Sun, 30 Jul 2006 10:54:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751050AbWG3Oyt (ORCPT ); Sun, 30 Jul 2006 10:54:49 -0400 Received: from pentafluge.infradead.org ([213.146.154.40]:26752 "EHLO pentafluge.infradead.org") by vger.kernel.org with ESMTP id S1750924AbWG3Oys (ORCPT ); Sun, 30 Jul 2006 10:54:48 -0400 Subject: Re: FP in kernelspace From: Arjan van de Ven To: Avi Kivity Cc: Jiri Slaby , Linux Kernel Mailing List In-Reply-To: <44CCC4CA.6000208@argo.co.il> References: <44CC97A4.8050207@gmail.com> <44CCC4CA.6000208@argo.co.il> Content-Type: text/plain Organization: Intel International BV Date: Sun, 30 Jul 2006 16:54:43 +0200 Message-Id: <1154271283.2941.27.camel@laptopd505.fenrus.org> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-SRS-Rewrite: SMTP reverse-path rewritten from by pentafluge.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org > > So 2 questions are: > > 1) howto FP in kernel > > > kernel_fpu_begin(); > c = d * 3.14; > kernel_fpu_end(); > unfortunately this only works for MMX not for real fpu (due to exception handling uglies) -- if you want to mail me at work (you don't), use arjan (at) linux.intel.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932325AbWG3PIe (ORCPT ); Sun, 30 Jul 2006 11:08:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932328AbWG3PIe (ORCPT ); Sun, 30 Jul 2006 11:08:34 -0400 Received: from nz-out-0102.google.com ([64.233.162.193]:49671 "EHLO nz-out-0102.google.com") by vger.kernel.org with ESMTP id S932325AbWG3PId (ORCPT ); Sun, 30 Jul 2006 11:08:33 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=L+A8h10ORUgE92oTum0msJd7y3mTRmmV1yEvUqHScY9L4Il2LWCnlVnpcC0kPDWZwpEO3M56EcSgsOY8EIg2mzKnnYwTyl6/3R9FDGrzqB0SEpA6DLGAgg4pF7pjCH4wj6gzQ45PyPi+htJ4QUf2imE0q/rL2IyYal+2wYCb7Ts= Message-ID: <44CCCB74.9010605@gmail.com> Date: Sun, 30 Jul 2006 17:08:13 +0159 From: Jiri Slaby User-Agent: Thunderbird 2.0a1 (X11/20060724) MIME-Version: 1.0 To: Arjan van de Ven CC: Avi Kivity , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <44CC97A4.8050207@gmail.com> <44CCC4CA.6000208@argo.co.il> <1154271283.2941.27.camel@laptopd505.fenrus.org> In-Reply-To: <1154271283.2941.27.camel@laptopd505.fenrus.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Arjan van de Ven wrote: >>> So 2 questions are: >>> 1) howto FP in kernel >>> >> kernel_fpu_begin(); >> c = d * 3.14; >> kernel_fpu_end(); Yup, I know about this possibility, but this is only x86 specific?! > unfortunately this only works for MMX not for real fpu (due to exception > handling uglies) concludes it's not multiplatform at all... For that reasen I (maybe) want some "protocol" for communication with US, where I can easily compute it. Another way could be rtai (there is FP implemented IIRC), but it means having out-of-kernel driver. thanks, -- Jiri Slaby faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932332AbWG3PUm (ORCPT ); Sun, 30 Jul 2006 11:20:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932335AbWG3PUm (ORCPT ); Sun, 30 Jul 2006 11:20:42 -0400 Received: from pentafluge.infradead.org ([213.146.154.40]:8615 "EHLO pentafluge.infradead.org") by vger.kernel.org with ESMTP id S932332AbWG3PUl (ORCPT ); Sun, 30 Jul 2006 11:20:41 -0400 Subject: Re: FP in kernelspace From: Arjan van de Ven To: Jiri Slaby Cc: Avi Kivity , Linux Kernel Mailing List In-Reply-To: <44CCCB74.9010605@gmail.com> References: <44CC97A4.8050207@gmail.com> <44CCC4CA.6000208@argo.co.il> <1154271283.2941.27.camel@laptopd505.fenrus.org> <44CCCB74.9010605@gmail.com> Content-Type: text/plain Organization: Intel International BV Date: Sun, 30 Jul 2006 17:20:38 +0200 Message-Id: <1154272838.2941.30.camel@laptopd505.fenrus.org> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-SRS-Rewrite: SMTP reverse-path rewritten from by pentafluge.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2006-07-30 at 17:08 +0159, Jiri Slaby wrote: > Arjan van de Ven wrote: > >>> So 2 questions are: > >>> 1) howto FP in kernel > >>> > >> kernel_fpu_begin(); > >> c = d * 3.14; > >> kernel_fpu_end(); > > Yup, I know about this possibility, but this is only x86 specific?! > > > unfortunately this only works for MMX not for real fpu (due to exception > > handling uglies) > > concludes it's not multiplatform at all... For that reasen I (maybe) want some > "protocol" for communication with US, where I can easily compute it.] easiest might be a shared mmap ring buffer (well 2 of these actually), kernel puts data in buffer, updates ring pointer (and wakes userspace if needed). Userspace notices data in ring, does math, puts data back in the 2nd ringbuffer and updates that ring pointer. Then maybe does a syscall to 'wake' the kernel. Kernel then sees data in the 2nd ringbuffer and gets it. In addition to the wakeups I mentioned you can also poll for the buffers; the wakeups are just there for extra safety. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932336AbWG3PV0 (ORCPT ); Sun, 30 Jul 2006 11:21:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932337AbWG3PVZ (ORCPT ); Sun, 30 Jul 2006 11:21:25 -0400 Received: from fw5.argo.co.il ([194.90.79.130]:43788 "EHLO argo2k.argo.co.il") by vger.kernel.org with ESMTP id S932336AbWG3PVZ (ORCPT ); Sun, 30 Jul 2006 11:21:25 -0400 Message-ID: <44CCCE72.8030808@argo.co.il> Date: Sun, 30 Jul 2006 18:21:22 +0300 From: Avi Kivity User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Arjan van de Ven CC: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <1154271283.2941.27.camel@laptopd505.fenrus.org> In-Reply-To: <1154271283.2941.27.camel@laptopd505.fenrus.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jul 2006 15:21:23.0172 (UTC) FILETIME=[D0FF5A40:01C6B3EB] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Arjan van de Ven wrote: > > > > So 2 questions are: > > > 1) howto FP in kernel > > > > > kernel_fpu_begin(); > > c = d * 3.14; > > kernel_fpu_end(); > > > > unfortunately this only works for MMX not for real fpu (due to exception > handling uglies) > Perhaps there should be a comment to that effect? Neither the code nor Documentation/preemt-locking (which mentions the fpu) says anything about this little fact. It's also broken for x86-64, which uses sse for floating point, not the x87 fpu. -- error compiling committee.c: too many arguments to function From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932337AbWG3PXy (ORCPT ); Sun, 30 Jul 2006 11:23:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932338AbWG3PXy (ORCPT ); Sun, 30 Jul 2006 11:23:54 -0400 Received: from fw5.argo.co.il ([194.90.79.130]:49164 "EHLO argo2k.argo.co.il") by vger.kernel.org with ESMTP id S932337AbWG3PXx (ORCPT ); Sun, 30 Jul 2006 11:23:53 -0400 Message-ID: <44CCCF06.4070406@argo.co.il> Date: Sun, 30 Jul 2006 18:23:50 +0300 From: Avi Kivity User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Jiri Slaby CC: Arjan van de Ven , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <44CCCB74.9010605@gmail.com> In-Reply-To: <44CCCB74.9010605@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jul 2006 15:23:51.0859 (UTC) FILETIME=[299F3030:01C6B3EC] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Jiri Slaby wrote: > > > unfortunately this only works for MMX not for real fpu (due to > exception > > handling uglies) > > concludes it's not multiplatform at all... For that reasen I (maybe) > want some > "protocol" for communication with US, where I can easily compute it. > Well, usually such a protocol is by means of read(2) and write(2) to a character device provided by your driver: userspace reads some data, does the fp ops, and writes it back. If you want realtime you'll have to use a realtime thread with the appropriate priority. -- error compiling committee.c: too many arguments to function From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932376AbWG3Rcx (ORCPT ); Sun, 30 Jul 2006 13:32:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932380AbWG3Rcx (ORCPT ); Sun, 30 Jul 2006 13:32:53 -0400 Received: from ns2.suse.de ([195.135.220.15]:2007 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S932376AbWG3Rcx (ORCPT ); Sun, 30 Jul 2006 13:32:53 -0400 To: Jiri Slaby Cc: linux-kernel@vger.kernel.org Subject: Re: FP in kernelspace References: <44CC97A4.8050207@gmail.com> From: Andi Kleen Date: 30 Jul 2006 19:32:50 +0200 In-Reply-To: <44CC97A4.8050207@gmail.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Jiri Slaby writes: > I have a driver written for 2.4 + RT patches with FP support. I want > it to work in 2.6. How to implement FP? Has anybody developped some > "protocol" between KS and US yet? If not, could somebody point me, how > to do it the best -- with low latency. > The device doesn't generate irqs Doesn't sound like something that should be supported for mainline then. > So 2 questions are: > 1) howto FP in kernel You can use kernel_fpu_begin()/_end() around the FP code in the kernel, but the real time people will probably hate you for it because it disables preemption. > 3) any way to have faster ticks (up to 5000Hz)? There are plenty of interval timers in various hardware in a typical system that can be used. e.g. RTC is a common choice. Drawback is that you might conflict with other users, especially in user space. But please don't try to submit such a hack. -Andi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932380AbWG3Rds (ORCPT ); Sun, 30 Jul 2006 13:33:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932383AbWG3Rds (ORCPT ); Sun, 30 Jul 2006 13:33:48 -0400 Received: from cantor2.suse.de ([195.135.220.15]:10967 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S932380AbWG3Rdr (ORCPT ); Sun, 30 Jul 2006 13:33:47 -0400 To: Arjan van de Ven Cc: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <44CC97A4.8050207@gmail.com> <44CCC4CA.6000208@argo.co.il> <1154271283.2941.27.camel@laptopd505.fenrus.org> From: Andi Kleen Date: 30 Jul 2006 19:33:41 +0200 In-Reply-To: <1154271283.2941.27.camel@laptopd505.fenrus.org> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Arjan van de Ven writes: > > unfortunately this only works for MMX not for real fpu (due to exception > handling uglies) He can always disable all FPU exceptions in his code or make sure there aren't any. -Andi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932386AbWG3Reg (ORCPT ); Sun, 30 Jul 2006 13:34:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932385AbWG3Reg (ORCPT ); Sun, 30 Jul 2006 13:34:36 -0400 Received: from ns2.suse.de ([195.135.220.15]:18647 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S932383AbWG3Ref (ORCPT ); Sun, 30 Jul 2006 13:34:35 -0400 To: Avi Kivity Cc: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <1154271283.2941.27.camel@laptopd505.fenrus.org> <44CCCE72.8030808@argo.co.il> From: Andi Kleen Date: 30 Jul 2006 19:34:29 +0200 In-Reply-To: <44CCCE72.8030808@argo.co.il> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Avi Kivity writes: > > It's also broken for x86-64, which uses sse for floating point, not > the x87 fpu. Sorry, that doesn't make sense. -Andi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932399AbWG3SLP (ORCPT ); Sun, 30 Jul 2006 14:11:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932401AbWG3SLP (ORCPT ); Sun, 30 Jul 2006 14:11:15 -0400 Received: from gateway.argo.co.il ([194.90.79.130]:24338 "EHLO argo2k.argo.co.il") by vger.kernel.org with ESMTP id S932399AbWG3SLO (ORCPT ); Sun, 30 Jul 2006 14:11:14 -0400 Message-ID: <44CCF63B.6070906@argo.co.il> Date: Sun, 30 Jul 2006 21:11:07 +0300 From: Avi Kivity User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Andi Kleen CC: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jul 2006 18:11:10.0325 (UTC) FILETIME=[89038A50:01C6B403] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Andi Kleen wrote: > > Avi Kivity writes: > > > > It's also broken for x86-64, which uses sse for floating point, not > > the x87 fpu. > > Sorry, that doesn't make sense. > > > kernel_fpu_begin(); > > c = d * 3.14; > > kernel_fpu_end(); Cannot work on x86-64, even disregarding fp exceptions, because kernel_fpu_begin() doesn't save the sse state which is used by fp math. No? -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932403AbWG3STO (ORCPT ); Sun, 30 Jul 2006 14:19:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932405AbWG3STO (ORCPT ); Sun, 30 Jul 2006 14:19:14 -0400 Received: from mailer.gwdg.de ([134.76.10.26]:8665 "EHLO mailer.gwdg.de") by vger.kernel.org with ESMTP id S932403AbWG3STN (ORCPT ); Sun, 30 Jul 2006 14:19:13 -0400 Date: Sun, 30 Jul 2006 20:17:39 +0200 (MEST) From: Jan Engelhardt To: Avi Kivity cc: Andi Kleen , Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace In-Reply-To: <44CCF63B.6070906@argo.co.il> Message-ID: References: <44CCF63B.6070906@argo.co.il> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Report: Content analysis: 0.0 points, 6.0 required _SUMMARY_ Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org > > Cannot work on x86-64, even disregarding fp exceptions, because > kernel_fpu_begin() doesn't save the sse state which is used by fp math. > > No? No. You can - if you want - exclusively use x87 math on x64 (at least for userspace) and don't care about SSE. Otherwise, GCC having a -mfpmath=387 would be pretty useless. No? Jan Engelhardt -- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932405AbWG3ST1 (ORCPT ); Sun, 30 Jul 2006 14:19:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932406AbWG3STZ (ORCPT ); Sun, 30 Jul 2006 14:19:25 -0400 Received: from mailer.gwdg.de ([134.76.10.26]:27866 "EHLO mailer.gwdg.de") by vger.kernel.org with ESMTP id S932405AbWG3STZ (ORCPT ); Sun, 30 Jul 2006 14:19:25 -0400 Date: Sun, 30 Jul 2006 20:18:37 +0200 (MEST) From: Jan Engelhardt To: Avi Kivity cc: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace In-Reply-To: <44CCC4CA.6000208@argo.co.il> Message-ID: References: <44CC97A4.8050207@gmail.com> <44CCC4CA.6000208@argo.co.il> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Report: Content analysis: 0.0 points, 6.0 required _SUMMARY_ Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org > kernel_fpu_begin(); > c = d * 3.14; > kernel_fpu_end(); static inline void kernel_fpu_begin() { ... preempt_disable(); ... } Jan Engelhardt -- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932406AbWG3SU0 (ORCPT ); Sun, 30 Jul 2006 14:20:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932401AbWG3SUZ (ORCPT ); Sun, 30 Jul 2006 14:20:25 -0400 Received: from mx1.suse.de ([195.135.220.2]:11242 "EHLO mx1.suse.de") by vger.kernel.org with ESMTP id S932406AbWG3SUZ (ORCPT ); Sun, 30 Jul 2006 14:20:25 -0400 From: Andi Kleen To: Avi Kivity Subject: Re: FP in kernelspace Date: Sun, 30 Jul 2006 20:15:33 +0200 User-Agent: KMail/1.9.3 Cc: Jiri Slaby , Linux Kernel Mailing List References: <44CCF63B.6070906@argo.co.il> In-Reply-To: <44CCF63B.6070906@argo.co.il> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200607302015.33684.ak@suse.de> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org > > Cannot work on x86-64, even disregarding fp exceptions, because > kernel_fpu_begin() doesn't save the sse state which is used by fp math. > > No? It does - FXSAVE saves everything. BTW you can use x87 on x86-64 too, you just need to use long double. -Andi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbWG3S2s (ORCPT ); Sun, 30 Jul 2006 14:28:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932415AbWG3S2s (ORCPT ); Sun, 30 Jul 2006 14:28:48 -0400 Received: from gateway.argo.co.il ([194.90.79.130]:62226 "EHLO argo2k.argo.co.il") by vger.kernel.org with ESMTP id S932372AbWG3S2r (ORCPT ); Sun, 30 Jul 2006 14:28:47 -0400 Message-ID: <44CCFA5A.2030605@argo.co.il> Date: Sun, 30 Jul 2006 21:28:42 +0300 From: Avi Kivity User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Jan Engelhardt CC: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jul 2006 18:28:45.0997 (UTC) FILETIME=[FE3E4DD0:01C6B405] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Jan Engelhardt wrote: > > > kernel_fpu_begin(); > > c = d * 3.14; > > kernel_fpu_end(); > > static inline void kernel_fpu_begin() { > ... > preempt_disable(); > ... > } > Is the kernel allowed to clobber userspace's sse registers? What about interrupt code? xor.h at least appears to save the sse state before use. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932416AbWG3Sax (ORCPT ); Sun, 30 Jul 2006 14:30:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932419AbWG3Sax (ORCPT ); Sun, 30 Jul 2006 14:30:53 -0400 Received: from fw5.argo.co.il ([194.90.79.130]:1299 "EHLO argo2k.argo.co.il") by vger.kernel.org with ESMTP id S932416AbWG3Saw (ORCPT ); Sun, 30 Jul 2006 14:30:52 -0400 Message-ID: <44CCFAD3.2050607@argo.co.il> Date: Sun, 30 Jul 2006 21:30:43 +0300 From: Avi Kivity User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: Andi Kleen CC: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace References: <200607302015.33684.ak@suse.de> In-Reply-To: <200607302015.33684.ak@suse.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jul 2006 18:30:50.0919 (UTC) FILETIME=[48B3E370:01C6B406] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Andi Kleen wrote: > > > > > Cannot work on x86-64, even disregarding fp exceptions, because > > kernel_fpu_begin() doesn't save the sse state which is used by fp math. > > > > No? > > It does - FXSAVE saves everything. > I see. Thanks for clearing it up. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964786AbWG3XMm (ORCPT ); Sun, 30 Jul 2006 19:12:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S964787AbWG3XMm (ORCPT ); Sun, 30 Jul 2006 19:12:42 -0400 Received: from mailer.gwdg.de ([134.76.10.26]:7092 "EHLO mailer.gwdg.de") by vger.kernel.org with ESMTP id S964786AbWG3XMl (ORCPT ); Sun, 30 Jul 2006 19:12:41 -0400 Date: Mon, 31 Jul 2006 01:11:51 +0200 (MEST) From: Jan Engelhardt To: Avi Kivity cc: Jiri Slaby , Linux Kernel Mailing List Subject: Re: FP in kernelspace In-Reply-To: <44CCFA5A.2030605@argo.co.il> Message-ID: References: <44CCFA5A.2030605@argo.co.il> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Report: Content analysis: 0.0 points, 6.0 required _SUMMARY_ Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org >> > kernel_fpu_begin(); >> > c = d * 3.14; >> > kernel_fpu_end(); >> >> static inline void kernel_fpu_begin() { >> ... >> preempt_disable(); >> ... >> } >> > Is the kernel allowed to clobber userspace's sse registers? As long as you save and restore it properly, and make it look like to all other threads that nothing happened, you are (I hope) free to do anything. > What about interrupt code? You do not want to go there... > xor.h at least appears to save the sse state before use. > > -- > Do not meddle in the internals of kernels, for they are subtle and quick to > panic. Follow that advice, don't do FP. But OTOH...... there is already an SSE player in the kernel: drivers/md/raid6sse*.c Jan Engelhardt -- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932491AbWGaAdP (ORCPT ); Sun, 30 Jul 2006 20:33:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932493AbWGaAdP (ORCPT ); Sun, 30 Jul 2006 20:33:15 -0400 Received: from ms-smtp-04.nyroc.rr.com ([24.24.2.58]:16116 "EHLO ms-smtp-04.nyroc.rr.com") by vger.kernel.org with ESMTP id S932491AbWGaAdO (ORCPT ); Sun, 30 Jul 2006 20:33:14 -0400 Subject: Re: FP in kernelspace From: Steven Rostedt To: Jiri Slaby Cc: Linux Kernel Mailing List , Ingo Molnar , Thomas Gleixner In-Reply-To: <44CC97A4.8050207@gmail.com> References: <44CC97A4.8050207@gmail.com> Content-Type: text/plain Date: Sun, 30 Jul 2006 20:33:09 -0400 Message-Id: <1154305989.10074.66.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2006-07-30 at 13:27 +0159, Jiri Slaby wrote: > Hello, > > I have a driver written for 2.4 + RT patches with FP support. I want it to work > in 2.6. How to implement FP? Has anybody developped some "protocol" between KS > and US yet? If not, could somebody point me, how to do it the best -- with low > latency. > The device doesn't generate irqs *), I need to quickly respond to timer call, > because interval between two posts of data to the device has to be equal as much > as possible (BTW is there any way how to gain up to 5000Hz). > I've one idea: have a thread with RT priority and wake the app in US waiting in > read of character device when timer ticks, post a struct with 2 floats and > operation and wait in write for the result. App computes, writes the result, we > are woken and can post it to the device. But I'm afraid it would be tooo slow. > > *) I don't know how to persuade it (standard PLX chip with unknown piece of > logic behind) to generate, because official driver is closed and _very_ > expensive. Old (2.4) driver was implemented with RT thread and timer, where FP > is implemented within RT and computed directly in KS. > > So 2 questions are: > 1) howto FP in kernel > 2) howto precise timer (may mingo RT patches help?) Well Ingo's RT patch set has the high resolution timers developed by Thomas Gleixner, which may help you here. > 3) any way to have faster ticks (up to 5000Hz)? Why do you need faster ticks? The high res timers are done in nano secs, and the resolution is up to the hardware. > > Any suggestions, please? -- Steve