From: Gianni Tedesco
Date: Thu Nov 06 2003 - 06:10:11 EST

On Wed, 2003-10-29 at 05:09, odain2@xxxxxxxxxxxxxx wrote:
> I believe that in normal operation each packet
> (or with NICs that do interrupt coalescing, every n packets) causes an
> interrupt which causes a context switch, the kernel then copies the data
> from the DMA buffer to the shared buffer and does a RETI. That's fairly
> expensive.

The cost of handling that interrupt and doing an iret is unavoidable
(ignoring NAPI). The main point you are missing with the ring buffer is
that if packets come in at a fast enough rate, the usermode task never
context switches, because there is always data in the ring buffer, so it
loops in usermode forever.

The problem could be the packets are coming in just too slow to allow
the ring buffer to work properly and causing the application to sleep on
poll(2) every time. This would kill performance at pathelogical packet
rates I guess.

You could work around this by spinning for a few thousand spins before
calling poll(2) (or even indefinately for that matter, and allow the
kernel to preempt you if need be).

// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D

Attachment: signature.asc
Description: This is a digitally signed message part