From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 19 16:20:43 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 129D916A4CE for ; Wed, 19 Jan 2005 16:20:43 +0000 (GMT) Received: from harmony.village.org (rover.village.org [168.103.84.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88A1143D5D for ; Wed, 19 Jan 2005 16:20:42 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.13.1/8.13.1) with ESMTP id j0JGILmC010337; Wed, 19 Jan 2005 09:18:21 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Wed, 19 Jan 2005 09:19:29 -0700 (MST) Message-Id: <20050119.091929.63840290.imp@bsdimp.com> To: ryans@gamersimpact.com From: "M. Warner Losh" In-Reply-To: <41ED14B0.8070600@gamersimpact.com> References: <002201c4fd4a$c5a81230$0700a8c0@felix> <41ED14B0.8070600@gamersimpact.com> X-Mailer: Mew version 3.3 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 cc: Felix.Schalck@gmx.net Subject: Re: Kernel mode programming X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2005 16:20:43 -0000 In message: <41ED14B0.8070600@gamersimpact.com> Ryan Sommers writes: : - Felix - wrote: : > Hi everyone, : > : > Doing lot of syscalls interrupts in a soft seems to take quite a long time, and seriously slow performances. As far as you can't reduce the syscall amount, is there any way to run apps in kernel mode, in order to call sysfonctions directly ? Perhaps by re-writing softs in kernel modules ? : > : > thanks for your time. : : Yes, it is possible to write loadable kernel modules. As far as if your : programs can be rewritten as kernel modules and achieve better : performance that's entirely dependent on what you are doing. What type : of syscalls are you executing? What is the rate at which you are calling : them? If you are calling a syscall on the same arguments thousands of : times could you implement some sort of cache system for syscall results? : : In my opinion it's bad practice to just throw a program into the kernel : to get better performance without evaluating why the performance is bad. : Making it a kernel module invites all kinds of security and stability : issues. And to be honest, it is rarely necessary. I say that as someone who has to deploy to 486/Pentium 133MHz machines for an embedded product. There's no subsititute for thorough understanding of the problem or a redesign of algorithms to make them do lest work. The overhead for kernel calls is so low (typically < 1-5%) that moving it into the kernel should only be done when you have an atypical case, or if there's a real-time or near-real-time component. Hearing about huge number of syscalls causing problems usually means that the caller needs to reevaluate how things are being done. One area where I have optimized is making the syscalls do more individual work. Rather than having a read interface that returns all the data, have one that returns ranges of an mmap'd region of memory and have the caller then schedule the writes from that region of memory. This technique saves a lot of data copying, for example. The scsi target code uses this technique, for example. Warner