From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 31 08:20:29 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 EC47916A420 for ; Tue, 31 Jan 2006 08:20:29 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A1B643D55 for ; Tue, 31 Jan 2006 08:20:29 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (qpiyrb8awtfpkhxy@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.3/8.13.3) with ESMTP id k0V8J3SD032441; Tue, 31 Jan 2006 00:19:03 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.3/8.13.3/Submit) id k0V8J3YT032440; Tue, 31 Jan 2006 00:19:03 -0800 (PST) (envelope-from jmg) Date: Tue, 31 Jan 2006 00:19:03 -0800 From: John-Mark Gurney To: Bharma Ji Message-ID: <20060131081902.GY69162@funkthat.com> Mail-Followup-To: Bharma Ji , freebsd-hackers@freebsd.org References: <67beabb0601301146h6c5034fao998bf573f1e89613@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67beabb0601301146h6c5034fao998bf573f1e89613@mail.gmail.com> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-hackers@freebsd.org Subject: Re: How to pin a userland page in memory(avoid copyin and copyout) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jan 2006 08:20:30 -0000 Bharma Ji wrote this message on Mon, Jan 30, 2006 at 11:46 -0800: > I am trying to explore the option avoiding copyin and copyout when mode > switches from user to kernel and vice versa. One way to achieve this, as I > understand, is to make the memory address (which contain the data to be > copied) non pageable. Then just pass the addresses to the kernel and the > data will be used directly from the userland page. Is there already some > example code / standard way to do this? > > Also is there any way one can determine the amount of time / performance hit > (CPU %)that happening on a given process due to the copyin and copyout. I > want to understand how much performance gain one can gain if I am able to > remove copyin/copyout. It really depends upon how much data you are going to copy... There was some tests performed that showed that for sizes less than 32k or so that it was faster to read/write (copyout/copyin) than it was to mmap a file... I am working on a driver that passed the buffer address w/ an ioctl, and use vslock + bus_dmamap_load_uio to be able to make the card dma directly into the user's buffers: http://perforce.freebsd.org/fileViewer.cgi?FSPC=//depot/user/jmg/bktrau/dev/bktrau/bktrau.c&REV=2 I believe there is a way to map a userland page into the kernel, though someone else will have to provide the hints for it... Unless you are trying to move many 10's of megabytes per second, and in very large chuncks, I doubt you'll see much of a difference... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."