Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: remove nobootmem

Move a few remaining functions from nobootmem.c to memblock.c and remove
nobootmem

Link: http://lkml.kernel.org/r/1536927045-23536-28-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Serge Semin <fancer.lancer@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mike Rapoport and committed by
Linus Torvalds
bda49a81 7c2ee349

+104 -129
-1
mm/Makefile
··· 42 42 debug.o $(mmu-y) 43 43 44 44 obj-y += init-mm.o 45 - obj-y += nobootmem.o 46 45 obj-y += memblock.o 47 46 48 47 ifdef CONFIG_MMU
+104
mm/memblock.c
··· 82 82 * initialization compltes. 83 83 */ 84 84 85 + #ifndef CONFIG_NEED_MULTIPLE_NODES 86 + struct pglist_data __refdata contig_page_data; 87 + EXPORT_SYMBOL(contig_page_data); 88 + #endif 89 + 90 + unsigned long max_low_pfn; 91 + unsigned long min_low_pfn; 92 + unsigned long max_pfn; 93 + unsigned long long max_possible_pfn; 94 + 85 95 static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; 86 96 static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; 87 97 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP ··· 1886 1876 return 0; 1887 1877 } 1888 1878 early_param("memblock", early_memblock); 1879 + 1880 + static void __init __free_pages_memory(unsigned long start, unsigned long end) 1881 + { 1882 + int order; 1883 + 1884 + while (start < end) { 1885 + order = min(MAX_ORDER - 1UL, __ffs(start)); 1886 + 1887 + while (start + (1UL << order) > end) 1888 + order--; 1889 + 1890 + memblock_free_pages(pfn_to_page(start), start, order); 1891 + 1892 + start += (1UL << order); 1893 + } 1894 + } 1895 + 1896 + static unsigned long __init __free_memory_core(phys_addr_t start, 1897 + phys_addr_t end) 1898 + { 1899 + unsigned long start_pfn = PFN_UP(start); 1900 + unsigned long end_pfn = min_t(unsigned long, 1901 + PFN_DOWN(end), max_low_pfn); 1902 + 1903 + if (start_pfn >= end_pfn) 1904 + return 0; 1905 + 1906 + __free_pages_memory(start_pfn, end_pfn); 1907 + 1908 + return end_pfn - start_pfn; 1909 + } 1910 + 1911 + static unsigned long __init free_low_memory_core_early(void) 1912 + { 1913 + unsigned long count = 0; 1914 + phys_addr_t start, end; 1915 + u64 i; 1916 + 1917 + memblock_clear_hotplug(0, -1); 1918 + 1919 + for_each_reserved_mem_region(i, &start, &end) 1920 + reserve_bootmem_region(start, end); 1921 + 1922 + /* 1923 + * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id 1924 + * because in some case like Node0 doesn't have RAM installed 1925 + * low ram will be on Node1 1926 + */ 1927 + for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end, 1928 + NULL) 1929 + count += __free_memory_core(start, end); 1930 + 1931 + return count; 1932 + } 1933 + 1934 + static int reset_managed_pages_done __initdata; 1935 + 1936 + void reset_node_managed_pages(pg_data_t *pgdat) 1937 + { 1938 + struct zone *z; 1939 + 1940 + for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) 1941 + z->managed_pages = 0; 1942 + } 1943 + 1944 + void __init reset_all_zones_managed_pages(void) 1945 + { 1946 + struct pglist_data *pgdat; 1947 + 1948 + if (reset_managed_pages_done) 1949 + return; 1950 + 1951 + for_each_online_pgdat(pgdat) 1952 + reset_node_managed_pages(pgdat); 1953 + 1954 + reset_managed_pages_done = 1; 1955 + } 1956 + 1957 + /** 1958 + * memblock_free_all - release free pages to the buddy allocator 1959 + * 1960 + * Return: the number of pages actually released. 1961 + */ 1962 + unsigned long __init memblock_free_all(void) 1963 + { 1964 + unsigned long pages; 1965 + 1966 + reset_all_zones_managed_pages(); 1967 + 1968 + pages = free_low_memory_core_early(); 1969 + totalram_pages += pages; 1970 + 1971 + return pages; 1972 + } 1889 1973 1890 1974 #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) 1891 1975
-128
mm/nobootmem.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * bootmem - A boot-time physical memory allocator and configurator 4 - * 5 - * Copyright (C) 1999 Ingo Molnar 6 - * 1999 Kanoj Sarcar, SGI 7 - * 2008 Johannes Weiner 8 - * 9 - * Access to this subsystem has to be serialized externally (which is true 10 - * for the boot process anyway). 11 - */ 12 - #include <linux/init.h> 13 - #include <linux/pfn.h> 14 - #include <linux/slab.h> 15 - #include <linux/export.h> 16 - #include <linux/kmemleak.h> 17 - #include <linux/range.h> 18 - #include <linux/memblock.h> 19 - #include <linux/bootmem.h> 20 - 21 - #include <asm/bug.h> 22 - #include <asm/io.h> 23 - 24 - #include "internal.h" 25 - 26 - #ifndef CONFIG_NEED_MULTIPLE_NODES 27 - struct pglist_data __refdata contig_page_data; 28 - EXPORT_SYMBOL(contig_page_data); 29 - #endif 30 - 31 - unsigned long max_low_pfn; 32 - unsigned long min_low_pfn; 33 - unsigned long max_pfn; 34 - unsigned long long max_possible_pfn; 35 - 36 - static void __init __free_pages_memory(unsigned long start, unsigned long end) 37 - { 38 - int order; 39 - 40 - while (start < end) { 41 - order = min(MAX_ORDER - 1UL, __ffs(start)); 42 - 43 - while (start + (1UL << order) > end) 44 - order--; 45 - 46 - memblock_free_pages(pfn_to_page(start), start, order); 47 - 48 - start += (1UL << order); 49 - } 50 - } 51 - 52 - static unsigned long __init __free_memory_core(phys_addr_t start, 53 - phys_addr_t end) 54 - { 55 - unsigned long start_pfn = PFN_UP(start); 56 - unsigned long end_pfn = min_t(unsigned long, 57 - PFN_DOWN(end), max_low_pfn); 58 - 59 - if (start_pfn >= end_pfn) 60 - return 0; 61 - 62 - __free_pages_memory(start_pfn, end_pfn); 63 - 64 - return end_pfn - start_pfn; 65 - } 66 - 67 - static unsigned long __init free_low_memory_core_early(void) 68 - { 69 - unsigned long count = 0; 70 - phys_addr_t start, end; 71 - u64 i; 72 - 73 - memblock_clear_hotplug(0, -1); 74 - 75 - for_each_reserved_mem_region(i, &start, &end) 76 - reserve_bootmem_region(start, end); 77 - 78 - /* 79 - * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id 80 - * because in some case like Node0 doesn't have RAM installed 81 - * low ram will be on Node1 82 - */ 83 - for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end, 84 - NULL) 85 - count += __free_memory_core(start, end); 86 - 87 - return count; 88 - } 89 - 90 - static int reset_managed_pages_done __initdata; 91 - 92 - void reset_node_managed_pages(pg_data_t *pgdat) 93 - { 94 - struct zone *z; 95 - 96 - for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) 97 - z->managed_pages = 0; 98 - } 99 - 100 - void __init reset_all_zones_managed_pages(void) 101 - { 102 - struct pglist_data *pgdat; 103 - 104 - if (reset_managed_pages_done) 105 - return; 106 - 107 - for_each_online_pgdat(pgdat) 108 - reset_node_managed_pages(pgdat); 109 - 110 - reset_managed_pages_done = 1; 111 - } 112 - 113 - /** 114 - * memblock_free_all - release free pages to the buddy allocator 115 - * 116 - * Return: the number of pages actually released. 117 - */ 118 - unsigned long __init memblock_free_all(void) 119 - { 120 - unsigned long pages; 121 - 122 - reset_all_zones_managed_pages(); 123 - 124 - pages = free_low_memory_core_early(); 125 - totalram_pages += pages; 126 - 127 - return pages; 128 - }