My system memory is plentiful (server with 24 GB). On my system, kernel space is allocated 320 MB and 120 MB for the kernel failure. The rest of the memory is used for other purposes. However, when I use __get_free_pages()
to select adjacent pages with order 11, and the kernel does not allocate 2 ^ 10 pages. Why?
According to makelinux
The maximum allowable value for the order of 10 or 11 (corresponding to 1024 or 2048 pages), depending on the architecture. The chances of an order of-10 distribution running on something else other than the just loaded system with a large amount of memory are small.
Why is this so? Each page on my system is 4 KB (4096 bytes), 2 ^ 10 pages = 1024 pages, and the total size is 1024 * 4096 = 4 194 304 (bytes) ~ 4 MB. This is only 4 MB of continuous space, and the kernel is very small: vmlinuz - only 2.1 MB, and initrd - 15 MB. The total memory consumption of the entire kernel is ~ 300 MB. For the kernel should be more than enough to allocate 4 MB of contiguous pages. Even in a regular machine with a kernel / user 1 GB / 3 GB and Iβm sure that the kernel will not use all 1 GB. But how can addition happen only with 4MB adjacent pages? And I think that in the kernel space the memory is not scattered in physical memory (due to the display of virtual memory), but it is linear and continuous.
I tried loading my kernel module first with a distribution of 2 ^ 10 pages, but it fails and resets the stack trace:
[ 6.037056] [<ffffffff810041ec>] dump_trace+0x86/0x2de [ 6.037063] [<ffffffff8122fe83>] dump_stack+0x69/0x6f [ 6.037070] [<ffffffff8108704e>] warn_alloc_failed+0x13f/0x151 [ 6.037076] [<ffffffff8108786a>] __alloc_pages_nodemask+0x80a/0x871 [ 6.037081] [<ffffffff81087959>] __get_free_pages+0x12/0x50
source share