um: switch to NO_BOOTMEM
authorMike Rapoport <rppt@linux.vnet.ibm.com>
Fri, 26 Oct 2018 22:05:02 +0000 (15:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Oct 2018 23:25:20 +0000 (16:25 -0700)
Replace bootmem initialization with memblock_add and memblock_reserve calls
and explicit initialization of {min,max}_low_pfn.

Link: http://lkml.kernel.org/r/1533326330-31677-7-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: Richard Weinberger <richard@nod.at>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Ley Foon Tan <ley.foon.tan@intel.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/um/Kconfig
arch/um/kernel/physmem.c

index 6b9938919f0bab07e46fefbe97b45c4cab663a8c..10c15b8853ae5a56c2d4a200c80ceef956b690eb 100644 (file)
@@ -12,6 +12,8 @@ config UML
        select HAVE_UID16
        select HAVE_FUTEX_CMPXCHG if FUTEX
        select HAVE_DEBUG_KMEMLEAK
        select HAVE_UID16
        select HAVE_FUTEX_CMPXCHG if FUTEX
        select HAVE_DEBUG_KMEMLEAK
+       select HAVE_MEMBLOCK
+       select NO_BOOTMEM
        select GENERIC_IRQ_SHOW
        select GENERIC_CPU_DEVICES
        select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_SHOW
        select GENERIC_CPU_DEVICES
        select GENERIC_CLOCKEVENTS
index 0eaec0e24767236c6eead47d0e85f5225c5e8bf5..296a91a04598b390bff809e0c178be89e4542d4f 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/module.h>
 #include <linux/bootmem.h>
 
 #include <linux/module.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/mm.h>
 #include <linux/pfn.h>
 #include <asm/page.h>
 #include <linux/mm.h>
 #include <linux/pfn.h>
 #include <asm/page.h>
@@ -80,23 +81,18 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
                          unsigned long len, unsigned long long highmem)
 {
        unsigned long reserve = reserve_end - start;
                          unsigned long len, unsigned long long highmem)
 {
        unsigned long reserve = reserve_end - start;
-       unsigned long pfn = PFN_UP(__pa(reserve_end));
-       unsigned long delta = (len - reserve) >> PAGE_SHIFT;
-       unsigned long offset, bootmap_size;
-       long map_size;
+       long map_size = len - reserve;
        int err;
 
        int err;
 
-       offset = reserve_end - start;
-       map_size = len - offset;
        if(map_size <= 0) {
                os_warn("Too few physical memory! Needed=%lu, given=%lu\n",
        if(map_size <= 0) {
                os_warn("Too few physical memory! Needed=%lu, given=%lu\n",
-                       offset, len);
+                       reserve, len);
                exit(1);
        }
 
        physmem_fd = create_mem_file(len + highmem);
 
                exit(1);
        }
 
        physmem_fd = create_mem_file(len + highmem);
 
-       err = os_map_memory((void *) reserve_end, physmem_fd, offset,
+       err = os_map_memory((void *) reserve_end, physmem_fd, reserve,
                            map_size, 1, 1, 1);
        if (err < 0) {
                os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p "
                            map_size, 1, 1, 1);
        if (err < 0) {
                os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p "
@@ -113,9 +109,11 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
        os_write_file(physmem_fd, __syscall_stub_start, PAGE_SIZE);
        os_fsync_file(physmem_fd);
 
        os_write_file(physmem_fd, __syscall_stub_start, PAGE_SIZE);
        os_fsync_file(physmem_fd);
 
-       bootmap_size = init_bootmem(pfn, pfn + delta);
-       free_bootmem(__pa(reserve_end) + bootmap_size,
-                    len - bootmap_size - reserve);
+       memblock_add(__pa(start), len + highmem);
+       memblock_reserve(__pa(start), reserve);
+
+       min_low_pfn = PFN_UP(__pa(reserve_end));
+       max_low_pfn = min_low_pfn + (map_size >> PAGE_SHIFT);
 }
 
 int phys_mapping(unsigned long phys, unsigned long long *offset_out)
 }
 
 int phys_mapping(unsigned long phys, unsigned long long *offset_out)