Re: Can I allocate memory dynamically when enqueue or dequeue? (adding some algorithms in kernel)

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



jbonf wrote:
>     Hi, I'm adding a queuing disc. inside kernel. I am
> confused that it seems few other qdiscs allocate
> memory dynamically. Is it invalid to use memory calls
> like molloc

No, you can kmalloc(...,GPF_ATOMIC) in enqueue and dequeue
functions.

> or just a suggest that do not use it often?

As a general rule, enqueue and dequeue are performance-critical,
so if you can move processing elsewhere, that's better. (E.g. if
you just need to allocate some scratch space, you might as well
do this at qdisc init time - calls to enqueue, dequeue, and
requeue are serialized through dev->queue_lock.)

Of course, kmalloc and kfree are reasonably fast, so if you
really need to use them, that's no tragedy. I'd be more worried
about the times it takes to do whatever you're going to do with
that kmalloc'ed space ...

For more details on locking in traffic control and such, you may
want to read tc.ps in
ftp://icaftp.epfl.ch/pub/people/almesber/junk/tc-04FEB2001-0.tar.gz
it's a bit old and also unfinished, but it should give you an
idea of how things are organized.

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux