Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jan 2006 00:19:03 -0800
From:      John-Mark Gurney <gurney_j@resnet.uoregon.edu>
To:        Bharma Ji <bharmaji@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How to pin a userland page in memory(avoid copyin and copyout)
Message-ID:  <20060131081902.GY69162@funkthat.com>
In-Reply-To: <67beabb0601301146h6c5034fao998bf573f1e89613@mail.gmail.com>
References:  <67beabb0601301146h6c5034fao998bf573f1e89613@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060131081902.GY69162>