]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
um: delete unnecessary bootmem struct page array
authorHonggang Li <enjoymindful@gmail.com>
Tue, 3 Jun 2014 05:30:45 +0000 (13:30 +0800)
committerRichard Weinberger <richard@nod.at>
Mon, 13 Oct 2014 15:15:09 +0000 (17:15 +0200)
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>
arch/um/include/shared/mem_user.h
arch/um/kernel/physmem.c
arch/um/kernel/um_arch.c

index 46384acd547b7590bd75e4f564cf203327e2e522..cb84414e3e6663eb280c555d88ec447c5c6cad27 100644 (file)
@@ -49,7 +49,7 @@ extern int iomem_size;
 extern int init_mem_user(void);
 extern void setup_memory(void *entry);
 extern unsigned long find_iomem(char *driver, unsigned long *len_out);
-extern int init_maps(unsigned long physmem, unsigned long iomem,
+extern void mem_total_pages(unsigned long physmem, unsigned long iomem,
                     unsigned long highmem);
 extern unsigned long get_vm(unsigned long len);
 extern void setup_physmem(unsigned long start, unsigned long usable,
index 30fdd5d0067b26c91fb8c831da5a1d4008c79e22..549ecf3f5857441c95e4344b6aabc99ce4723f7f 100644 (file)
@@ -22,39 +22,19 @@ EXPORT_SYMBOL(high_physmem);
 
 extern unsigned long long physmem_size;
 
-int __init init_maps(unsigned long physmem, unsigned long iomem,
+void __init mem_total_pages(unsigned long physmem, unsigned long iomem,
                     unsigned long highmem)
 {
-       struct page *p, *map;
-       unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
-       unsigned long iomem_len, iomem_pages, total_len, total_pages;
-       int i;
-
-       phys_pages = physmem >> PAGE_SHIFT;
-       phys_len = phys_pages * sizeof(struct page);
-
-       iomem_pages = iomem >> PAGE_SHIFT;
-       iomem_len = iomem_pages * sizeof(struct page);
+       unsigned long phys_pages, highmem_pages;
+       unsigned long iomem_pages, total_pages;
 
+       phys_pages    = physmem >> PAGE_SHIFT;
+       iomem_pages   = iomem   >> PAGE_SHIFT;
        highmem_pages = highmem >> PAGE_SHIFT;
-       highmem_len = highmem_pages * sizeof(struct page);
-
-       total_pages = phys_pages + iomem_pages + highmem_pages;
-       total_len = phys_len + iomem_len + highmem_len;
 
-       map = alloc_bootmem_low_pages(total_len);
-       if (map == NULL)
-               return -ENOMEM;
-
-       for (i = 0; i < total_pages; i++) {
-               p = &map[i];
-               memset(p, 0, sizeof(struct page));
-               SetPageReserved(p);
-               INIT_LIST_HEAD(&p->lru);
-       }
+       total_pages   = phys_pages + iomem_pages + highmem_pages;
 
        max_mapnr = total_pages;
-       return 0;
 }
 
 void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
index 016adf0985d522ccfb5f22e6d287bb60dfdb4e61..9274eae6ae7b81fb976f059ea9d8afb6b420722a 100644 (file)
@@ -348,12 +348,7 @@ int __init linux_main(int argc, char **argv)
        start_vm = VMALLOC_START;
 
        setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
-       if (init_maps(physmem_size, iomem_size, highmem)) {
-               printf("Failed to allocate mem_map for %Lu bytes of physical "
-                      "memory and %Lu bytes of highmem\n", physmem_size,
-                      highmem);
-               exit(1);
-       }
+       mem_total_pages(physmem_size, iomem_size, highmem);
 
        virtmem_size = physmem_size;
        stack = (unsigned long) argv;