When searching for a suitable block of memory on the free list,
skip blocks that are too big by a factor of two or greater. This avoids some cases of extremely inefficient memory use that can occur when large (e.g. 64k) blocks on the free list get used when allocating a 4k chunk of 64-byte fragments. Because fragments have their own free list, the 60k difference got lost forever every time.
This commit is contained in:
parent
5b775a536b
commit
6d68eec474
@ -142,7 +142,8 @@ usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
|
||||
s = splusb();
|
||||
/* First check the free list. */
|
||||
for (p = LIST_FIRST(&usb_blk_freelist); p; p = LIST_NEXT(p, next)) {
|
||||
if (p->tag == tag && p->size >= size && p->align >= align) {
|
||||
if (p->tag == tag && p->size >= size && p->size < size * 2 &&
|
||||
p->align >= align) {
|
||||
LIST_REMOVE(p, next);
|
||||
usb_blk_nfree--;
|
||||
splx(s);
|
||||
|
Loading…
x
Reference in New Issue
Block a user