contiguous memory allocation problem
Hans Petter Selasky
hselasky at c2i.net
Sat Jul 1 09:07:08 UTC 2006
On Friday 30 June 2006 22:32, Peter Jeremy wrote:
> On Fri, 2006-Jun-30 20:29:28 +0200, Hans Petter Selasky wrote:
> >I sometimes see that the USB driver is unable to allocate contiguous
> > memory for itself. For example I noticed that FreeBSD was unable to
> > allocate 350kbytes of contiguous memory after that I had run "konqueror",
> > the KDE web browser and various other memory consuming applications for a
> > while.
>
> I reported this about 18 months ago and I'm fairly certain you even
> contributed to the thread at the time.
>
> >Any comments?
>
> The latest concensus seems to be that the USB system should make use of
> the scatter-gather facilities in the hardware to avoid the need to
> allocate large contiguous memory chunks. iedowse@ had mostly finished
> implementing this in mid May.
Yes, but scatter and gather will add extra complexity to the driver, and maybe
an extra memory copy in most cases. The idea is to allocate less than or
equal to a page of memory, and then avoid the problem?
The most important thing is to keep memory allocations of constant size. For
example under my USB system, all memory is allocated at attach. There is no
longer allocation and freeing of memory during usage, with a few exceptions.
I was thinking I could pre-allocate 2-4MB for the USB system, then make a
list of freed memory blocks, and then search this list first, before
allocating new memory.
Depending on how many different kinds of equipment one plugs, this should work
fine.
What do you think?
--HPS
More information about the freebsd-hackers
mailing list