I'm allocating a large block of shared memory using shmget on an embedded system:
shmid = shmget(key, 16777216, IPC_CREAT | 0666)
The system is running uClinux (2.6.28 Linux Kernel) using Slab allocator. I've got no MMU on the CPU.
Once in a while, when running the above shmget command, I get a page allocation failure. This also happens when I'm running out of available RAM, but this also happens once in a while when I have plenty of RAA available.
I suspect the culprit is fragmentation, but I'm not quite sure - so my questions is, can this error be caused because the IPC subsystem requires a continuous physical 16Mb segment for this procedure, and cannot find one due to fragmented memory, throwing the allocation failure, or does the issue lie elsewhere?
In a !MMU
system, you do not have virtual memory, so your supposition is correct - a contiguous block of physical memory is required for that mapping.
You can alleviate this issue by refactoring your application to use multiple smaller shared memory blocks, and/or first allocating the shared memory as early as possible after boot.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.