jbonf
2002-Oct-20 07:02 UTC
Can I allocate memory dynamically when enqueue or dequeue? (adding some algorithms in kernel)
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 ----------------------------------------------------------------- < 每天都 Yahoo!奇摩 > www.yahoo.com.tw _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
Werner Almesberger
2002-Oct-20 07:25 UTC
Re: Can I allocate memory dynamically when enqueue or dequeue? (adding some algorithms in kernel)
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 mollocNo, 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/