netfilter KO performance
I've build a netfilter driver which receives a lot of data (800 Mbit/sec) and copies it to its internal buffers (using skb_copy_bits).
I've tried checking its CPU usage (using /proc/stat or top) and found that the CPU usage is very low (less than 0.5%).
However when I copy about the same amount of data in user space application I get much higher CPU usage.
Does anyone has an idea why do I get such low CPU usage inside the kernel?
I suspect that maybe some statistics are disabled, but I can't be sure.
Do you copy also in the same way, I mean some alike program. That can make difference.
Does your copy make directories or not, and the same for bothe your copy programs?
It must be a reason in that direction.
But not easy for me to tell, not knowing the details.
b.t.w copying in memory is much faster the in filesystem...???
I don't understand you completely...
The netfilter driver is copying buffers received from the network to its internal buffers and from there it is passed to the user.
It has nothing to do to file system.
Well let me say it this way. Is your netfilter a kernel module?
Then if you use exactly the same program to copy some data as normal user, it is slower? I understand of what you said it is all about copying in memory.
Only thing I know userspace has some overhead because of priveledge checking, but I have no idea how much that would be.
Kernel space programs are trusted an can run without any delay. But I don't think it would differ very much.
Yes my netfilter is kernel module.
I found out that there is a flag called CONFIG_IRQ_TIME_ACCOUNTING (I'm working with kernel version 3.68).
This flag enables collection of time statistics inside IRQs and SIRQs.
I turend it on and got the following results:
5.61% CPU usage (using an application based on /proc/stat) even without my KO.
After inserting my KO I got 5.91 CPU usage.
I still can't understand why the CPU usage is that high when my KO isn't inserted.
Maybe it is beacuse of the high interrupt rate.
I'll try to check it out.
Thanks for your help,