On Mon, 25 Aug 2014 20:30:00 +0800, lx said: > I have two ideas to handle the packet. > 1.I allocate a memory pool and mmap into userspace, when packet is coming, > I copy packet into the memory pool, then, userspace can access it. > 2.When packet is coming , I mmap the data of packet into userspace every > time, then userspace can access this packet. > Which one is better, why? Hint: mmap is expensive, you don't want to do it on every packet when the packets are showing up at 100K/second. You might want to see which way do the 10G ethernet drivers do it? If you're an NFS server trying to flip 100K packets a second *plus* do the disk I/O, making it as cheap as possible is really important. Also, look carefully how existing drivers actually implement zero-copy (it's trickier than it looks) Also, if you're trying to flip packets fast, you forgot: MTU=9000 if your network setup allows it - that gets you a 6x reduction in interrupts on bulk transfers. Interrupt coalescing, where the card doesn't even bother waking you up on every packet. You'll also want to be looking at hardware that does TSO/GSO, at 10G you'll be wanting to offload as many processing cycles as you can....
Attachment:
pgpeGpQm84s0K.pgp
Description: PGP signature
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies