Move remaining definitions and declarations from include/linux/bootmem.h into include/linux/memblock.h and remove the redundant header. The includes were replaced with the semantic patch below and then semi-automated removal of duplicated '#include <linux/memblock.h> @@ @@ - #include <linux/bootmem.h> + #include <linux/memblock.h> [sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au [sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au [sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal] Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> 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>
Showing the changes to include/linux (2 of 275 files). Show all
Unified · Split
| @@ -1,173 +0,0 @@ | ||
| 1 | −/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | −/* | |
| 3 | − * Discontiguous memory support, Kanoj Sarcar, SGI, Nov 1999 | |
| 4 | − */ | |
| 5 | −#ifndef _LINUX_BOOTMEM_H | |
| 6 | −#define _LINUX_BOOTMEM_H | |
| 7 | − | |
| 8 | −#include <linux/mmzone.h> | |
| 9 | −#include <linux/mm_types.h> | |
| 10 | −#include <asm/dma.h> | |
| 11 | −#include <asm/processor.h> | |
| 12 | − | |
| 13 | −/* | |
| 14 | − * simple boot-time physical memory area allocator. | |
| 15 | − */ | |
| 16 | − | |
| 17 | −extern unsigned long max_low_pfn; | |
| 18 | −extern unsigned long min_low_pfn; | |
| 19 | − | |
| 20 | −/* | |
| 21 | − * highest page | |
| 22 | − */ | |
| 23 | −extern unsigned long max_pfn; | |
| 24 | −/* | |
| 25 | − * highest possible page | |
| 26 | − */ | |
| 27 | −extern unsigned long long max_possible_pfn; | |
| 28 | − | |
| 29 | −extern unsigned long memblock_free_all(void); | |
| 30 | −extern void reset_node_managed_pages(pg_data_t *pgdat); | |
| 31 | −extern void reset_all_zones_managed_pages(void); | |
| 32 | − | |
| 33 | −/* We are using top down, so it is safe to use 0 here */ | |
| 34 | −#define BOOTMEM_LOW_LIMIT 0 | |
| 35 | − | |
| 36 | −#ifndef ARCH_LOW_ADDRESS_LIMIT | |
| 37 | −#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL | |
| 38 | −#endif | |
| 39 | − | |
| 40 | −/* FIXME: use MEMBLOCK_ALLOC_* variants here */ | |
| 41 | −#define BOOTMEM_ALLOC_ACCESSIBLE 0 | |
| 42 | −#define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0) | |
| 43 | − | |
| 44 | −/* FIXME: Move to memblock.h at a point where we remove nobootmem.c */ | |
| 45 | −void *memblock_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align, | |
| 46 | − phys_addr_t min_addr, | |
| 47 | − phys_addr_t max_addr, int nid); | |
| 48 | −void *memblock_alloc_try_nid_nopanic(phys_addr_t size, | |
| 49 | − phys_addr_t align, phys_addr_t min_addr, | |
| 50 | − phys_addr_t max_addr, int nid); | |
| 51 | −void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, | |
| 52 | − phys_addr_t min_addr, phys_addr_t max_addr, int nid); | |
| 53 | −void __memblock_free_early(phys_addr_t base, phys_addr_t size); | |
| 54 | −void __memblock_free_late(phys_addr_t base, phys_addr_t size); | |
| 55 | − | |
| 56 | −static inline void * __init memblock_alloc( | |
| 57 | − phys_addr_t size, phys_addr_t align) | |
| 58 | −{ | |
| 59 | − return memblock_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT, | |
| 60 | − BOOTMEM_ALLOC_ACCESSIBLE, | |
| 61 | − NUMA_NO_NODE); | |
| 62 | −} | |
| 63 | − | |
| 64 | −static inline void * __init memblock_alloc_raw( | |
| 65 | − phys_addr_t size, phys_addr_t align) | |
| 66 | −{ | |
| 67 | − return memblock_alloc_try_nid_raw(size, align, BOOTMEM_LOW_LIMIT, | |
| 68 | − BOOTMEM_ALLOC_ACCESSIBLE, | |
| 69 | − NUMA_NO_NODE); | |
| 70 | −} | |
| 71 | − | |
| 72 | −static inline void * __init memblock_alloc_from( | |
| 73 | − phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | |
| 74 | −{ | |
| 75 | − return memblock_alloc_try_nid(size, align, min_addr, | |
| 76 | − BOOTMEM_ALLOC_ACCESSIBLE, | |
| 77 | − NUMA_NO_NODE); | |
| 78 | −} | |
| 79 | − | |
| 80 | −static inline void * __init memblock_alloc_nopanic( | |
| 81 | − phys_addr_t size, phys_addr_t align) | |
| 82 | −{ | |
| 83 | − return memblock_alloc_try_nid_nopanic(size, align, | |
| 84 | − BOOTMEM_LOW_LIMIT, | |
| 85 | − BOOTMEM_ALLOC_ACCESSIBLE, | |
| 86 | − NUMA_NO_NODE); | |
| 87 | −} | |
| 88 | − | |
| 89 | −static inline void * __init memblock_alloc_low( | |
| 90 | − phys_addr_t size, phys_addr_t align) | |
| 91 | −{ | |
| 92 | − return memblock_alloc_try_nid(size, align, | |
| 93 | − BOOTMEM_LOW_LIMIT, | |
| 94 | − ARCH_LOW_ADDRESS_LIMIT, | |
| 95 | − NUMA_NO_NODE); | |
| 96 | −} | |
| 97 | −static inline void * __init memblock_alloc_low_nopanic( | |
| 98 | − phys_addr_t size, phys_addr_t align) | |
| 99 | −{ | |
| 100 | − return memblock_alloc_try_nid_nopanic(size, align, | |
| 101 | − BOOTMEM_LOW_LIMIT, | |
| 102 | − ARCH_LOW_ADDRESS_LIMIT, | |
| 103 | − NUMA_NO_NODE); | |
| 104 | −} | |
| 105 | − | |
| 106 | −static inline void * __init memblock_alloc_from_nopanic( | |
| 107 | − phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | |
| 108 | −{ | |
| 109 | − return memblock_alloc_try_nid_nopanic(size, align, min_addr, | |
| 110 | − BOOTMEM_ALLOC_ACCESSIBLE, | |
| 111 | − NUMA_NO_NODE); | |
| 112 | −} | |
| 113 | − | |
| 114 | −static inline void * __init memblock_alloc_node( | |
| 115 | − phys_addr_t size, phys_addr_t align, int nid) | |
| 116 | −{ | |
| 117 | − return memblock_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT, | |
| 118 | − BOOTMEM_ALLOC_ACCESSIBLE, nid); | |
| 119 | −} | |
| 120 | − | |
| 121 | −static inline void * __init memblock_alloc_node_nopanic( | |
| 122 | − phys_addr_t size, int nid) | |
| 123 | −{ | |
| 124 | − return memblock_alloc_try_nid_nopanic(size, 0, BOOTMEM_LOW_LIMIT, | |
| 125 | − BOOTMEM_ALLOC_ACCESSIBLE, | |
| 126 | − nid); | |
| 127 | −} | |
| 128 | − | |
| 129 | −static inline void __init memblock_free_early( | |
| 130 | − phys_addr_t base, phys_addr_t size) | |
| 131 | −{ | |
| 132 | − __memblock_free_early(base, size); | |
| 133 | −} | |
| 134 | − | |
| 135 | −static inline void __init memblock_free_early_nid( | |
| 136 | − phys_addr_t base, phys_addr_t size, int nid) | |
| 137 | −{ | |
| 138 | − __memblock_free_early(base, size); | |
| 139 | −} | |
| 140 | − | |
| 141 | −static inline void __init memblock_free_late( | |
| 142 | − phys_addr_t base, phys_addr_t size) | |
| 143 | −{ | |
| 144 | − __memblock_free_late(base, size); | |
| 145 | −} | |
| 146 | − | |
| 147 | −extern void *alloc_large_system_hash(const char *tablename, | |
| 148 | − unsigned long bucketsize, | |
| 149 | − unsigned long numentries, | |
| 150 | − int scale, | |
| 151 | − int flags, | |
| 152 | − unsigned int *_hash_shift, | |
| 153 | − unsigned int *_hash_mask, | |
| 154 | − unsigned long low_limit, | |
| 155 | − unsigned long high_limit); | |
| 156 | − | |
| 157 | −#define HASH_EARLY 0x00000001 /* Allocating during early boot? */ | |
| 158 | −#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min | |
| 159 | − * shift passed via *_hash_shift */ | |
| 160 | −#define HASH_ZERO 0x00000004 /* Zero allocated hash table */ | |
| 161 | − | |
| 162 | −/* Only NUMA needs hash distribution. 64bit NUMA architectures have | |
| 163 | − * sufficient vmalloc space. | |
| 164 | − */ | |
| 165 | −#ifdef CONFIG_NUMA | |
| 166 | −#define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) | |
| 167 | −extern int hashdist; /* Distribute hashes across NUMA nodes? */ | |
| 168 | −#else | |
| 169 | −#define hashdist (0) | |
| 170 | −#endif | |
| 171 | − | |
| 172 | − | |
| 173 | −#endif /* _LINUX_BOOTMEM_H */ | |
| @@ -15,6 +15,19 @@ · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | #include <linux/init.h> |
| 17 | 17 | #include <linux/mm.h> |
| 18 | +#include <asm/dma.h> | |
| 19 | + | |
| 20 | +extern unsigned long max_low_pfn; | |
| 21 | +extern unsigned long min_low_pfn; | |
| 22 | + | |
| 23 | +/* | |
| 24 | + * highest page | |
| 25 | + */ | |
| 26 | +extern unsigned long max_pfn; | |
| 27 | +/* | |
| 28 | + * highest possible page | |
| 29 | + */ | |
| 30 | +extern unsigned long long max_possible_pfn; | |
| 18 | 31 | |
| 19 | 32 | #define INIT_MEMBLOCK_REGIONS 128 |
| 20 | 33 | #define INIT_PHYSMEM_REGIONS 4 |
| @@ -119,6 +132,10 @@ int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); · 98 unmodified lines | ||
| 119 | 132 | int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); |
| 120 | 133 | enum memblock_flags choose_memblock_flags(void); |
| 121 | 134 | |
| 135 | +unsigned long memblock_free_all(void); | |
| 136 | +void reset_node_managed_pages(pg_data_t *pgdat); | |
| 137 | +void reset_all_zones_managed_pages(void); | |
| 138 | + | |
| 122 | 139 | /* Low level functions */ |
| 123 | 140 | int memblock_add_range(struct memblock_type *type, |
| 124 | 141 | phys_addr_t base, phys_addr_t size, |
| @@ -300,11 +317,116 @@ static inline int memblock_get_region_node(const struct memblock_region *r) · 175 unmodified lines | ||
| 300 | 317 | } |
| 301 | 318 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ |
| 302 | 319 | |
| 320 | +/* Flags for memblock allocation APIs */ | |
| 321 | +#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0) | |
| 322 | +#define MEMBLOCK_ALLOC_ACCESSIBLE 0 | |
| 323 | + | |
| 324 | +/* We are using top down, so it is safe to use 0 here */ | |
| 325 | +#define MEMBLOCK_LOW_LIMIT 0 | |
| 326 | + | |
| 327 | +#ifndef ARCH_LOW_ADDRESS_LIMIT | |
| 328 | +#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL | |
| 329 | +#endif | |
| 330 | + | |
| 303 | 331 | phys_addr_t memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); |
| 304 | 332 | phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); |
| 305 | 333 | |
| 306 | 334 | phys_addr_t memblock_phys_alloc(phys_addr_t size, phys_addr_t align); |
| 307 | 335 | |
| 336 | +void *memblock_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align, | |
| 337 | + phys_addr_t min_addr, phys_addr_t max_addr, | |
| 338 | + int nid); | |
| 339 | +void *memblock_alloc_try_nid_nopanic(phys_addr_t size, phys_addr_t align, | |
| 340 | + phys_addr_t min_addr, phys_addr_t max_addr, | |
| 341 | + int nid); | |
| 342 | +void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, | |
| 343 | + phys_addr_t min_addr, phys_addr_t max_addr, | |
| 344 | + int nid); | |
| 345 | + | |
| 346 | +static inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align) | |
| 347 | +{ | |
| 348 | + return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT, | |
| 349 | + MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); | |
| 350 | +} | |
| 351 | + | |
| 352 | +static inline void * __init memblock_alloc_raw(phys_addr_t size, | |
| 353 | + phys_addr_t align) | |
| 354 | +{ | |
| 355 | + return memblock_alloc_try_nid_raw(size, align, MEMBLOCK_LOW_LIMIT, | |
| 356 | + MEMBLOCK_ALLOC_ACCESSIBLE, | |
| 357 | + NUMA_NO_NODE); | |
| 358 | +} | |
| 359 | + | |
| 360 | +static inline void * __init memblock_alloc_from(phys_addr_t size, | |
| 361 | + phys_addr_t align, | |
| 362 | + phys_addr_t min_addr) | |
| 363 | +{ | |
| 364 | + return memblock_alloc_try_nid(size, align, min_addr, | |
| 365 | + MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); | |
| 366 | +} | |
| 367 | + | |
| 368 | +static inline void * __init memblock_alloc_nopanic(phys_addr_t size, | |
| 369 | + phys_addr_t align) | |
| 370 | +{ | |
| 371 | + return memblock_alloc_try_nid_nopanic(size, align, MEMBLOCK_LOW_LIMIT, | |
| 372 | + MEMBLOCK_ALLOC_ACCESSIBLE, | |
| 373 | + NUMA_NO_NODE); | |
| 374 | +} | |
| 375 | + | |
| 376 | +static inline void * __init memblock_alloc_low(phys_addr_t size, | |
| 377 | + phys_addr_t align) | |
| 378 | +{ | |
| 379 | + return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT, | |
| 380 | + ARCH_LOW_ADDRESS_LIMIT, NUMA_NO_NODE); | |
| 381 | +} | |
| 382 | +static inline void * __init memblock_alloc_low_nopanic(phys_addr_t size, | |
| 383 | + phys_addr_t align) | |
| 384 | +{ | |
| 385 | + return memblock_alloc_try_nid_nopanic(size, align, MEMBLOCK_LOW_LIMIT, | |
| 386 | + ARCH_LOW_ADDRESS_LIMIT, | |
| 387 | + NUMA_NO_NODE); | |
| 388 | +} | |
| 389 | + | |
| 390 | +static inline void * __init memblock_alloc_from_nopanic(phys_addr_t size, | |
| 391 | + phys_addr_t align, | |
| 392 | + phys_addr_t min_addr) | |
| 393 | +{ | |
| 394 | + return memblock_alloc_try_nid_nopanic(size, align, min_addr, | |
| 395 | + MEMBLOCK_ALLOC_ACCESSIBLE, | |
| 396 | + NUMA_NO_NODE); | |
| 397 | +} | |
| 398 | + | |
| 399 | +static inline void * __init memblock_alloc_node(phys_addr_t size, | |
| 400 | + phys_addr_t align, int nid) | |
| 401 | +{ | |
| 402 | + return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT, | |
| 403 | + MEMBLOCK_ALLOC_ACCESSIBLE, nid); | |
| 404 | +} | |
| 405 | + | |
| 406 | +static inline void * __init memblock_alloc_node_nopanic(phys_addr_t size, | |
| 407 | + int nid) | |
| 408 | +{ | |
| 409 | + return memblock_alloc_try_nid_nopanic(size, 0, MEMBLOCK_LOW_LIMIT, | |
| 410 | + MEMBLOCK_ALLOC_ACCESSIBLE, nid); | |
| 411 | +} | |
| 412 | + | |
| 413 | +static inline void __init memblock_free_early(phys_addr_t base, | |
| 414 | + phys_addr_t size) | |
| 415 | +{ | |
| 416 | + __memblock_free_early(base, size); | |
| 417 | +} | |
| 418 | + | |
| 419 | +static inline void __init memblock_free_early_nid(phys_addr_t base, | |
| 420 | + phys_addr_t size, int nid) | |
| 421 | +{ | |
| 422 | + __memblock_free_early(base, size); | |
| 423 | +} | |
| 424 | + | |
| 425 | +static inline void __init memblock_free_late(phys_addr_t base, phys_addr_t size) | |
| 426 | +{ | |
| 427 | + __memblock_free_late(base, size); | |
| 428 | +} | |
| 429 | + | |
| 308 | 430 | /* |
| 309 | 431 | * Set the allocation direction to bottom-up or top-down. |
| 310 | 432 | */ |
| @@ -323,10 +445,6 @@ static inline bool memblock_bottom_up(void) · 12 unmodified lines | ||
| 323 | 445 | return memblock.bottom_up; |
| 324 | 446 | } |
| 325 | 447 | |
| 326 | −/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ | |
| 327 | −#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0) | |
| 328 | −#define MEMBLOCK_ALLOC_ACCESSIBLE 0 | |
| 329 | − | |
| 330 | 448 | phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, |
| 331 | 449 | phys_addr_t start, phys_addr_t end, |
| 332 | 450 | enum memblock_flags flags); |
| @@ -432,6 +550,31 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo · 99 unmodified lines | ||
| 432 | 550 | i < memblock_type->cnt; \ |
| 433 | 551 | i++, rgn = &memblock_type->regions[i]) |
| 434 | 552 | |
| 553 | +extern void *alloc_large_system_hash(const char *tablename, | |
| 554 | + unsigned long bucketsize, | |
| 555 | + unsigned long numentries, | |
| 556 | + int scale, | |
| 557 | + int flags, | |
| 558 | + unsigned int *_hash_shift, | |
| 559 | + unsigned int *_hash_mask, | |
| 560 | + unsigned long low_limit, | |
| 561 | + unsigned long high_limit); | |
| 562 | + | |
| 563 | +#define HASH_EARLY 0x00000001 /* Allocating during early boot? */ | |
| 564 | +#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min | |
| 565 | + * shift passed via *_hash_shift */ | |
| 566 | +#define HASH_ZERO 0x00000004 /* Zero allocated hash table */ | |
| 567 | + | |
| 568 | +/* Only NUMA needs hash distribution. 64bit NUMA architectures have | |
| 569 | + * sufficient vmalloc space. | |
| 570 | + */ | |
| 571 | +#ifdef CONFIG_NUMA | |
| 572 | +#define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) | |
| 573 | +extern int hashdist; /* Distribute hashes across NUMA nodes? */ | |
| 574 | +#else | |
| 575 | +#define hashdist (0) | |
| 576 | +#endif | |
| 577 | + | |
| 435 | 578 | #ifdef CONFIG_MEMTEST |
| 436 | 579 | extern void early_memtest(phys_addr_t start, phys_addr_t end); |
| 437 | 580 | #else |