Subject: Re: Measuring memory to memory copy operations (+ interrupts, DMA)
To: Kamal R Prasad <kamalrpr@in.ibm.com>
From: Eduardo Horvath <eeh@NetBSD.ORG>
List: tech-kern
Date: 08/19/2003 17:22:59
Potentially, but it depends on the implementation of copyin()/copyout()
for that particular operating system.
Machines which support two or more address spaces at the same time,
such as SPARC, use use memcpy with a few hooks to handle trap recovery.
But PowerPC only supports a single address space, so the copyin()/copyout()
implementations are a bit more compilcated. Either the page needs to be
mapped into the kernel, which is usually an expensive operation, or it
needs to use some machine-dependent magic to allow access to user
addresses.
I don't know how AIX does this.
Eduardo
On Tue, Aug 19, 2003 at 06:35:57PM +0530, Kamal R Prasad wrote:
> 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
>
>