1、刚工作时做Linux 流控;后来做安全操作系统;再后来做操作系统加固;现在做TCP 加速。唉!没离开过类Unix!!!但是水平有限。。
全部博文(353)
分类:
2011-12-08 13:04:18
原文地址:使用alloc_bootmem()分配大内存 作者:CUDev
diff --git a/mm/bootmem.c b/mm/bootmem.c index 00a9697..8f3ef0d 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -487,3 +487,40 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, return __alloc_bootmem_core(pgdat->bdata, size, align, goal, ARCH_LOW_ADDRESS_LIMIT); } + +static int __init reserve_setup(char *str) +{ + unsigned long long start, size; + + size = memparse(str, &str); + if (*str != '@') + return 1; + str++; + start = memparse(str, &str); + + reserve_bootmem(start, size); + printk(KERN_INFO "bootmem: Reserved %llu bytes @ 0x%llx\n", size, start); + return 1; +} + +static int __init alloc_setup(char *str) +{ + unsigned long long size; + unsigned int nid = 0; + void *start; + + size = memparse(str, &str); + if (*str == '@') { + str++; + get_option(&str, &nid); + } + + start = alloc_bootmem_pages_node(NODE_DATA(nid), size); + if (start) + printk(KERN_INFO "bootmem: Allocated %llu bytes at 0x%p(0x%p) on node %u\n", + size, start, (void *) virt_to_phys(start), nid); + return 1; +} + +__setup("bootmem-reserve=", reserve_setup); +__setup("bootmem-alloc=", alloc_setup); |