[Click] Kernel BufferQueue
Eddie Kohler
kohler at cs.ucla.edu
Tue Sep 19 10:24:52 EDT 2006
Hi Beyers,
So Click actually supports a type of allocation that dynamically decides
whether to use kmalloc() or vmalloc(), based on the size of the data to be
allocated. The allocation and freeing functions are
void *ptr = CLICK_LALLOC(size_t size);
CLICK_LFREE(void *ptr, size_t size);
Note that you have to specify the size when you delete the object as well as
when you allocate it.
I've gone ahead and changed the Queue-derived elements to use LALLOC and LFREE
instead of new[] and delete[]. That should mean that you can use regular
Queues with huge capacities, no need for a special element.
Thanks,
Eddie
Beyers Cronje wrote:
> Hi Eddie, all,
>
> I had a need to buffer incoming packets in Click kernel module for two
> seconds on an interface with around 350+mbps traffic load with an
> average packet count of 80,000pps. In other words I needed to buffer at
> least 160,000 packets at any given time in the kernel module. Any
> SimpleQueue derived queue's maximum capacity is 32761, limited by
> kmalloc's maximum bucket size of 131048 bytes. Click-install will crash
> the kernel if you specify any larger capacity.
>
> The attached element is a linuxmodule only element that uses vmalloc
> instead of kmalloc to allocate queue memory. It installs and seems to
> run fine on my system with a queue capacity of 500,000. It is derived
> from NotifierQueue and overrides methods used in SimpleQueue to allocate
> and free memory (initialize, live_reconfigure & cleanup).
>
> Feel free to use or include in Click. Also feel free to rename as I
> couldnt come up with a better name than BufferQueue :)
>
> One drawback of calling vmalloc directly is that click/meminfo will not
> reflect this allocation. Maybe a Click newvm(size_t) function can help
> with this.
>
> Cheers
>
> Beyers Cronje
More information about the click
mailing list