diff options
author | Honggang Li <enjoymindful@gmail.com> | 2014-06-03 01:30:45 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2014-10-13 11:15:09 -0400 |
commit | 9e6a57d2cdee36a6d9c5d5cc3db85713dd416719 (patch) | |
tree | cf8fc0074fd53202b6eb552010326ecc58aa7671 | |
parent | 671312304ec73059a0128ff3ac7a5ced459098ae (diff) |
um: delete unnecessary bootmem struct page array
1) uml kernel bootmem managed through bootmem_data->node_bootmem_map,
not the struct page array, so the array is unnecessary.
2) the bootmem struct page array has been pointed by a *local* pointer,
struct page *map, in init_maps function. The array can be accessed only
in init_maps's scope. As a result, uml kernel wastes about 1% of total
memory.
Signed-off-by: Honggang Li <enjoymindful@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | arch/um/include/shared/mem_user.h | 2 | ||||
-rw-r--r-- | arch/um/kernel/physmem.c | 32 | ||||
-rw-r--r-- | arch/um/kernel/um_arch.c | 7 |
3 files changed, 8 insertions, 33 deletions
diff --git a/arch/um/include/shared/mem_user.h b/arch/um/include/shared/mem_user.h index 46384acd547b..cb84414e3e66 100644 --- a/arch/um/include/shared/mem_user.h +++ b/arch/um/include/shared/mem_user.h | |||
@@ -49,7 +49,7 @@ extern int iomem_size; | |||
49 | extern int init_mem_user(void); | 49 | extern int init_mem_user(void); |
50 | extern void setup_memory(void *entry); | 50 | extern void setup_memory(void *entry); |
51 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); | 51 | extern unsigned long find_iomem(char *driver, unsigned long *len_out); |
52 | extern int init_maps(unsigned long physmem, unsigned long iomem, | 52 | extern void mem_total_pages(unsigned long physmem, unsigned long iomem, |
53 | unsigned long highmem); | 53 | unsigned long highmem); |
54 | extern unsigned long get_vm(unsigned long len); | 54 | extern unsigned long get_vm(unsigned long len); |
55 | extern void setup_physmem(unsigned long start, unsigned long usable, | 55 | extern void setup_physmem(unsigned long start, unsigned long usable, |
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index 30fdd5d0067b..549ecf3f5857 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c | |||
@@ -22,39 +22,19 @@ EXPORT_SYMBOL(high_physmem); | |||
22 | 22 | ||
23 | extern unsigned long long physmem_size; | 23 | extern unsigned long long physmem_size; |
24 | 24 | ||
25 | int __init init_maps(unsigned long physmem, unsigned long iomem, | 25 | void __init mem_total_pages(unsigned long physmem, unsigned long iomem, |
26 | unsigned long highmem) | 26 | unsigned long highmem) |
27 | { | 27 | { |
28 | struct page *p, *map; | 28 | unsigned long phys_pages, highmem_pages; |
29 | unsigned long phys_len, phys_pages, highmem_len, highmem_pages; | 29 | unsigned long iomem_pages, total_pages; |
30 | unsigned long iomem_len, iomem_pages, total_len, total_pages; | ||
31 | int i; | ||
32 | |||
33 | phys_pages = physmem >> PAGE_SHIFT; | ||
34 | phys_len = phys_pages * sizeof(struct page); | ||
35 | |||
36 | iomem_pages = iomem >> PAGE_SHIFT; | ||
37 | iomem_len = iomem_pages * sizeof(struct page); | ||
38 | 30 | ||
31 | phys_pages = physmem >> PAGE_SHIFT; | ||
32 | iomem_pages = iomem >> PAGE_SHIFT; | ||
39 | highmem_pages = highmem >> PAGE_SHIFT; | 33 | highmem_pages = highmem >> PAGE_SHIFT; |
40 | highmem_len = highmem_pages * sizeof(struct page); | ||
41 | |||
42 | total_pages = phys_pages + iomem_pages + highmem_pages; | ||
43 | total_len = phys_len + iomem_len + highmem_len; | ||
44 | 34 | ||
45 | map = alloc_bootmem_low_pages(total_len); | 35 | total_pages = phys_pages + iomem_pages + highmem_pages; |
46 | if (map == NULL) | ||
47 | return -ENOMEM; | ||
48 | |||
49 | for (i = 0; i < total_pages; i++) { | ||
50 | p = &map[i]; | ||
51 | memset(p, 0, sizeof(struct page)); | ||
52 | SetPageReserved(p); | ||
53 | INIT_LIST_HEAD(&p->lru); | ||
54 | } | ||
55 | 36 | ||
56 | max_mapnr = total_pages; | 37 | max_mapnr = total_pages; |
57 | return 0; | ||
58 | } | 38 | } |
59 | 39 | ||
60 | void map_memory(unsigned long virt, unsigned long phys, unsigned long len, | 40 | void map_memory(unsigned long virt, unsigned long phys, unsigned long len, |
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 016adf0985d5..9274eae6ae7b 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c | |||
@@ -348,12 +348,7 @@ int __init linux_main(int argc, char **argv) | |||
348 | start_vm = VMALLOC_START; | 348 | start_vm = VMALLOC_START; |
349 | 349 | ||
350 | setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); | 350 | setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); |
351 | if (init_maps(physmem_size, iomem_size, highmem)) { | 351 | mem_total_pages(physmem_size, iomem_size, highmem); |
352 | printf("Failed to allocate mem_map for %Lu bytes of physical " | ||
353 | "memory and %Lu bytes of highmem\n", physmem_size, | ||
354 | highmem); | ||
355 | exit(1); | ||
356 | } | ||
357 | 352 | ||
358 | virtmem_size = physmem_size; | 353 | virtmem_size = physmem_size; |
359 | stack = (unsigned long) argv; | 354 | stack = (unsigned long) argv; |