LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 03-07-2013, 12:57 AM   #1
Pankajgoyal38
LQ Newbie
 
Registered: Sep 2012
Posts: 9

Rep: Reputation: Disabled
Smile 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
 
Old 03-07-2013, 09:32 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
Old 03-07-2013, 09:41 PM   #3
Pankajgoyal38
LQ Newbie
 
Registered: Sep 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-11-2013, 11:48 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
"I have thread functionality for every CPU." I do not understand what you mean.

Please describe the entire application, kernel-driver and otherwise.
 
Old 03-11-2013, 10:39 PM   #5
Pankajgoyal38
LQ Newbie
 
Registered: Sep 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
populating headers fields in skb karan2386 Linux - Kernel 1 03-31-2012 08:59 AM
contents of skb->transport_header karan2386 Linux - Kernel 0 03-22-2012 08:45 AM
how to tcp seq from skb ycli Linux - Software 1 01-19-2009 04:22 PM
how to get tcp seq from skb ycli Linux - Software 0 01-19-2009 04:10 PM
group the outgoing skb's into single skb and then send grouped skb. venkatesh111 Linux - Networking 0 04-27-2006 01:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration