How does System V IPC deal with fragmentation when allocating a large block of memory using "shmget"?
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 fragme开发者_运维技巧nted 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.
精彩评论