Subject: Re: Measuring memory to memory copy operations (+ interrupts, DMA)
To: None <tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 08/18/2003 04:35:58
> 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.

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).

> 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
willing to accept.  Oh, and your clock interrupt rate, too, since you
mustn't take longer than the inter-interrupt delay (or perhaps twice
it, depending on how clock interrupts work).  If you're doing it only
once a second, though, it's much less likely to have a severe
performance impact.

I do rather wonder, though, how it could possibly be useful to fiddle
something in the internals of whatever process happens to be current
(if any) once a second, and why it can't be done with existing
facilities.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B