simple memory malloc and free in ip_output.c

Guibin(Bill) Tian gbtian at gmail.com
Thu Jan 2 12:42:48 EST 2014


Thank you sirs. But in fact, I don't alloc/free for every packet. I did
exactly as what you said---reuse.

I am a little confused why GFP_ATOMIC can work but GFP_KERNEL will cause
the system to panic.  Does it because that GFP_KERNEL can sleep in kmalloc,
then ip_xmit_queue will be held or something? But anyway, GFP_ATOMIC works
perfectly.


On Thu, Jan 2, 2014 at 1:15 AM, Mulyadi Santosa
<mulyadi.santosa at gmail.com>wrote:

> On Thu, Jan 2, 2014 at 12:41 PM,  <Valdis.Kletnieks at vt.edu> wrote:
> > On Thu, 02 Jan 2014 12:12:49 +0700, Mulyadi Santosa said:
> >
> >> Other than what others have said, IMHO it is better to avoid such
> >> rapid alloc/free, assuming your code fragment is running on every
> >> packet reception/sending.
> >>
> >> Instead, I suggest to allocate the memory before the ip_queue_xmit and
> >> use-reuse it inside ip_queue_xmit.
> >
> > Be careful with re-entrancy issues - you'll want a separate instance of
> memory
> > for all possible concurrent callers of ip_queue_xmit (you may need one
> per
> > active interface, because you can e transmitting packets on multiple
> interfaces
> > at the same time).
>
> Ah yes, you're correct Valdis. Thanks for note.
>
>
>
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140102/4e4cd4dd/attachment.html 


More information about the Kernelnewbies mailing list