Vmalloc可以获得的地址在VMALLOC_START到VMALLOC_END的范围中。这两个符号在<asm/pgtable.h>中定义:
* arch/arm/include/asm/pgtable.h
/*
* Just any arbitrary offset to the start of the vmalloc VM area: the
* current 8MB value just means that there will be a 8MB "hole" after the
* physical memory until the kernel virtual memory starts. That means that
* any out-of-bounds memory accesses will hopefully be caught.
* The vmalloc() routines leaves a hole of 4kB between each vmalloced
* area for the same reason. ;)
*
* Note that platforms may override VMALLOC_START, but they must provide
* VMALLOC_END. VMALLOC_END defines the (exclusive) limit of this space,
* which may not overlap IO space.
*/
#ifndef VMALLOC_START
#define VMALLOC_OFFSET (8*1024*1024)
#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
#endif
high_memory值在这里定义:
/* arch/arm/mm/init.c */
void __init bootmem_init(struct meminfo *mi)
{
……
high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
}
在我们的板子上,这些值为:
lzm: bootmem_init : high_memory = E0000000 <--------- 3G+512M , high_memory既实际内存最大物理地址对应的的内核逻辑地址
加8MB
lzm: bootmem_init : VMALLOC_START = E0800000 <--------- 3G+512M+8M (8M为内核规定的一个gap) ,vmalloc分配的起始地址(内核空间)
用vmalloc=0k 启动后
Using UBoot passing parameters structure
vmalloc area too small, limiting to 16MB 默认128m,现在变成16m,少了112m
Memory policy: ECC disabled, Data cache writeback
Truncating RAM at 20000000-3fffffff to -26ffffff (vmalloc region overlap). 提高到624m
lzm: bootmem_init : high_memory = E7000000 <--------- 3G+512M +112M,升高了112m
lzm: bootmem_init : VMALLOC_START = E7800000
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 158496
Kernel command line: root=/dev/nfs nfsroot=192.168.73.60:/rootfs rw noinitrd init=/sbin/init ip=192.168.73.59:192.168.73.1:192.168.73.1:255.255.255.0:target:eth0:off console=ttyS0,115200 console=tty1 mtdparts=spi_flash:0x100000?(uboot),0x700000?x100000(linux-root) mac=00:11:65:34:43:22 video=dovefb:lcd0:1024x768-32?0 clcd.lcd0_enable=1 vmalloc=0k
PID hash table entries: 4096 (order: 12, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 512MB 112MB = 624MB total
Memory: 620032KB available (5244K code, 300K data, 4172K init, 0K highmem)
Hierarchical RCU implementation.
。。。
但是出现了错误:
vmap allocation for size 16781312 failed: use vmalloc=<size> to increase size.
ERROR: Failed to ioremap Flash device at physical base 0xf4000000
参考链接: