Allocate aligned memory

Suleiman Souhlal ssouhlal at FreeBSD.org
Fri Dec 15 00:51:20 PST 2006


Marc Lörner wrote:
> Hello all,
> 
> I want to allocate 120KB of memory thats aligned to 32KB.
> I already saw/found the function contigmalloc, now my question is, why 
> following functioncall never does return with an resulting address, instead 
> null is returned?
> 
> unsigned long *p = (unsigned long*) 
> 	contigmalloc(120*1024, M_DEVBUF, M_WAITOK, 0, (1<<22), 32*1024, 1024*1024);

Have you considered the fact that there might be no 32K-aligned 120KB chunk of memory in the range you specified?

My suggestion is to make the your high limit (currently 1 << 22) MUCH higher, if possible. Also, getting rid of the 1MB boundary might help.

-- Suleiman


More information about the freebsd-hackers mailing list