LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Recycle SKB using SKB pool (https://www.linuxquestions.org/questions/linux-kernel-70/recycle-skb-using-skb-pool-4175453059/)

Pankajgoyal38 03-07-2013 12:57 AM

Recycle SKB using SKB pool
 
Hello Guys,

Actually I am developing a module which is transferring the skb after filling it self. But the issue I am facing is, speed is too slow. only 1K pkt per sec. I think that is taking time for allocating memory to skb and freeing it.

I found on googling that we can make it efficient if we use skb pool in our driver module itself. I am kernel newbie, could any one plz tell me, how to implement it or it is not a good idea.

Thanks a lot.

Pankaj Singh

sundialsvcs 03-07-2013 09:32 AM

There's absolutely nothing that a CPU could possibly do, to cause a network adapter to only manage 1 kb/sec!

Memory allocation and deallocation (pooling ...) takes microseconds if not nanoseconds to do. Start by measuring the traffic that's taking place between the two machines, perhaps using a hardware monitoring device. The most likely culprit is always the application program that you're using for test purposes. It might not be behaving properly.

Pankajgoyal38 03-07-2013 09:41 PM

Thank you sir for early reply.

But as you say pooling takes microseconds. Speed is 1000 packet per second. In terms of Bytes it is more. M using Jradius Client for testing purpose.

Actually my scenario is :
I have a network driver, it receives pkt from network through hook then put info into KFIFO. another module, in which I have thread functionality for every online cpu. this module takes pkt info from KFIFO and again allocate skb, fill info into that skb with some extra header(RADIUS header) and again send back, then free the skb through kfree_skb(skb). It happens every time when it receives pkt from KFIFO.

This allocation and deallocation of skb every time takes time I think. So You please tell me that if we take a pool, which we will allocate at start of module itself. Then whenever we need any new skb, we will take it from that pool. I think it will take less time.

I don't know weather it is right or wrong, even don't know how to implement it. You please explain me. Should I do it or not. If yes then How??

M really thank full to you. My English is not that much good. Beg me pardon.

Pankaj Singh.

sundialsvcs 03-11-2013 11:48 AM

"I have thread functionality for every CPU." I do not understand what you mean.

Please describe the entire application, kernel-driver and otherwise.

Pankajgoyal38 03-11-2013 10:39 PM

Hello sir,

As we do in kernel, like "for_each_online_cpu()" I have created a kernel thread. That thread is bounded to available cpu. Thread's function is like, It will pick one packet from KFIFO. that packet is having information about coming IP,mac, etc. It will add these info to new allocated skb and send it using "dev_xmit()".

The allocation of skb is taking time in that thread. That's why I thought, I can use pre-allocated pool of skb. So that I won't be needed to allocate and de-allocate skb every time.

I have implemented it. But the thing is its getting more time, then previous.
As of now my statistics is :-

When allocate an skb - time taken > 400 mostly always greater then 1100.
de-allocation - time > 50-60

In terms of pool :-
dequeue the skb from pool - time taken > 300-400
again enqueue back to pool - time > 450
In between we have to re-initialize the skb that takes - time 300-700

Time is in terms of cpu ticks.

Thats all.

It may be possible that I am not implementing pool in a proper manner.
So, Please tell explain me, whatever I am doing is right or wrong.
Tell me the mechanism of skb pool implementation.

Thanks
Pankaj Singh


All times are GMT -5. The time now is 11:20 AM.