[Top] [All Lists]

Re: Huge buffer allocation: best place

Subject: Re: Huge buffer allocation: best place
From: C Michael Sundius <>
Date: Wed, 08 Oct 2008 09:39:28 -0700
Authentication-results: sj-dkim-1;; dkim=neutral
Original-recipient: rfc822;
User-agent: Thunderbird (X11/20080501)
Luigi 'Comio' Mantellini Wrote:

> I need to allocate a huge contiguous buffer (~6MByte) shared with a secondary cpu > (a packet processor). Which is the best place and the best way to do this?

> The main problem is that using a simple kmalloc at module init time there isn't sufficient > contiguous memory to cover the request. I should use (I suppose) the alloc_bootmem_* > macros but I'm not sure where is the best place to reserve my memory. For now I defined
> a global bad huge vector... but I'm not happy for this solution...

I have seen a similar need and allocate driver buffers from the bootmem allocator, however if you use Highmem you might prefer to use memory in high memory since the low memory is limited. This presents a problem since the bootmem allocator does not manage memory
in the high memory zone.

I am currently working on a extremely simple allocation method for allocating large driver buffers early (say after paging_init() and sparse_init() but before mem_init() ) for exactly this

I'm wondering if anyone else out there has run into these problems and how they solved them. up to now, we have blindly carved off a huge chunk of the highmemory and required each driver to allocate the driver memory resource at compile time. (via a big ugly struct with lots of magic numbers the drivers map (kmap) these memory areas in separately). This error prone a best and is problematic since each version of our box has different resource needs (and we want just one
kernel). Thus the need for runtime allocation of such resources.

Luigi, are you running w/ highmem enabled? if not I suggest just using the bootmem allocator. we call a function called platform_alloc_bootmem() which is in our platform specific code, it is called just after (or at the end of) the bootmem_init() function in the setup.c (after they reserve
space for the initrd and kernel).

there is another function called resource_init() which I think could be a good place for you to
make a call to some platform_specific resource allocation function.
(one other question: is any of that resource --from resrouce.c-- used in the mips code?)


- - - - - Cisco - - - - - This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.

<Prev in Thread] Current Thread [Next in Thread>