Skip to contentSkip to conversation

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

LARTC jbonf 2 participants 2 messages Oct 20, 2002

lore
Share & tools
lore

jbonf

author
#0 lore raw

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 or just a suggest that do not use it
often? Thanks for your help. bon

-----------------------------------------------------------------
< ¨C¤Ñ³£ Yahoo!©_¼¯ > www.yahoo.com.tw
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#1 lore raw

Re: [LARTC] Can I allocate memory dynamically when enqueue or dequeue? (adding some algorithms in ke

Quoted 4 lines · jbonf

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.

Quoted 1 line

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

Signature · 6 lines
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         [email protected] /
/_http://www.almesberger.net/____________________________________________/
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/