Subject: Re: Measuring memory to memory copy operations (+ interrupts, DMA)
To: Eduardo Horvath <eeh@netbsd.org>
From: Kamal R Prasad <kamalrpr@in.ibm.com>
List: tech-kern
Date: 08/19/2003 18:35:57
Hello,
If I understand correctly, if the userland page is pinned -then
memcpy(userspace, kernelspace) is as expensive as within a single context.
Pl. correct me if Im wrong.
thanks
-kamal
Eduardo Horvath <eeh@netbsd.org>
08/18/2003 11:55 PM
To: Kamal R Prasad/India/IBM@IBMIN
cc: der Mouse <mouse@Rodents.Montreal.QC.CA>,
tech-kern@netbsd.org
Subject: Re: Measuring memory to memory copy operations (+
interrupts, DMA)
On Mon, Aug 18, 2003 at 04:01:07PM +0530, Kamal R Prasad wrote:
> > I am modifying [the clock interrupt handler] and want to add a couple
> > of mem-to-mem copys [copy from userspace to kernel space] in the
> > handler.
>
> > The code is on AIX -but I expect similar performance on most versions
> > of UNIX.
>
> >Well, this is a NetBSD list. If you want AIX-specific advice, this is
> >a wrong place to ask; my comments will apply to NetBSD.
>
> Im aware of this.
>
> >This is a rather dangerous thing to do. Unless you have arranged for
> >something to be present in every process at some userspace address
> >that's fixed (or otherwise easily computable), there's no safe way to
> >do this. Even if you have, I'm not entirely convinced it's enough, as
> >I'm not sure there's always a userland in the MMU (for example, if no
> >process has been run since the last process-exit, I'm not sure what's
> >left in the MMU - it's probably port-specific).
>
> http://netbsd.gw.com/cgi-bin/man-cgi?profil+2+NetBSD-current
>
> this function and the code for updating timer ticks is inside the
kernel.
>
> > is it affordable to copy in about 100 bytes twice [and copy out a few
> > bytes] within the routine if it is being called every one second?
>
> >"Probably." This depends on your CPU speed, how expensive copyin() is
> >on the port you're using, and how much performance degradation you're
> [snip]
>
> lets assume a 1 GHZ cpu speed and the port is obviously powerpc.
> I am looking for info about overhead associated with copying from one
> context to another.
copyin()/copyout() can result in pages being retrieved from swap. If
this operation is done in the clock interrupt handler you can end up
with a stopped clock for the duration of the disk I/O or worse, a hard
hang as the storage driver waits for an interrupt that never arrives
because it's currently masked.
Eduardo