diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-31 12:25:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-31 12:25:15 -0400 |
commit | 59fc453b21f767f2fb0ff4dc0a947e9b9c9e6d14 (patch) | |
tree | 42029c432982ebabb462bd16a413a033125fd793 | |
parent | 310c7585e8300ddc46211df0757c11e4299ec482 (diff) | |
parent | 2ebe82288b3278b8e538ee8adce4142dbdedd8f6 (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
- the rest of MM
- lib/bitmap updates
- hfs updates
- fatfs updates
- various other misc things
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (94 commits)
mm/gup.c: fix __get_user_pages_fast() comment
mm: Fix warning in insert_pfn()
memory-hotplug.rst: add some details about locking internals
powerpc/powernv: hold device_hotplug_lock when calling memtrace_offline_pages()
powerpc/powernv: hold device_hotplug_lock when calling device_online()
mm/memory_hotplug: fix online/offline_pages called w.o. mem_hotplug_lock
mm/memory_hotplug: make add_memory() take the device_hotplug_lock
mm/memory_hotplug: make remove_memory() take the device_hotplug_lock
mm/memblock.c: warn if zero alignment was requested
memblock: stop using implicit alignment to SMP_CACHE_BYTES
docs/boot-time-mm: remove bootmem documentation
mm: remove include/linux/bootmem.h
memblock: replace BOOTMEM_ALLOC_* with MEMBLOCK variants
mm: remove nobootmem
memblock: rename __free_pages_bootmem to memblock_free_pages
memblock: rename free_all_bootmem to memblock_free_all
memblock: replace free_bootmem_late with memblock_free_late
memblock: replace free_bootmem{_node} with memblock_free
mm: nobootmem: remove bootmem allocation APIs
memblock: replace alloc_bootmem with memblock_alloc
...
423 files changed, 1918 insertions, 3094 deletions
@@ -160,6 +160,11 @@ Peter Oruba <peter.oruba@amd.com> | |||
160 | Pratyush Anand <pratyush.anand@gmail.com> <pratyush.anand@st.com> | 160 | Pratyush Anand <pratyush.anand@gmail.com> <pratyush.anand@st.com> |
161 | Praveen BP <praveenbp@ti.com> | 161 | Praveen BP <praveenbp@ti.com> |
162 | Qais Yousef <qsyousef@gmail.com> <qais.yousef@imgtec.com> | 162 | Qais Yousef <qsyousef@gmail.com> <qais.yousef@imgtec.com> |
163 | Oleksij Rempel <linux@rempel-privat.de> <bug-track@fisher-privat.net> | ||
164 | Oleksij Rempel <linux@rempel-privat.de> <external.Oleksij.Rempel@de.bosch.com> | ||
165 | Oleksij Rempel <linux@rempel-privat.de> <fixed-term.Oleksij.Rempel@de.bosch.com> | ||
166 | Oleksij Rempel <linux@rempel-privat.de> <o.rempel@pengutronix.de> | ||
167 | Oleksij Rempel <linux@rempel-privat.de> <ore@pengutronix.de> | ||
163 | Rajesh Shah <rajesh.shah@intel.com> | 168 | Rajesh Shah <rajesh.shah@intel.com> |
164 | Ralf Baechle <ralf@linux-mips.org> | 169 | Ralf Baechle <ralf@linux-mips.org> |
165 | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> | 170 | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> |
diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index 25157aec5b31..5c4432c96c4b 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst | |||
@@ -5,7 +5,7 @@ Memory Hotplug | |||
5 | ============== | 5 | ============== |
6 | 6 | ||
7 | :Created: Jul 28 2007 | 7 | :Created: Jul 28 2007 |
8 | :Updated: Add description of notifier of memory hotplug: Oct 11 2007 | 8 | :Updated: Add some details about locking internals: Aug 20 2018 |
9 | 9 | ||
10 | This document is about memory hotplug including how-to-use and current status. | 10 | This document is about memory hotplug including how-to-use and current status. |
11 | Because Memory Hotplug is still under development, contents of this text will | 11 | Because Memory Hotplug is still under development, contents of this text will |
@@ -392,6 +392,46 @@ Need more implementation yet.... | |||
392 | - Notification completion of remove works by OS to firmware. | 392 | - Notification completion of remove works by OS to firmware. |
393 | - Guard from remove if not yet. | 393 | - Guard from remove if not yet. |
394 | 394 | ||
395 | |||
396 | Locking Internals | ||
397 | ================= | ||
398 | |||
399 | When adding/removing memory that uses memory block devices (i.e. ordinary RAM), | ||
400 | the device_hotplug_lock should be held to: | ||
401 | |||
402 | - synchronize against online/offline requests (e.g. via sysfs). This way, memory | ||
403 | block devices can only be accessed (.online/.state attributes) by user | ||
404 | space once memory has been fully added. And when removing memory, we | ||
405 | know nobody is in critical sections. | ||
406 | - synchronize against CPU hotplug and similar (e.g. relevant for ACPI and PPC) | ||
407 | |||
408 | Especially, there is a possible lock inversion that is avoided using | ||
409 | device_hotplug_lock when adding memory and user space tries to online that | ||
410 | memory faster than expected: | ||
411 | |||
412 | - device_online() will first take the device_lock(), followed by | ||
413 | mem_hotplug_lock | ||
414 | - add_memory_resource() will first take the mem_hotplug_lock, followed by | ||
415 | the device_lock() (while creating the devices, during bus_add_device()). | ||
416 | |||
417 | As the device is visible to user space before taking the device_lock(), this | ||
418 | can result in a lock inversion. | ||
419 | |||
420 | onlining/offlining of memory should be done via device_online()/ | ||
421 | device_offline() - to make sure it is properly synchronized to actions | ||
422 | via sysfs. Holding device_hotplug_lock is advised (to e.g. protect online_type) | ||
423 | |||
424 | When adding/removing/onlining/offlining memory or adding/removing | ||
425 | heterogeneous/device memory, we should always hold the mem_hotplug_lock in | ||
426 | write mode to serialise memory hotplug (e.g. access to global/zone | ||
427 | variables). | ||
428 | |||
429 | In addition, mem_hotplug_lock (in contrast to device_hotplug_lock) in read | ||
430 | mode allows for a quite efficient get_online_mems/put_online_mems | ||
431 | implementation, so code accessing memory can protect from that memory | ||
432 | vanishing. | ||
433 | |||
434 | |||
395 | Future Work | 435 | Future Work |
396 | =========== | 436 | =========== |
397 | 437 | ||
diff --git a/Documentation/core-api/boot-time-mm.rst b/Documentation/core-api/boot-time-mm.rst index 6e12e89a03e0..e5ec9f1a563d 100644 --- a/Documentation/core-api/boot-time-mm.rst +++ b/Documentation/core-api/boot-time-mm.rst | |||
@@ -5,54 +5,23 @@ Boot time memory management | |||
5 | Early system initialization cannot use "normal" memory management | 5 | Early system initialization cannot use "normal" memory management |
6 | simply because it is not set up yet. But there is still need to | 6 | simply because it is not set up yet. But there is still need to |
7 | allocate memory for various data structures, for instance for the | 7 | allocate memory for various data structures, for instance for the |
8 | physical page allocator. To address this, a specialized allocator | 8 | physical page allocator. |
9 | called the :ref:`Boot Memory Allocator <bootmem>`, or bootmem, was | ||
10 | introduced. Several years later PowerPC developers added a "Logical | ||
11 | Memory Blocks" allocator, which was later adopted by other | ||
12 | architectures and renamed to :ref:`memblock <memblock>`. There is also | ||
13 | a compatibility layer called `nobootmem` that translates bootmem | ||
14 | allocation interfaces to memblock calls. | ||
15 | 9 | ||
16 | The selection of the early allocator is done using | 10 | A specialized allocator called ``memblock`` performs the |
17 | ``CONFIG_NO_BOOTMEM`` and ``CONFIG_HAVE_MEMBLOCK`` kernel | 11 | boot time memory management. The architecture specific initialization |
18 | configuration options. These options are enabled or disabled | 12 | must set it up in :c:func:`setup_arch` and tear it down in |
19 | statically by the architectures' Kconfig files. | 13 | :c:func:`mem_init` functions. |
20 | |||
21 | * Architectures that rely only on bootmem select | ||
22 | ``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=n``. | ||
23 | * The users of memblock with the nobootmem compatibility layer set | ||
24 | ``CONFIG_NO_BOOTMEM=y && CONFIG_HAVE_MEMBLOCK=y``. | ||
25 | * And for those that use both memblock and bootmem the configuration | ||
26 | includes ``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=y``. | ||
27 | |||
28 | Whichever allocator is used, it is the responsibility of the | ||
29 | architecture specific initialization to set it up in | ||
30 | :c:func:`setup_arch` and tear it down in :c:func:`mem_init` functions. | ||
31 | 14 | ||
32 | Once the early memory management is available it offers a variety of | 15 | Once the early memory management is available it offers a variety of |
33 | functions and macros for memory allocations. The allocation request | 16 | functions and macros for memory allocations. The allocation request |
34 | may be directed to the first (and probably the only) node or to a | 17 | may be directed to the first (and probably the only) node or to a |
35 | particular node in a NUMA system. There are API variants that panic | 18 | particular node in a NUMA system. There are API variants that panic |
36 | when an allocation fails and those that don't. And more recent and | 19 | when an allocation fails and those that don't. |
37 | advanced memblock even allows controlling its own behaviour. | ||
38 | |||
39 | .. _bootmem: | ||
40 | |||
41 | Bootmem | ||
42 | ======= | ||
43 | 20 | ||
44 | (mostly stolen from Mel Gorman's "Understanding the Linux Virtual | 21 | Memblock also offers a variety of APIs that control its own behaviour. |
45 | Memory Manager" `book`_) | ||
46 | 22 | ||
47 | .. _book: https://www.kernel.org/doc/gorman/ | 23 | Memblock Overview |
48 | 24 | ================= | |
49 | .. kernel-doc:: mm/bootmem.c | ||
50 | :doc: bootmem overview | ||
51 | |||
52 | .. _memblock: | ||
53 | |||
54 | Memblock | ||
55 | ======== | ||
56 | 25 | ||
57 | .. kernel-doc:: mm/memblock.c | 26 | .. kernel-doc:: mm/memblock.c |
58 | :doc: memblock overview | 27 | :doc: memblock overview |
@@ -61,26 +30,6 @@ Memblock | |||
61 | Functions and structures | 30 | Functions and structures |
62 | ======================== | 31 | ======================== |
63 | 32 | ||
64 | Common API | ||
65 | ---------- | ||
66 | |||
67 | The functions that are described in this section are available | ||
68 | regardless of what early memory manager is enabled. | ||
69 | |||
70 | .. kernel-doc:: mm/nobootmem.c | ||
71 | |||
72 | Bootmem specific API | ||
73 | -------------------- | ||
74 | |||
75 | These interfaces available only with bootmem, i.e when ``CONFIG_NO_BOOTMEM=n`` | ||
76 | |||
77 | .. kernel-doc:: include/linux/bootmem.h | ||
78 | .. kernel-doc:: mm/bootmem.c | ||
79 | :functions: | ||
80 | |||
81 | Memblock specific API | ||
82 | --------------------- | ||
83 | |||
84 | Here is the description of memblock data structures, functions and | 33 | Here is the description of memblock data structures, functions and |
85 | macros. Some of them are actually internal, but since they are | 34 | macros. Some of them are actually internal, but since they are |
86 | documented it would be silly to omit them. Besides, reading the | 35 | documented it would be silly to omit them. Besides, reading the |
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 620b0a711ee4..5b4f88363453 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig | |||
@@ -31,8 +31,6 @@ config ALPHA | |||
31 | select ODD_RT_SIGACTION | 31 | select ODD_RT_SIGACTION |
32 | select OLD_SIGSUSPEND | 32 | select OLD_SIGSUSPEND |
33 | select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67 | 33 | select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67 |
34 | select HAVE_MEMBLOCK | ||
35 | select NO_BOOTMEM | ||
36 | help | 34 | help |
37 | The Alpha is a 64-bit general-purpose processor designed and | 35 | The Alpha is a 64-bit general-purpose processor designed and |
38 | marketed by the Digital Equipment Corporation of blessed memory, | 36 | marketed by the Digital Equipment Corporation of blessed memory, |
diff --git a/arch/alpha/include/asm/processor.h b/arch/alpha/include/asm/processor.h index cb05d045efe3..6100431da07a 100644 --- a/arch/alpha/include/asm/processor.h +++ b/arch/alpha/include/asm/processor.h | |||
@@ -11,12 +11,6 @@ | |||
11 | #include <linux/personality.h> /* for ADDR_LIMIT_32BIT */ | 11 | #include <linux/personality.h> /* for ADDR_LIMIT_32BIT */ |
12 | 12 | ||
13 | /* | 13 | /* |
14 | * Returns current instruction pointer ("program counter"). | ||
15 | */ | ||
16 | #define current_text_addr() \ | ||
17 | ({ void *__pc; __asm__ ("br %0,.+4" : "=r"(__pc)); __pc; }) | ||
18 | |||
19 | /* | ||
20 | * We have a 42-bit user address space: 4TB user VM... | 14 | * We have a 42-bit user address space: 4TB user VM... |
21 | */ | 15 | */ |
22 | #define TASK_SIZE (0x40000000000UL) | 16 | #define TASK_SIZE (0x40000000000UL) |
diff --git a/arch/alpha/kernel/core_apecs.c b/arch/alpha/kernel/core_apecs.c index 1bf3eef34c22..6df765ff2b10 100644 --- a/arch/alpha/kernel/core_apecs.c +++ b/arch/alpha/kernel/core_apecs.c | |||
@@ -346,7 +346,8 @@ apecs_init_arch(void) | |||
346 | * Window 1 is direct access 1GB at 1GB | 346 | * Window 1 is direct access 1GB at 1GB |
347 | * Window 2 is scatter-gather 8MB at 8MB (for isa) | 347 | * Window 2 is scatter-gather 8MB at 8MB (for isa) |
348 | */ | 348 | */ |
349 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0); | 349 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, |
350 | SMP_CACHE_BYTES); | ||
350 | hose->sg_pci = NULL; | 351 | hose->sg_pci = NULL; |
351 | __direct_map_base = 0x40000000; | 352 | __direct_map_base = 0x40000000; |
352 | __direct_map_size = 0x40000000; | 353 | __direct_map_size = 0x40000000; |
diff --git a/arch/alpha/kernel/core_cia.c b/arch/alpha/kernel/core_cia.c index 4b38386f6e62..867e8730b0c5 100644 --- a/arch/alpha/kernel/core_cia.c +++ b/arch/alpha/kernel/core_cia.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/bootmem.h> | 24 | #include <linux/memblock.h> |
25 | 25 | ||
26 | #include <asm/ptrace.h> | 26 | #include <asm/ptrace.h> |
27 | #include <asm/mce.h> | 27 | #include <asm/mce.h> |
@@ -331,7 +331,7 @@ cia_prepare_tbia_workaround(int window) | |||
331 | long i; | 331 | long i; |
332 | 332 | ||
333 | /* Use minimal 1K map. */ | 333 | /* Use minimal 1K map. */ |
334 | ppte = __alloc_bootmem(CIA_BROKEN_TBIA_SIZE, 32768, 0); | 334 | ppte = memblock_alloc_from(CIA_BROKEN_TBIA_SIZE, 32768, 0); |
335 | pte = (virt_to_phys(ppte) >> (PAGE_SHIFT - 1)) | 1; | 335 | pte = (virt_to_phys(ppte) >> (PAGE_SHIFT - 1)) | 1; |
336 | 336 | ||
337 | for (i = 0; i < CIA_BROKEN_TBIA_SIZE / sizeof(unsigned long); ++i) | 337 | for (i = 0; i < CIA_BROKEN_TBIA_SIZE / sizeof(unsigned long); ++i) |
diff --git a/arch/alpha/kernel/core_irongate.c b/arch/alpha/kernel/core_irongate.c index f70986683fc6..a9fd133a7fb2 100644 --- a/arch/alpha/kernel/core_irongate.c +++ b/arch/alpha/kernel/core_irongate.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/initrd.h> | 22 | #include <linux/initrd.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
25 | 24 | ||
26 | #include <asm/ptrace.h> | 25 | #include <asm/ptrace.h> |
@@ -234,8 +233,7 @@ albacore_init_arch(void) | |||
234 | unsigned long size; | 233 | unsigned long size; |
235 | 234 | ||
236 | size = initrd_end - initrd_start; | 235 | size = initrd_end - initrd_start; |
237 | free_bootmem_node(NODE_DATA(0), __pa(initrd_start), | 236 | memblock_free(__pa(initrd_start), PAGE_ALIGN(size)); |
238 | PAGE_ALIGN(size)); | ||
239 | if (!move_initrd(pci_mem)) | 237 | if (!move_initrd(pci_mem)) |
240 | printk("irongate_init_arch: initrd too big " | 238 | printk("irongate_init_arch: initrd too big " |
241 | "(%ldK)\ndisabling initrd\n", | 239 | "(%ldK)\ndisabling initrd\n", |
diff --git a/arch/alpha/kernel/core_lca.c b/arch/alpha/kernel/core_lca.c index 81c0c43635b0..57e0750419f2 100644 --- a/arch/alpha/kernel/core_lca.c +++ b/arch/alpha/kernel/core_lca.c | |||
@@ -275,7 +275,8 @@ lca_init_arch(void) | |||
275 | * Note that we do not try to save any of the DMA window CSRs | 275 | * Note that we do not try to save any of the DMA window CSRs |
276 | * before setting them, since we cannot read those CSRs on LCA. | 276 | * before setting them, since we cannot read those CSRs on LCA. |
277 | */ | 277 | */ |
278 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0); | 278 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, |
279 | SMP_CACHE_BYTES); | ||
279 | hose->sg_pci = NULL; | 280 | hose->sg_pci = NULL; |
280 | __direct_map_base = 0x40000000; | 281 | __direct_map_base = 0x40000000; |
281 | __direct_map_size = 0x40000000; | 282 | __direct_map_size = 0x40000000; |
diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c index bdebb8c206f1..c1d0c18c71ca 100644 --- a/arch/alpha/kernel/core_marvel.c +++ b/arch/alpha/kernel/core_marvel.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/mc146818rtc.h> | 18 | #include <linux/mc146818rtc.h> |
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | 22 | ||
23 | #include <asm/ptrace.h> | 23 | #include <asm/ptrace.h> |
24 | #include <asm/smp.h> | 24 | #include <asm/smp.h> |
@@ -82,7 +82,7 @@ mk_resource_name(int pe, int port, char *str) | |||
82 | char *name; | 82 | char *name; |
83 | 83 | ||
84 | sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port); | 84 | sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port); |
85 | name = alloc_bootmem(strlen(tmp) + 1); | 85 | name = memblock_alloc(strlen(tmp) + 1, SMP_CACHE_BYTES); |
86 | strcpy(name, tmp); | 86 | strcpy(name, tmp); |
87 | 87 | ||
88 | return name; | 88 | return name; |
@@ -117,7 +117,7 @@ alloc_io7(unsigned int pe) | |||
117 | return NULL; | 117 | return NULL; |
118 | } | 118 | } |
119 | 119 | ||
120 | io7 = alloc_bootmem(sizeof(*io7)); | 120 | io7 = memblock_alloc(sizeof(*io7), SMP_CACHE_BYTES); |
121 | io7->pe = pe; | 121 | io7->pe = pe; |
122 | raw_spin_lock_init(&io7->irq_lock); | 122 | raw_spin_lock_init(&io7->irq_lock); |
123 | 123 | ||
diff --git a/arch/alpha/kernel/core_mcpcia.c b/arch/alpha/kernel/core_mcpcia.c index b1549db54260..74b1d018124c 100644 --- a/arch/alpha/kernel/core_mcpcia.c +++ b/arch/alpha/kernel/core_mcpcia.c | |||
@@ -364,9 +364,11 @@ mcpcia_startup_hose(struct pci_controller *hose) | |||
364 | * Window 1 is scatter-gather (up to) 1GB at 1GB (for pci) | 364 | * Window 1 is scatter-gather (up to) 1GB at 1GB (for pci) |
365 | * Window 2 is direct access 2GB at 2GB | 365 | * Window 2 is direct access 2GB at 2GB |
366 | */ | 366 | */ |
367 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0); | 367 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, |
368 | SMP_CACHE_BYTES); | ||
368 | hose->sg_pci = iommu_arena_new(hose, 0x40000000, | 369 | hose->sg_pci = iommu_arena_new(hose, 0x40000000, |
369 | size_for_memory(0x40000000), 0); | 370 | size_for_memory(0x40000000), |
371 | SMP_CACHE_BYTES); | ||
370 | 372 | ||
371 | __direct_map_base = 0x80000000; | 373 | __direct_map_base = 0x80000000; |
372 | __direct_map_size = 0x80000000; | 374 | __direct_map_size = 0x80000000; |
diff --git a/arch/alpha/kernel/core_t2.c b/arch/alpha/kernel/core_t2.c index 2c00b61ca379..98d5b6ff8a76 100644 --- a/arch/alpha/kernel/core_t2.c +++ b/arch/alpha/kernel/core_t2.c | |||
@@ -351,7 +351,7 @@ t2_sg_map_window2(struct pci_controller *hose, | |||
351 | 351 | ||
352 | /* Note we can only do 1 SG window, as the other is for direct, so | 352 | /* Note we can only do 1 SG window, as the other is for direct, so |
353 | do an ISA SG area, especially for the floppy. */ | 353 | do an ISA SG area, especially for the floppy. */ |
354 | hose->sg_isa = iommu_arena_new(hose, base, length, 0); | 354 | hose->sg_isa = iommu_arena_new(hose, base, length, SMP_CACHE_BYTES); |
355 | hose->sg_pci = NULL; | 355 | hose->sg_pci = NULL; |
356 | 356 | ||
357 | temp = (base & 0xfff00000UL) | ((base + length - 1) >> 20); | 357 | temp = (base & 0xfff00000UL) | ((base + length - 1) >> 20); |
diff --git a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c index 132b06bdf903..2a2820fb1be6 100644 --- a/arch/alpha/kernel/core_titan.c +++ b/arch/alpha/kernel/core_titan.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/vmalloc.h> | 18 | #include <linux/vmalloc.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | 20 | ||
21 | #include <asm/ptrace.h> | 21 | #include <asm/ptrace.h> |
22 | #include <asm/smp.h> | 22 | #include <asm/smp.h> |
@@ -316,10 +316,12 @@ titan_init_one_pachip_port(titan_pachip_port *port, int index) | |||
316 | * Window 1 is direct access 1GB at 2GB | 316 | * Window 1 is direct access 1GB at 2GB |
317 | * Window 2 is scatter-gather 1GB at 3GB | 317 | * Window 2 is scatter-gather 1GB at 3GB |
318 | */ | 318 | */ |
319 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0); | 319 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, |
320 | SMP_CACHE_BYTES); | ||
320 | hose->sg_isa->align_entry = 8; /* 64KB for ISA */ | 321 | hose->sg_isa->align_entry = 8; /* 64KB for ISA */ |
321 | 322 | ||
322 | hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x40000000, 0); | 323 | hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x40000000, |
324 | SMP_CACHE_BYTES); | ||
323 | hose->sg_pci->align_entry = 4; /* Titan caches 4 PTEs at a time */ | 325 | hose->sg_pci->align_entry = 4; /* Titan caches 4 PTEs at a time */ |
324 | 326 | ||
325 | port->wsba[0].csr = hose->sg_isa->dma_base | 3; | 327 | port->wsba[0].csr = hose->sg_isa->dma_base | 3; |
diff --git a/arch/alpha/kernel/core_tsunami.c b/arch/alpha/kernel/core_tsunami.c index e7c956ea46b6..fc1ab73f23de 100644 --- a/arch/alpha/kernel/core_tsunami.c +++ b/arch/alpha/kernel/core_tsunami.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/pci.h> | 17 | #include <linux/pci.h> |
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | 21 | ||
22 | #include <asm/ptrace.h> | 22 | #include <asm/ptrace.h> |
23 | #include <asm/smp.h> | 23 | #include <asm/smp.h> |
@@ -319,12 +319,14 @@ tsunami_init_one_pchip(tsunami_pchip *pchip, int index) | |||
319 | * NOTE: we need the align_entry settings for Acer devices on ES40, | 319 | * NOTE: we need the align_entry settings for Acer devices on ES40, |
320 | * specifically floppy and IDE when memory is larger than 2GB. | 320 | * specifically floppy and IDE when memory is larger than 2GB. |
321 | */ | 321 | */ |
322 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0); | 322 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, |
323 | SMP_CACHE_BYTES); | ||
323 | /* Initially set for 4 PTEs, but will be overridden to 64K for ISA. */ | 324 | /* Initially set for 4 PTEs, but will be overridden to 64K for ISA. */ |
324 | hose->sg_isa->align_entry = 4; | 325 | hose->sg_isa->align_entry = 4; |
325 | 326 | ||
326 | hose->sg_pci = iommu_arena_new(hose, 0x40000000, | 327 | hose->sg_pci = iommu_arena_new(hose, 0x40000000, |
327 | size_for_memory(0x40000000), 0); | 328 | size_for_memory(0x40000000), |
329 | SMP_CACHE_BYTES); | ||
328 | hose->sg_pci->align_entry = 4; /* Tsunami caches 4 PTEs at a time */ | 330 | hose->sg_pci->align_entry = 4; /* Tsunami caches 4 PTEs at a time */ |
329 | 331 | ||
330 | __direct_map_base = 0x80000000; | 332 | __direct_map_base = 0x80000000; |
diff --git a/arch/alpha/kernel/core_wildfire.c b/arch/alpha/kernel/core_wildfire.c index cad36fc6ed7d..353c03d15442 100644 --- a/arch/alpha/kernel/core_wildfire.c +++ b/arch/alpha/kernel/core_wildfire.c | |||
@@ -111,8 +111,10 @@ wildfire_init_hose(int qbbno, int hoseno) | |||
111 | * ??? We ought to scale window 3 memory. | 111 | * ??? We ought to scale window 3 memory. |
112 | * | 112 | * |
113 | */ | 113 | */ |
114 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0); | 114 | hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, |
115 | hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x08000000, 0); | 115 | SMP_CACHE_BYTES); |
116 | hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x08000000, | ||
117 | SMP_CACHE_BYTES); | ||
116 | 118 | ||
117 | pci = WILDFIRE_pci(qbbno, hoseno); | 119 | pci = WILDFIRE_pci(qbbno, hoseno); |
118 | 120 | ||
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c index c7c5879869d3..091cff3c68fd 100644 --- a/arch/alpha/kernel/pci-noop.c +++ b/arch/alpha/kernel/pci-noop.c | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/gfp.h> | 11 | #include <linux/gfp.h> |
12 | #include <linux/capability.h> | 12 | #include <linux/capability.h> |
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
@@ -33,7 +33,7 @@ alloc_pci_controller(void) | |||
33 | { | 33 | { |
34 | struct pci_controller *hose; | 34 | struct pci_controller *hose; |
35 | 35 | ||
36 | hose = alloc_bootmem(sizeof(*hose)); | 36 | hose = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES); |
37 | 37 | ||
38 | *hose_tail = hose; | 38 | *hose_tail = hose; |
39 | hose_tail = &hose->next; | 39 | hose_tail = &hose->next; |
@@ -44,7 +44,7 @@ alloc_pci_controller(void) | |||
44 | struct resource * __init | 44 | struct resource * __init |
45 | alloc_resource(void) | 45 | alloc_resource(void) |
46 | { | 46 | { |
47 | return alloc_bootmem(sizeof(struct resource)); | 47 | return memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES); |
48 | } | 48 | } |
49 | 49 | ||
50 | SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus, | 50 | SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus, |
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index c668c3b7a167..97098127df83 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/ioport.h> | 19 | #include <linux/ioport.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/cache.h> | 23 | #include <linux/cache.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
@@ -392,7 +392,7 @@ alloc_pci_controller(void) | |||
392 | { | 392 | { |
393 | struct pci_controller *hose; | 393 | struct pci_controller *hose; |
394 | 394 | ||
395 | hose = alloc_bootmem(sizeof(*hose)); | 395 | hose = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES); |
396 | 396 | ||
397 | *hose_tail = hose; | 397 | *hose_tail = hose; |
398 | hose_tail = &hose->next; | 398 | hose_tail = &hose->next; |
@@ -403,7 +403,7 @@ alloc_pci_controller(void) | |||
403 | struct resource * __init | 403 | struct resource * __init |
404 | alloc_resource(void) | 404 | alloc_resource(void) |
405 | { | 405 | { |
406 | return alloc_bootmem(sizeof(struct resource)); | 406 | return memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES); |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index 6923b0d9c1e1..46e08e0d9181 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
9 | #include <linux/gfp.h> | 9 | #include <linux/gfp.h> |
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/export.h> | 11 | #include <linux/export.h> |
12 | #include <linux/scatterlist.h> | 12 | #include <linux/scatterlist.h> |
13 | #include <linux/log2.h> | 13 | #include <linux/log2.h> |
@@ -74,26 +74,26 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base, | |||
74 | 74 | ||
75 | #ifdef CONFIG_DISCONTIGMEM | 75 | #ifdef CONFIG_DISCONTIGMEM |
76 | 76 | ||
77 | arena = alloc_bootmem_node(NODE_DATA(nid), sizeof(*arena)); | 77 | arena = memblock_alloc_node(sizeof(*arena), align, nid); |
78 | if (!NODE_DATA(nid) || !arena) { | 78 | if (!NODE_DATA(nid) || !arena) { |
79 | printk("%s: couldn't allocate arena from node %d\n" | 79 | printk("%s: couldn't allocate arena from node %d\n" |
80 | " falling back to system-wide allocation\n", | 80 | " falling back to system-wide allocation\n", |
81 | __func__, nid); | 81 | __func__, nid); |
82 | arena = alloc_bootmem(sizeof(*arena)); | 82 | arena = memblock_alloc(sizeof(*arena), SMP_CACHE_BYTES); |
83 | } | 83 | } |
84 | 84 | ||
85 | arena->ptes = __alloc_bootmem_node(NODE_DATA(nid), mem_size, align, 0); | 85 | arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid); |
86 | if (!NODE_DATA(nid) || !arena->ptes) { | 86 | if (!NODE_DATA(nid) || !arena->ptes) { |
87 | printk("%s: couldn't allocate arena ptes from node %d\n" | 87 | printk("%s: couldn't allocate arena ptes from node %d\n" |
88 | " falling back to system-wide allocation\n", | 88 | " falling back to system-wide allocation\n", |
89 | __func__, nid); | 89 | __func__, nid); |
90 | arena->ptes = __alloc_bootmem(mem_size, align, 0); | 90 | arena->ptes = memblock_alloc_from(mem_size, align, 0); |
91 | } | 91 | } |
92 | 92 | ||
93 | #else /* CONFIG_DISCONTIGMEM */ | 93 | #else /* CONFIG_DISCONTIGMEM */ |
94 | 94 | ||
95 | arena = alloc_bootmem(sizeof(*arena)); | 95 | arena = memblock_alloc(sizeof(*arena), SMP_CACHE_BYTES); |
96 | arena->ptes = __alloc_bootmem(mem_size, align, 0); | 96 | arena->ptes = memblock_alloc_from(mem_size, align, 0); |
97 | 97 | ||
98 | #endif /* CONFIG_DISCONTIGMEM */ | 98 | #endif /* CONFIG_DISCONTIGMEM */ |
99 | 99 | ||
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index 4f0d94471bc9..a37fd990bd55 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/string.h> | 29 | #include <linux/string.h> |
30 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
31 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
32 | #include <linux/bootmem.h> | ||
33 | #include <linux/memblock.h> | 32 | #include <linux/memblock.h> |
34 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
35 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
@@ -294,7 +293,7 @@ move_initrd(unsigned long mem_limit) | |||
294 | unsigned long size; | 293 | unsigned long size; |
295 | 294 | ||
296 | size = initrd_end - initrd_start; | 295 | size = initrd_end - initrd_start; |
297 | start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0); | 296 | start = memblock_alloc_from(PAGE_ALIGN(size), PAGE_SIZE, 0); |
298 | if (!start || __pa(start) + size > mem_limit) { | 297 | if (!start || __pa(start) + size > mem_limit) { |
299 | initrd_start = initrd_end = 0; | 298 | initrd_start = initrd_end = 0; |
300 | return NULL; | 299 | return NULL; |
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c index ff4f54b86c7f..cd9a112d67ff 100644 --- a/arch/alpha/kernel/sys_nautilus.c +++ b/arch/alpha/kernel/sys_nautilus.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/reboot.h> | 34 | #include <linux/reboot.h> |
35 | #include <linux/bootmem.h> | 35 | #include <linux/memblock.h> |
36 | #include <linux/bitops.h> | 36 | #include <linux/bitops.h> |
37 | 37 | ||
38 | #include <asm/ptrace.h> | 38 | #include <asm/ptrace.h> |
diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index 9d74520298ab..a42fc5c4db89 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/swap.h> | 20 | #include <linux/swap.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/bootmem.h> /* max_low_pfn */ | 22 | #include <linux/memblock.h> /* max_low_pfn */ |
23 | #include <linux/vmalloc.h> | 23 | #include <linux/vmalloc.h> |
24 | #include <linux/gfp.h> | 24 | #include <linux/gfp.h> |
25 | 25 | ||
@@ -282,7 +282,7 @@ mem_init(void) | |||
282 | { | 282 | { |
283 | set_max_mapnr(max_low_pfn); | 283 | set_max_mapnr(max_low_pfn); |
284 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); | 284 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); |
285 | free_all_bootmem(); | 285 | memblock_free_all(); |
286 | mem_init_print_info(NULL); | 286 | mem_init_print_info(NULL); |
287 | } | 287 | } |
288 | 288 | ||
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c index 26cd925d19b1..74846553e3f1 100644 --- a/arch/alpha/mm/numa.c +++ b/arch/alpha/mm/numa.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/bootmem.h> | ||
14 | #include <linux/memblock.h> | 13 | #include <linux/memblock.h> |
15 | #include <linux/swap.h> | 14 | #include <linux/swap.h> |
16 | #include <linux/initrd.h> | 15 | #include <linux/initrd.h> |
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index e98c6b8e6186..c9e2a1323536 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -37,14 +37,12 @@ config ARC | |||
37 | select HAVE_KERNEL_LZMA | 37 | select HAVE_KERNEL_LZMA |
38 | select HAVE_KPROBES | 38 | select HAVE_KPROBES |
39 | select HAVE_KRETPROBES | 39 | select HAVE_KRETPROBES |
40 | select HAVE_MEMBLOCK | ||
41 | select HAVE_MOD_ARCH_SPECIFIC | 40 | select HAVE_MOD_ARCH_SPECIFIC |
42 | select HAVE_OPROFILE | 41 | select HAVE_OPROFILE |
43 | select HAVE_PERF_EVENTS | 42 | select HAVE_PERF_EVENTS |
44 | select HANDLE_DOMAIN_IRQ | 43 | select HANDLE_DOMAIN_IRQ |
45 | select IRQ_DOMAIN | 44 | select IRQ_DOMAIN |
46 | select MODULES_USE_ELF_RELA | 45 | select MODULES_USE_ELF_RELA |
47 | select NO_BOOTMEM | ||
48 | select OF | 46 | select OF |
49 | select OF_EARLY_FLATTREE | 47 | select OF_EARLY_FLATTREE |
50 | select OF_RESERVED_MEM | 48 | select OF_RESERVED_MEM |
diff --git a/arch/arc/include/asm/processor.h b/arch/arc/include/asm/processor.h index 8ee41e988169..10346d6cf926 100644 --- a/arch/arc/include/asm/processor.h +++ b/arch/arc/include/asm/processor.h | |||
@@ -98,14 +98,6 @@ extern void start_thread(struct pt_regs * regs, unsigned long pc, | |||
98 | 98 | ||
99 | extern unsigned int get_wchan(struct task_struct *p); | 99 | extern unsigned int get_wchan(struct task_struct *p); |
100 | 100 | ||
101 | /* | ||
102 | * Default implementation of macro that returns current | ||
103 | * instruction pointer ("program counter"). | ||
104 | * Should the PC register be read instead ? This macro does not seem to | ||
105 | * be used in many places so this wont be all that bad. | ||
106 | */ | ||
107 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
108 | |||
109 | #endif /* !__ASSEMBLY__ */ | 101 | #endif /* !__ASSEMBLY__ */ |
110 | 102 | ||
111 | /* | 103 | /* |
diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c index 183391d4d33a..d34f69eb1a95 100644 --- a/arch/arc/kernel/unwind.c +++ b/arch/arc/kernel/unwind.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/bootmem.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/sort.h> | 19 | #include <linux/sort.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/stop_machine.h> | 21 | #include <linux/stop_machine.h> |
@@ -181,8 +181,8 @@ static void init_unwind_hdr(struct unwind_table *table, | |||
181 | */ | 181 | */ |
182 | static void *__init unw_hdr_alloc_early(unsigned long sz) | 182 | static void *__init unw_hdr_alloc_early(unsigned long sz) |
183 | { | 183 | { |
184 | return __alloc_bootmem_nopanic(sz, sizeof(unsigned int), | 184 | return memblock_alloc_from_nopanic(sz, sizeof(unsigned int), |
185 | MAX_DMA_ADDRESS); | 185 | MAX_DMA_ADDRESS); |
186 | } | 186 | } |
187 | 187 | ||
188 | static void *unw_hdr_alloc(unsigned long sz) | 188 | static void *unw_hdr_alloc(unsigned long sz) |
diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c index 77ff64a874a1..48e700151810 100644 --- a/arch/arc/mm/highmem.c +++ b/arch/arc/mm/highmem.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/export.h> | 11 | #include <linux/export.h> |
12 | #include <linux/highmem.h> | 12 | #include <linux/highmem.h> |
13 | #include <asm/processor.h> | 13 | #include <asm/processor.h> |
@@ -123,7 +123,7 @@ static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr) | |||
123 | pud_k = pud_offset(pgd_k, kvaddr); | 123 | pud_k = pud_offset(pgd_k, kvaddr); |
124 | pmd_k = pmd_offset(pud_k, kvaddr); | 124 | pmd_k = pmd_offset(pud_k, kvaddr); |
125 | 125 | ||
126 | pte_k = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE); | 126 | pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); |
127 | pmd_populate_kernel(&init_mm, pmd_k, pte_k); | 127 | pmd_populate_kernel(&init_mm, pmd_k, pte_k); |
128 | return pte_k; | 128 | return pte_k; |
129 | } | 129 | } |
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index ba145065c579..f8fe5668b30f 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/bootmem.h> | ||
12 | #include <linux/memblock.h> | 11 | #include <linux/memblock.h> |
13 | #ifdef CONFIG_BLK_DEV_INITRD | 12 | #ifdef CONFIG_BLK_DEV_INITRD |
14 | #include <linux/initrd.h> | 13 | #include <linux/initrd.h> |
@@ -218,7 +217,7 @@ void __init mem_init(void) | |||
218 | free_highmem_page(pfn_to_page(tmp)); | 217 | free_highmem_page(pfn_to_page(tmp)); |
219 | #endif | 218 | #endif |
220 | 219 | ||
221 | free_all_bootmem(); | 220 | memblock_free_all(); |
222 | mem_init_print_info(NULL); | 221 | mem_init_print_info(NULL); |
223 | } | 222 | } |
224 | 223 | ||
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b8c6062ca0c1..91be74d8df65 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -82,7 +82,6 @@ config ARM | |||
82 | select HAVE_KERNEL_XZ | 82 | select HAVE_KERNEL_XZ |
83 | select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M | 83 | select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M |
84 | select HAVE_KRETPROBES if (HAVE_KPROBES) | 84 | select HAVE_KRETPROBES if (HAVE_KPROBES) |
85 | select HAVE_MEMBLOCK | ||
86 | select HAVE_MOD_ARCH_SPECIFIC | 85 | select HAVE_MOD_ARCH_SPECIFIC |
87 | select HAVE_NMI | 86 | select HAVE_NMI |
88 | select HAVE_OPROFILE if (HAVE_PERF_EVENTS) | 87 | select HAVE_OPROFILE if (HAVE_PERF_EVENTS) |
@@ -100,7 +99,6 @@ config ARM | |||
100 | select IRQ_FORCED_THREADING | 99 | select IRQ_FORCED_THREADING |
101 | select MODULES_USE_ELF_REL | 100 | select MODULES_USE_ELF_REL |
102 | select NEED_DMA_MAP_STATE | 101 | select NEED_DMA_MAP_STATE |
103 | select NO_BOOTMEM | ||
104 | select OF_EARLY_FLATTREE if OF | 102 | select OF_EARLY_FLATTREE if OF |
105 | select OF_RESERVED_MEM if OF | 103 | select OF_RESERVED_MEM if OF |
106 | select OLD_SIGACTION | 104 | select OLD_SIGACTION |
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h index 1bf65b47808a..120f4c9bbfde 100644 --- a/arch/arm/include/asm/processor.h +++ b/arch/arm/include/asm/processor.h | |||
@@ -11,12 +11,6 @@ | |||
11 | #ifndef __ASM_ARM_PROCESSOR_H | 11 | #ifndef __ASM_ARM_PROCESSOR_H |
12 | #define __ASM_ARM_PROCESSOR_H | 12 | #define __ASM_ARM_PROCESSOR_H |
13 | 13 | ||
14 | /* | ||
15 | * Default implementation of macro that returns current | ||
16 | * instruction pointer ("program counter"). | ||
17 | */ | ||
18 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
19 | |||
20 | #ifdef __KERNEL__ | 14 | #ifdef __KERNEL__ |
21 | 15 | ||
22 | #include <asm/hw_breakpoint.h> | 16 | #include <asm/hw_breakpoint.h> |
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index 13bcd3b867cb..e3057c1b55b9 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/export.h> | 12 | #include <linux/export.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/bootmem.h> | ||
16 | #include <linux/memblock.h> | 15 | #include <linux/memblock.h> |
17 | #include <linux/of.h> | 16 | #include <linux/of.h> |
18 | #include <linux/of_fdt.h> | 17 | #include <linux/of_fdt.h> |
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 4c249cb261f3..ac7e08886863 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/utsname.h> | 16 | #include <linux/utsname.h> |
17 | #include <linux/initrd.h> | 17 | #include <linux/initrd.h> |
18 | #include <linux/console.h> | 18 | #include <linux/console.h> |
19 | #include <linux/bootmem.h> | ||
20 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
21 | #include <linux/screen_info.h> | 20 | #include <linux/screen_info.h> |
22 | #include <linux/of_platform.h> | 21 | #include <linux/of_platform.h> |
@@ -857,7 +856,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) | |||
857 | */ | 856 | */ |
858 | boot_alias_start = phys_to_idmap(start); | 857 | boot_alias_start = phys_to_idmap(start); |
859 | if (arm_has_idmap_alias() && boot_alias_start != IDMAP_INVALID_ADDR) { | 858 | if (arm_has_idmap_alias() && boot_alias_start != IDMAP_INVALID_ADDR) { |
860 | res = memblock_virt_alloc(sizeof(*res), 0); | 859 | res = memblock_alloc(sizeof(*res), SMP_CACHE_BYTES); |
861 | res->name = "System RAM (boot alias)"; | 860 | res->name = "System RAM (boot alias)"; |
862 | res->start = boot_alias_start; | 861 | res->start = boot_alias_start; |
863 | res->end = phys_to_idmap(end); | 862 | res->end = phys_to_idmap(end); |
@@ -865,7 +864,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) | |||
865 | request_resource(&iomem_resource, res); | 864 | request_resource(&iomem_resource, res); |
866 | } | 865 | } |
867 | 866 | ||
868 | res = memblock_virt_alloc(sizeof(*res), 0); | 867 | res = memblock_alloc(sizeof(*res), SMP_CACHE_BYTES); |
869 | res->name = "System RAM"; | 868 | res->name = "System RAM"; |
870 | res->start = start; | 869 | res->start = start; |
871 | res->end = end; | 870 | res->end = end; |
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 56a1fe90d394..083dcd9942ce 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
@@ -141,7 +141,7 @@ | |||
141 | #include <linux/cpu.h> | 141 | #include <linux/cpu.h> |
142 | #include <linux/of.h> | 142 | #include <linux/of.h> |
143 | #include <linux/of_address.h> | 143 | #include <linux/of_address.h> |
144 | #include <linux/bootmem.h> | 144 | #include <linux/memblock.h> |
145 | 145 | ||
146 | #include <linux/platform_data/ti-sysc.h> | 146 | #include <linux/platform_data/ti-sysc.h> |
147 | 147 | ||
@@ -726,7 +726,7 @@ static int __init _setup_clkctrl_provider(struct device_node *np) | |||
726 | u64 size; | 726 | u64 size; |
727 | int i; | 727 | int i; |
728 | 728 | ||
729 | provider = memblock_virt_alloc(sizeof(*provider), 0); | 729 | provider = memblock_alloc(sizeof(*provider), SMP_CACHE_BYTES); |
730 | if (!provider) | 730 | if (!provider) |
731 | return -ENOMEM; | 731 | return -ENOMEM; |
732 | 732 | ||
@@ -736,12 +736,14 @@ static int __init _setup_clkctrl_provider(struct device_node *np) | |||
736 | of_property_count_elems_of_size(np, "reg", sizeof(u32)) / 2; | 736 | of_property_count_elems_of_size(np, "reg", sizeof(u32)) / 2; |
737 | 737 | ||
738 | provider->addr = | 738 | provider->addr = |
739 | memblock_virt_alloc(sizeof(void *) * provider->num_addrs, 0); | 739 | memblock_alloc(sizeof(void *) * provider->num_addrs, |
740 | SMP_CACHE_BYTES); | ||
740 | if (!provider->addr) | 741 | if (!provider->addr) |
741 | return -ENOMEM; | 742 | return -ENOMEM; |
742 | 743 | ||
743 | provider->size = | 744 | provider->size = |
744 | memblock_virt_alloc(sizeof(u32) * provider->num_addrs, 0); | 745 | memblock_alloc(sizeof(u32) * provider->num_addrs, |
746 | SMP_CACHE_BYTES); | ||
745 | if (!provider->size) | 747 | if (!provider->size) |
746 | return -ENOMEM; | 748 | return -ENOMEM; |
747 | 749 | ||
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 66566472c153..661fe48ab78d 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -9,7 +9,6 @@ | |||
9 | * | 9 | * |
10 | * DMA uncached mapping support. | 10 | * DMA uncached mapping support. |
11 | */ | 11 | */ |
12 | #include <linux/bootmem.h> | ||
13 | #include <linux/module.h> | 12 | #include <linux/module.h> |
14 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
15 | #include <linux/genalloc.h> | 14 | #include <linux/genalloc.h> |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 0cc8e04295a4..32e4845af2b6 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/swap.h> | 12 | #include <linux/swap.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/mman.h> | 14 | #include <linux/mman.h> |
16 | #include <linux/sched/signal.h> | 15 | #include <linux/sched/signal.h> |
17 | #include <linux/sched/task.h> | 16 | #include <linux/sched/task.h> |
@@ -508,7 +507,7 @@ void __init mem_init(void) | |||
508 | 507 | ||
509 | /* this will put all unused low memory onto the freelists */ | 508 | /* this will put all unused low memory onto the freelists */ |
510 | free_unused_memmap(); | 509 | free_unused_memmap(); |
511 | free_all_bootmem(); | 510 | memblock_free_all(); |
512 | 511 | ||
513 | #ifdef CONFIG_SA1111 | 512 | #ifdef CONFIG_SA1111 |
514 | /* now that our DMA memory is actually so designated, we can free it */ | 513 | /* now that our DMA memory is actually so designated, we can free it */ |
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index e46a6a446cdd..f5cc1ccfea3d 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
@@ -721,7 +721,7 @@ EXPORT_SYMBOL(phys_mem_access_prot); | |||
721 | 721 | ||
722 | static void __init *early_alloc_aligned(unsigned long sz, unsigned long align) | 722 | static void __init *early_alloc_aligned(unsigned long sz, unsigned long align) |
723 | { | 723 | { |
724 | void *ptr = __va(memblock_alloc(sz, align)); | 724 | void *ptr = __va(memblock_phys_alloc(sz, align)); |
725 | memset(ptr, 0, sz); | 725 | memset(ptr, 0, sz); |
726 | return ptr; | 726 | return ptr; |
727 | } | 727 | } |
diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c index 785d2a562a23..cb44aa290e73 100644 --- a/arch/arm/xen/mm.c +++ b/arch/arm/xen/mm.c | |||
@@ -1,6 +1,5 @@ | |||
1 | #include <linux/cpu.h> | 1 | #include <linux/cpu.h> |
2 | #include <linux/dma-mapping.h> | 2 | #include <linux/dma-mapping.h> |
3 | #include <linux/bootmem.h> | ||
4 | #include <linux/gfp.h> | 3 | #include <linux/gfp.h> |
5 | #include <linux/highmem.h> | 4 | #include <linux/highmem.h> |
6 | #include <linux/export.h> | 5 | #include <linux/export.h> |
diff --git a/arch/arm/xen/p2m.c b/arch/arm/xen/p2m.c index 0641ba54ab62..e70a49fc8dcd 100644 --- a/arch/arm/xen/p2m.c +++ b/arch/arm/xen/p2m.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #include <linux/bootmem.h> | 1 | #include <linux/memblock.h> |
2 | #include <linux/gfp.h> | 2 | #include <linux/gfp.h> |
3 | #include <linux/export.h> | 3 | #include <linux/export.h> |
4 | #include <linux/spinlock.h> | 4 | #include <linux/spinlock.h> |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 964f682a2b7b..787d7850e064 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig | |||
@@ -139,7 +139,6 @@ config ARM64 | |||
139 | select HAVE_GENERIC_DMA_COHERENT | 139 | select HAVE_GENERIC_DMA_COHERENT |
140 | select HAVE_HW_BREAKPOINT if PERF_EVENTS | 140 | select HAVE_HW_BREAKPOINT if PERF_EVENTS |
141 | select HAVE_IRQ_TIME_ACCOUNTING | 141 | select HAVE_IRQ_TIME_ACCOUNTING |
142 | select HAVE_MEMBLOCK | ||
143 | select HAVE_MEMBLOCK_NODE_MAP if NUMA | 142 | select HAVE_MEMBLOCK_NODE_MAP if NUMA |
144 | select HAVE_NMI | 143 | select HAVE_NMI |
145 | select HAVE_PATA_PLATFORM | 144 | select HAVE_PATA_PLATFORM |
@@ -161,7 +160,6 @@ config ARM64 | |||
161 | select MULTI_IRQ_HANDLER | 160 | select MULTI_IRQ_HANDLER |
162 | select NEED_DMA_MAP_STATE | 161 | select NEED_DMA_MAP_STATE |
163 | select NEED_SG_DMA_LENGTH | 162 | select NEED_SG_DMA_LENGTH |
164 | select NO_BOOTMEM | ||
165 | select OF | 163 | select OF |
166 | select OF_EARLY_FLATTREE | 164 | select OF_EARLY_FLATTREE |
167 | select OF_RESERVED_MEM | 165 | select OF_RESERVED_MEM |
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 2bf6691371c2..3e2091708b8e 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h | |||
@@ -25,13 +25,6 @@ | |||
25 | #define USER_DS (TASK_SIZE_64 - 1) | 25 | #define USER_DS (TASK_SIZE_64 - 1) |
26 | 26 | ||
27 | #ifndef __ASSEMBLY__ | 27 | #ifndef __ASSEMBLY__ |
28 | |||
29 | /* | ||
30 | * Default implementation of macro that returns current | ||
31 | * instruction pointer ("program counter"). | ||
32 | */ | ||
33 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
34 | |||
35 | #ifdef __KERNEL__ | 28 | #ifdef __KERNEL__ |
36 | 29 | ||
37 | #include <linux/build_bug.h> | 30 | #include <linux/build_bug.h> |
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index ed46dc188b22..44e3c351e1ea 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #define pr_fmt(fmt) "ACPI: " fmt | 16 | #define pr_fmt(fmt) "ACPI: " fmt |
17 | 17 | ||
18 | #include <linux/acpi.h> | 18 | #include <linux/acpi.h> |
19 | #include <linux/bootmem.h> | ||
20 | #include <linux/cpumask.h> | 19 | #include <linux/cpumask.h> |
21 | #include <linux/efi.h> | 20 | #include <linux/efi.h> |
22 | #include <linux/efi-bgrt.h> | 21 | #include <linux/efi-bgrt.h> |
diff --git a/arch/arm64/kernel/acpi_numa.c b/arch/arm64/kernel/acpi_numa.c index 4f4f1815e047..eac1d0cc595c 100644 --- a/arch/arm64/kernel/acpi_numa.c +++ b/arch/arm64/kernel/acpi_numa.c | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/bitmap.h> | 20 | #include <linux/bitmap.h> |
21 | #include <linux/bootmem.h> | ||
22 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
23 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index d0f62dd24c90..953e316521fc 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/initrd.h> | 26 | #include <linux/initrd.h> |
27 | #include <linux/console.h> | 27 | #include <linux/console.h> |
28 | #include <linux/cache.h> | 28 | #include <linux/cache.h> |
29 | #include <linux/bootmem.h> | ||
30 | #include <linux/screen_info.h> | 29 | #include <linux/screen_info.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/kexec.h> | 31 | #include <linux/kexec.h> |
@@ -217,8 +216,9 @@ static void __init request_standard_resources(void) | |||
217 | kernel_data.end = __pa_symbol(_end - 1); | 216 | kernel_data.end = __pa_symbol(_end - 1); |
218 | 217 | ||
219 | num_standard_resources = memblock.memory.cnt; | 218 | num_standard_resources = memblock.memory.cnt; |
220 | standard_resources = alloc_bootmem_low(num_standard_resources * | 219 | standard_resources = memblock_alloc_low(num_standard_resources * |
221 | sizeof(*standard_resources)); | 220 | sizeof(*standard_resources), |
221 | SMP_CACHE_BYTES); | ||
222 | 222 | ||
223 | for_each_memblock(memory, region) { | 223 | for_each_memblock(memory, region) { |
224 | res = &standard_resources[i++]; | 224 | res = &standard_resources[i++]; |
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index d190612b8f33..3a703e5d4e32 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/gfp.h> | 20 | #include <linux/gfp.h> |
21 | #include <linux/acpi.h> | 21 | #include <linux/acpi.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/cache.h> | 23 | #include <linux/cache.h> |
24 | #include <linux/export.h> | 24 | #include <linux/export.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 3cf87341859f..9d9582cac6c4 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
23 | #include <linux/swap.h> | 23 | #include <linux/swap.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/bootmem.h> | ||
26 | #include <linux/cache.h> | 25 | #include <linux/cache.h> |
27 | #include <linux/mman.h> | 26 | #include <linux/mman.h> |
28 | #include <linux/nodemask.h> | 27 | #include <linux/nodemask.h> |
@@ -536,7 +535,7 @@ static inline void free_memmap(unsigned long start_pfn, unsigned long end_pfn) | |||
536 | * memmap array. | 535 | * memmap array. |
537 | */ | 536 | */ |
538 | if (pg < pgend) | 537 | if (pg < pgend) |
539 | free_bootmem(pg, pgend - pg); | 538 | memblock_free(pg, pgend - pg); |
540 | } | 539 | } |
541 | 540 | ||
542 | /* | 541 | /* |
@@ -599,7 +598,7 @@ void __init mem_init(void) | |||
599 | free_unused_memmap(); | 598 | free_unused_memmap(); |
600 | #endif | 599 | #endif |
601 | /* this will put all unused low memory onto the freelists */ | 600 | /* this will put all unused low memory onto the freelists */ |
602 | free_all_bootmem(); | 601 | memblock_free_all(); |
603 | 602 | ||
604 | kexec_reserve_crashkres_pages(); | 603 | kexec_reserve_crashkres_pages(); |
605 | 604 | ||
diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index fccb1a6f8c6f..63527e585aac 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c | |||
@@ -11,7 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) "kasan: " fmt | 13 | #define pr_fmt(fmt) "kasan: " fmt |
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/kasan.h> | 14 | #include <linux/kasan.h> |
16 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
17 | #include <linux/sched/task.h> | 16 | #include <linux/sched/task.h> |
@@ -38,7 +37,7 @@ static pgd_t tmp_pg_dir[PTRS_PER_PGD] __initdata __aligned(PGD_SIZE); | |||
38 | 37 | ||
39 | static phys_addr_t __init kasan_alloc_zeroed_page(int node) | 38 | static phys_addr_t __init kasan_alloc_zeroed_page(int node) |
40 | { | 39 | { |
41 | void *p = memblock_virt_alloc_try_nid(PAGE_SIZE, PAGE_SIZE, | 40 | void *p = memblock_alloc_try_nid(PAGE_SIZE, PAGE_SIZE, |
42 | __pa(MAX_DMA_ADDRESS), | 41 | __pa(MAX_DMA_ADDRESS), |
43 | MEMBLOCK_ALLOC_ACCESSIBLE, node); | 42 | MEMBLOCK_ALLOC_ACCESSIBLE, node); |
44 | return __pa(p); | 43 | return __pa(p); |
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 9498c15b847b..394b8d554def 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c | |||
@@ -101,7 +101,7 @@ static phys_addr_t __init early_pgtable_alloc(void) | |||
101 | phys_addr_t phys; | 101 | phys_addr_t phys; |
102 | void *ptr; | 102 | void *ptr; |
103 | 103 | ||
104 | phys = memblock_alloc(PAGE_SIZE, PAGE_SIZE); | 104 | phys = memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); |
105 | 105 | ||
106 | /* | 106 | /* |
107 | * The FIX_{PGD,PUD,PMD} slots may be in active use, but the FIX_PTE | 107 | * The FIX_{PGD,PUD,PMD} slots may be in active use, but the FIX_PTE |
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c index d7b66fc5e1c5..27a31efd9e8e 100644 --- a/arch/arm64/mm/numa.c +++ b/arch/arm64/mm/numa.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #define pr_fmt(fmt) "NUMA: " fmt | 20 | #define pr_fmt(fmt) "NUMA: " fmt |
21 | 21 | ||
22 | #include <linux/acpi.h> | 22 | #include <linux/acpi.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/of.h> | 25 | #include <linux/of.h> |
@@ -168,7 +167,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, | |||
168 | { | 167 | { |
169 | int nid = early_cpu_to_node(cpu); | 168 | int nid = early_cpu_to_node(cpu); |
170 | 169 | ||
171 | return memblock_virt_alloc_try_nid(size, align, | 170 | return memblock_alloc_try_nid(size, align, |
172 | __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); | 171 | __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
173 | } | 172 | } |
174 | 173 | ||
@@ -237,7 +236,7 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) | |||
237 | if (start_pfn >= end_pfn) | 236 | if (start_pfn >= end_pfn) |
238 | pr_info("Initmem setup node %d [<memory-less node>]\n", nid); | 237 | pr_info("Initmem setup node %d [<memory-less node>]\n", nid); |
239 | 238 | ||
240 | nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); | 239 | nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); |
241 | nd = __va(nd_pa); | 240 | nd = __va(nd_pa); |
242 | 241 | ||
243 | /* report and initialize */ | 242 | /* report and initialize */ |
diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig index f65a084607fd..84420109113d 100644 --- a/arch/c6x/Kconfig +++ b/arch/c6x/Kconfig | |||
@@ -13,7 +13,6 @@ config C6X | |||
13 | select GENERIC_ATOMIC64 | 13 | select GENERIC_ATOMIC64 |
14 | select GENERIC_IRQ_SHOW | 14 | select GENERIC_IRQ_SHOW |
15 | select HAVE_ARCH_TRACEHOOK | 15 | select HAVE_ARCH_TRACEHOOK |
16 | select HAVE_MEMBLOCK | ||
17 | select SPARSE_IRQ | 16 | select SPARSE_IRQ |
18 | select IRQ_DOMAIN | 17 | select IRQ_DOMAIN |
19 | select OF | 18 | select OF |
diff --git a/arch/c6x/include/asm/processor.h b/arch/c6x/include/asm/processor.h index 8f7cce829f8e..a8581f5b27f6 100644 --- a/arch/c6x/include/asm/processor.h +++ b/arch/c6x/include/asm/processor.h | |||
@@ -18,17 +18,6 @@ | |||
18 | #include <asm/current.h> | 18 | #include <asm/current.h> |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * Default implementation of macro that returns current | ||
22 | * instruction pointer ("program counter"). | ||
23 | */ | ||
24 | #define current_text_addr() \ | ||
25 | ({ \ | ||
26 | void *__pc; \ | ||
27 | asm("mvc .S2 pce1,%0\n" : "=b"(__pc)); \ | ||
28 | __pc; \ | ||
29 | }) | ||
30 | |||
31 | /* | ||
32 | * User space process size. This is mostly meaningless for NOMMU | 21 | * User space process size. This is mostly meaningless for NOMMU |
33 | * but some C6X processors may have RAM addresses up to 0xFFFFFFFF. | 22 | * but some C6X processors may have RAM addresses up to 0xFFFFFFFF. |
34 | * Since calls like mmap() can return an address or an error, we | 23 | * Since calls like mmap() can return an address or an error, we |
diff --git a/arch/c6x/kernel/setup.c b/arch/c6x/kernel/setup.c index 05d96a9541b5..2e1c0ea22eb0 100644 --- a/arch/c6x/kernel/setup.c +++ b/arch/c6x/kernel/setup.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/dma-mapping.h> | 11 | #include <linux/dma-mapping.h> |
12 | #include <linux/memblock.h> | 12 | #include <linux/memblock.h> |
13 | #include <linux/seq_file.h> | 13 | #include <linux/seq_file.h> |
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/clkdev.h> | 14 | #include <linux/clkdev.h> |
16 | #include <linux/initrd.h> | 15 | #include <linux/initrd.h> |
17 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
diff --git a/arch/c6x/mm/dma-coherent.c b/arch/c6x/mm/dma-coherent.c index d0a8e0c4b27e..01305c787201 100644 --- a/arch/c6x/mm/dma-coherent.c +++ b/arch/c6x/mm/dma-coherent.c | |||
@@ -135,8 +135,8 @@ void __init coherent_mem_init(phys_addr_t start, u32 size) | |||
135 | if (dma_size & (PAGE_SIZE - 1)) | 135 | if (dma_size & (PAGE_SIZE - 1)) |
136 | ++dma_pages; | 136 | ++dma_pages; |
137 | 137 | ||
138 | bitmap_phys = memblock_alloc(BITS_TO_LONGS(dma_pages) * sizeof(long), | 138 | bitmap_phys = memblock_phys_alloc(BITS_TO_LONGS(dma_pages) * sizeof(long), |
139 | sizeof(long)); | 139 | sizeof(long)); |
140 | 140 | ||
141 | dma_bitmap = phys_to_virt(bitmap_phys); | 141 | dma_bitmap = phys_to_virt(bitmap_phys); |
142 | memset(dma_bitmap, 0, dma_pages * PAGE_SIZE); | 142 | memset(dma_bitmap, 0, dma_pages * PAGE_SIZE); |
diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c index 4cc72b0d1c1d..af5ada0520be 100644 --- a/arch/c6x/mm/init.c +++ b/arch/c6x/mm/init.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/swap.h> | 12 | #include <linux/swap.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #ifdef CONFIG_BLK_DEV_RAM | 15 | #ifdef CONFIG_BLK_DEV_RAM |
16 | #include <linux/blkdev.h> | 16 | #include <linux/blkdev.h> |
17 | #endif | 17 | #endif |
@@ -38,7 +38,8 @@ void __init paging_init(void) | |||
38 | struct pglist_data *pgdat = NODE_DATA(0); | 38 | struct pglist_data *pgdat = NODE_DATA(0); |
39 | unsigned long zones_size[MAX_NR_ZONES] = {0, }; | 39 | unsigned long zones_size[MAX_NR_ZONES] = {0, }; |
40 | 40 | ||
41 | empty_zero_page = (unsigned long) alloc_bootmem_pages(PAGE_SIZE); | 41 | empty_zero_page = (unsigned long) memblock_alloc(PAGE_SIZE, |
42 | PAGE_SIZE); | ||
42 | memset((void *)empty_zero_page, 0, PAGE_SIZE); | 43 | memset((void *)empty_zero_page, 0, PAGE_SIZE); |
43 | 44 | ||
44 | /* | 45 | /* |
@@ -61,7 +62,7 @@ void __init mem_init(void) | |||
61 | high_memory = (void *)(memory_end & PAGE_MASK); | 62 | high_memory = (void *)(memory_end & PAGE_MASK); |
62 | 63 | ||
63 | /* this will put all memory onto the freelists */ | 64 | /* this will put all memory onto the freelists */ |
64 | free_all_bootmem(); | 65 | memblock_free_all(); |
65 | 66 | ||
66 | mem_init_print_info(NULL); | 67 | mem_init_print_info(NULL); |
67 | } | 68 | } |
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index 0a0558567eaa..cb64f8dacd08 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig | |||
@@ -36,10 +36,8 @@ config CSKY | |||
36 | select HAVE_C_RECORDMCOUNT | 36 | select HAVE_C_RECORDMCOUNT |
37 | select HAVE_DMA_API_DEBUG | 37 | select HAVE_DMA_API_DEBUG |
38 | select HAVE_DMA_CONTIGUOUS | 38 | select HAVE_DMA_CONTIGUOUS |
39 | select HAVE_MEMBLOCK | ||
40 | select MAY_HAVE_SPARSE_IRQ | 39 | select MAY_HAVE_SPARSE_IRQ |
41 | select MODULES_USE_ELF_RELA if MODULES | 40 | select MODULES_USE_ELF_RELA if MODULES |
42 | select NO_BOOTMEM | ||
43 | select OF | 41 | select OF |
44 | select OF_EARLY_FLATTREE | 42 | select OF_EARLY_FLATTREE |
45 | select OF_RESERVED_MEM | 43 | select OF_RESERVED_MEM |
diff --git a/arch/csky/include/asm/processor.h b/arch/csky/include/asm/processor.h index 5ad4f0b83092..b1748659b2e9 100644 --- a/arch/csky/include/asm/processor.h +++ b/arch/csky/include/asm/processor.h | |||
@@ -4,12 +4,6 @@ | |||
4 | #ifndef __ASM_CSKY_PROCESSOR_H | 4 | #ifndef __ASM_CSKY_PROCESSOR_H |
5 | #define __ASM_CSKY_PROCESSOR_H | 5 | #define __ASM_CSKY_PROCESSOR_H |
6 | 6 | ||
7 | /* | ||
8 | * Default implementation of macro that returns current | ||
9 | * instruction pointer ("program counter"). | ||
10 | */ | ||
11 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
12 | |||
13 | #include <linux/bitops.h> | 7 | #include <linux/bitops.h> |
14 | #include <asm/segment.h> | 8 | #include <asm/segment.h> |
15 | #include <asm/ptrace.h> | 9 | #include <asm/ptrace.h> |
diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c index a5e3ab1d5360..dff8b89444ec 100644 --- a/arch/csky/kernel/setup.c +++ b/arch/csky/kernel/setup.c | |||
@@ -3,7 +3,6 @@ | |||
3 | 3 | ||
4 | #include <linux/console.h> | 4 | #include <linux/console.h> |
5 | #include <linux/memblock.h> | 5 | #include <linux/memblock.h> |
6 | #include <linux/bootmem.h> | ||
7 | #include <linux/initrd.h> | 6 | #include <linux/initrd.h> |
8 | #include <linux/of.h> | 7 | #include <linux/of.h> |
9 | #include <linux/of_fdt.h> | 8 | #include <linux/of_fdt.h> |
diff --git a/arch/csky/mm/highmem.c b/arch/csky/mm/highmem.c index e168ac087ccb..53b1bfa4c462 100644 --- a/arch/csky/mm/highmem.c +++ b/arch/csky/mm/highmem.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/highmem.h> | 5 | #include <linux/highmem.h> |
6 | #include <linux/smp.h> | 6 | #include <linux/smp.h> |
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | #include <asm/fixmap.h> | 8 | #include <asm/fixmap.h> |
9 | #include <asm/tlbflush.h> | 9 | #include <asm/tlbflush.h> |
10 | #include <asm/cacheflush.h> | 10 | #include <asm/cacheflush.h> |
@@ -140,7 +140,7 @@ static void __init fixrange_init(unsigned long start, unsigned long end, | |||
140 | pmd = (pmd_t *)pud; | 140 | pmd = (pmd_t *)pud; |
141 | for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, k++) { | 141 | for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, k++) { |
142 | if (pmd_none(*pmd)) { | 142 | if (pmd_none(*pmd)) { |
143 | pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); | 143 | pte = (pte_t *) memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); |
144 | set_pmd(pmd, __pmd(__pa(pte))); | 144 | set_pmd(pmd, __pmd(__pa(pte))); |
145 | BUG_ON(pte != pte_offset_kernel(pmd, 0)); | 145 | BUG_ON(pte != pte_offset_kernel(pmd, 0)); |
146 | } | 146 | } |
diff --git a/arch/csky/mm/init.c b/arch/csky/mm/init.c index ce2711e050ad..dc07c078f9b8 100644 --- a/arch/csky/mm/init.c +++ b/arch/csky/mm/init.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/ptrace.h> | 14 | #include <linux/ptrace.h> |
15 | #include <linux/mman.h> | 15 | #include <linux/mman.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/bootmem.h> | ||
18 | #include <linux/highmem.h> | 17 | #include <linux/highmem.h> |
19 | #include <linux/memblock.h> | 18 | #include <linux/memblock.h> |
20 | #include <linux/swap.h> | 19 | #include <linux/swap.h> |
@@ -47,7 +46,7 @@ void __init mem_init(void) | |||
47 | #endif | 46 | #endif |
48 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); | 47 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); |
49 | 48 | ||
50 | free_all_bootmem(); | 49 | memblock_free_all(); |
51 | 50 | ||
52 | #ifdef CONFIG_HIGHMEM | 51 | #ifdef CONFIG_HIGHMEM |
53 | for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) { | 52 | for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) { |
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 0b334b671e90..d19c6b16cd5d 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig | |||
@@ -15,8 +15,6 @@ config H8300 | |||
15 | select OF | 15 | select OF |
16 | select OF_IRQ | 16 | select OF_IRQ |
17 | select OF_EARLY_FLATTREE | 17 | select OF_EARLY_FLATTREE |
18 | select HAVE_MEMBLOCK | ||
19 | select NO_BOOTMEM | ||
20 | select TIMER_OF | 18 | select TIMER_OF |
21 | select H8300_TMR8 | 19 | select H8300_TMR8 |
22 | select HAVE_KERNEL_GZIP | 20 | select HAVE_KERNEL_GZIP |
diff --git a/arch/h8300/include/asm/processor.h b/arch/h8300/include/asm/processor.h index 985346393e4a..a060b41b2d31 100644 --- a/arch/h8300/include/asm/processor.h +++ b/arch/h8300/include/asm/processor.h | |||
@@ -12,12 +12,6 @@ | |||
12 | #ifndef __ASM_H8300_PROCESSOR_H | 12 | #ifndef __ASM_H8300_PROCESSOR_H |
13 | #define __ASM_H8300_PROCESSOR_H | 13 | #define __ASM_H8300_PROCESSOR_H |
14 | 14 | ||
15 | /* | ||
16 | * Default implementation of macro that returns current | ||
17 | * instruction pointer ("program counter"). | ||
18 | */ | ||
19 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
20 | |||
21 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
22 | #include <asm/segment.h> | 16 | #include <asm/segment.h> |
23 | #include <asm/ptrace.h> | 17 | #include <asm/ptrace.h> |
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c index 34e2df5c0d6d..b32bfa1fe99e 100644 --- a/arch/h8300/kernel/setup.c +++ b/arch/h8300/kernel/setup.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/console.h> | 18 | #include <linux/console.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/bootmem.h> | ||
22 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/of.h> | 23 | #include <linux/of.h> |
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c index 015287ac8ce8..6519252ac4db 100644 --- a/arch/h8300/mm/init.c +++ b/arch/h8300/mm/init.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/highmem.h> | 31 | #include <linux/highmem.h> |
32 | #include <linux/pagemap.h> | 32 | #include <linux/pagemap.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/memblock.h> |
34 | #include <linux/gfp.h> | 34 | #include <linux/gfp.h> |
35 | 35 | ||
36 | #include <asm/setup.h> | 36 | #include <asm/setup.h> |
@@ -67,7 +67,7 @@ void __init paging_init(void) | |||
67 | * Initialize the bad page table and bad page to point | 67 | * Initialize the bad page table and bad page to point |
68 | * to a couple of allocated pages. | 68 | * to a couple of allocated pages. |
69 | */ | 69 | */ |
70 | empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); | 70 | empty_zero_page = (unsigned long)memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
71 | memset((void *)empty_zero_page, 0, PAGE_SIZE); | 71 | memset((void *)empty_zero_page, 0, PAGE_SIZE); |
72 | 72 | ||
73 | /* | 73 | /* |
@@ -96,7 +96,7 @@ void __init mem_init(void) | |||
96 | max_mapnr = MAP_NR(high_memory); | 96 | max_mapnr = MAP_NR(high_memory); |
97 | 97 | ||
98 | /* this will put all low memory onto the freelists */ | 98 | /* this will put all low memory onto the freelists */ |
99 | free_all_bootmem(); | 99 | memblock_free_all(); |
100 | 100 | ||
101 | mem_init_print_info(NULL); | 101 | mem_init_print_info(NULL); |
102 | } | 102 | } |
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 7b25d7c8fa49..2b688af379e6 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig | |||
@@ -21,9 +21,7 @@ config HEXAGON | |||
21 | select GENERIC_IRQ_SHOW | 21 | select GENERIC_IRQ_SHOW |
22 | select HAVE_ARCH_KGDB | 22 | select HAVE_ARCH_KGDB |
23 | select HAVE_ARCH_TRACEHOOK | 23 | select HAVE_ARCH_TRACEHOOK |
24 | select HAVE_MEMBLOCK | ||
25 | select ARCH_DISCARD_MEMBLOCK | 24 | select ARCH_DISCARD_MEMBLOCK |
26 | select NO_BOOTMEM | ||
27 | select NEED_SG_DMA_LENGTH | 25 | select NEED_SG_DMA_LENGTH |
28 | select NO_IOPORT_MAP | 26 | select NO_IOPORT_MAP |
29 | select GENERIC_IOMAP | 27 | select GENERIC_IOMAP |
diff --git a/arch/hexagon/include/asm/processor.h b/arch/hexagon/include/asm/processor.h index ce67940860a5..227bcb9cfdac 100644 --- a/arch/hexagon/include/asm/processor.h +++ b/arch/hexagon/include/asm/processor.h | |||
@@ -27,9 +27,6 @@ | |||
27 | #include <asm/registers.h> | 27 | #include <asm/registers.h> |
28 | #include <asm/hexagon_vm.h> | 28 | #include <asm/hexagon_vm.h> |
29 | 29 | ||
30 | /* must be a macro */ | ||
31 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
32 | |||
33 | /* task_struct, defined elsewhere, is the "process descriptor" */ | 30 | /* task_struct, defined elsewhere, is the "process descriptor" */ |
34 | struct task_struct; | 31 | struct task_struct; |
35 | 32 | ||
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c index 706699374444..38eaa7b703e7 100644 --- a/arch/hexagon/kernel/dma.c +++ b/arch/hexagon/kernel/dma.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/dma-noncoherent.h> | 21 | #include <linux/dma-noncoherent.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/genalloc.h> | 23 | #include <linux/genalloc.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <asm/page.h> | 25 | #include <asm/page.h> |
diff --git a/arch/hexagon/kernel/setup.c b/arch/hexagon/kernel/setup.c index dc8c7e75b5d1..b3c3e04d4e57 100644 --- a/arch/hexagon/kernel/setup.c +++ b/arch/hexagon/kernel/setup.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/mmzone.h> | 24 | #include <linux/mmzone.h> |
25 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
26 | #include <linux/seq_file.h> | 26 | #include <linux/seq_file.h> |
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c index d789b9cc0189..1719ede9e9bd 100644 --- a/arch/hexagon/mm/init.c +++ b/arch/hexagon/mm/init.c | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
25 | #include <asm/atomic.h> | 24 | #include <asm/atomic.h> |
26 | #include <linux/highmem.h> | 25 | #include <linux/highmem.h> |
@@ -68,7 +67,7 @@ unsigned long long kmap_generation; | |||
68 | void __init mem_init(void) | 67 | void __init mem_init(void) |
69 | { | 68 | { |
70 | /* No idea where this is actually declared. Seems to evade LXR. */ | 69 | /* No idea where this is actually declared. Seems to evade LXR. */ |
71 | free_all_bootmem(); | 70 | memblock_free_all(); |
72 | mem_init_print_info(NULL); | 71 | mem_init_print_info(NULL); |
73 | 72 | ||
74 | /* | 73 | /* |
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 8b4a0c1748c0..36773def6920 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
@@ -26,9 +26,7 @@ config IA64 | |||
26 | select HAVE_FUNCTION_TRACER | 26 | select HAVE_FUNCTION_TRACER |
27 | select TTY | 27 | select TTY |
28 | select HAVE_ARCH_TRACEHOOK | 28 | select HAVE_ARCH_TRACEHOOK |
29 | select HAVE_MEMBLOCK | ||
30 | select HAVE_MEMBLOCK_NODE_MAP | 29 | select HAVE_MEMBLOCK_NODE_MAP |
31 | select NO_BOOTMEM | ||
32 | select HAVE_VIRT_CPU_ACCOUNTING | 30 | select HAVE_VIRT_CPU_ACCOUNTING |
33 | select ARCH_HAS_DMA_MARK_CLEAN | 31 | select ARCH_HAS_DMA_MARK_CLEAN |
34 | select ARCH_HAS_SG_CHAIN | 32 | select ARCH_HAS_SG_CHAIN |
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h index 10061ccf0440..c91ef98ed6bf 100644 --- a/arch/ia64/include/asm/processor.h +++ b/arch/ia64/include/asm/processor.h | |||
@@ -602,12 +602,6 @@ ia64_set_unat (__u64 *unat, void *spill_addr, unsigned long nat) | |||
602 | *unat = (*unat & ~mask) | (nat << bit); | 602 | *unat = (*unat & ~mask) | (nat << bit); |
603 | } | 603 | } |
604 | 604 | ||
605 | /* | ||
606 | * Get the current instruction/program counter value. | ||
607 | */ | ||
608 | #define current_text_addr() \ | ||
609 | ({ void *_pc; _pc = (void *)ia64_getreg(_IA64_REG_IP); _pc; }) | ||
610 | |||
611 | static inline __u64 | 605 | static inline __u64 |
612 | ia64_get_ivr (void) | 606 | ia64_get_ivr (void) |
613 | { | 607 | { |
diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c index 39f4433a6f0e..bec762a9b418 100644 --- a/arch/ia64/kernel/crash.c +++ b/arch/ia64/kernel/crash.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/smp.h> | 12 | #include <linux/smp.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/crash_dump.h> | 14 | #include <linux/crash_dump.h> |
15 | #include <linux/bootmem.h> | 15 | #include <linux/memblock.h> |
16 | #include <linux/kexec.h> | 16 | #include <linux/kexec.h> |
17 | #include <linux/elfcore.h> | 17 | #include <linux/elfcore.h> |
18 | #include <linux/sysctl.h> | 18 | #include <linux/sysctl.h> |
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index f77d80edddfe..8f106638913c 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c | |||
@@ -23,7 +23,7 @@ | |||
23 | * Skip non-WB memory and ignore empty memory ranges. | 23 | * Skip non-WB memory and ignore empty memory ranges. |
24 | */ | 24 | */ |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/crash_dump.h> | 27 | #include <linux/crash_dump.h> |
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c index 6b51c88e3578..b49fe6f618ed 100644 --- a/arch/ia64/kernel/ia64_ksyms.c +++ b/arch/ia64/kernel/ia64_ksyms.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #ifdef CONFIG_VIRTUAL_MEM_MAP | 6 | #ifdef CONFIG_VIRTUAL_MEM_MAP |
7 | #include <linux/compiler.h> | 7 | #include <linux/compiler.h> |
8 | #include <linux/export.h> | 8 | #include <linux/export.h> |
9 | #include <linux/bootmem.h> | 9 | #include <linux/memblock.h> |
10 | EXPORT_SYMBOL(min_low_pfn); /* defined by bootmem.c, but not exported by generic code */ | 10 | EXPORT_SYMBOL(min_low_pfn); /* defined by bootmem.c, but not exported by generic code */ |
11 | EXPORT_SYMBOL(max_low_pfn); /* defined by bootmem.c, but not exported by generic code */ | 11 | EXPORT_SYMBOL(max_low_pfn); /* defined by bootmem.c, but not exported by generic code */ |
12 | #endif | 12 | #endif |
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index 550243a94b5d..fe6e4946672e 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c | |||
@@ -90,7 +90,7 @@ | |||
90 | #include <linux/slab.h> | 90 | #include <linux/slab.h> |
91 | #include <linux/smp.h> | 91 | #include <linux/smp.h> |
92 | #include <linux/string.h> | 92 | #include <linux/string.h> |
93 | #include <linux/bootmem.h> | 93 | #include <linux/memblock.h> |
94 | 94 | ||
95 | #include <asm/delay.h> | 95 | #include <asm/delay.h> |
96 | #include <asm/hw_irq.h> | 96 | #include <asm/hw_irq.h> |
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c index 6115464d5f03..91bd1e129379 100644 --- a/arch/ia64/kernel/mca.c +++ b/arch/ia64/kernel/mca.c | |||
@@ -77,7 +77,7 @@ | |||
77 | #include <linux/sched/task.h> | 77 | #include <linux/sched/task.h> |
78 | #include <linux/interrupt.h> | 78 | #include <linux/interrupt.h> |
79 | #include <linux/irq.h> | 79 | #include <linux/irq.h> |
80 | #include <linux/bootmem.h> | 80 | #include <linux/memblock.h> |
81 | #include <linux/acpi.h> | 81 | #include <linux/acpi.h> |
82 | #include <linux/timer.h> | 82 | #include <linux/timer.h> |
83 | #include <linux/module.h> | 83 | #include <linux/module.h> |
@@ -361,9 +361,9 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES]; | |||
361 | 361 | ||
362 | #define IA64_LOG_ALLOCATE(it, size) \ | 362 | #define IA64_LOG_ALLOCATE(it, size) \ |
363 | {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \ | 363 | {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \ |
364 | (ia64_err_rec_t *)alloc_bootmem(size); \ | 364 | (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES); \ |
365 | ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \ | 365 | ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \ |
366 | (ia64_err_rec_t *)alloc_bootmem(size);} | 366 | (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES);} |
367 | #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock) | 367 | #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock) |
368 | #define IA64_LOG_LOCK(it) spin_lock_irqsave(&ia64_state_log[it].isl_lock, s) | 368 | #define IA64_LOG_LOCK(it) spin_lock_irqsave(&ia64_state_log[it].isl_lock, s) |
369 | #define IA64_LOG_UNLOCK(it) spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s) | 369 | #define IA64_LOG_UNLOCK(it) spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s) |
@@ -1835,8 +1835,8 @@ format_mca_init_stack(void *mca_data, unsigned long offset, | |||
1835 | /* Caller prevents this from being called after init */ | 1835 | /* Caller prevents this from being called after init */ |
1836 | static void * __ref mca_bootmem(void) | 1836 | static void * __ref mca_bootmem(void) |
1837 | { | 1837 | { |
1838 | return __alloc_bootmem(sizeof(struct ia64_mca_cpu), | 1838 | return memblock_alloc_from(sizeof(struct ia64_mca_cpu), |
1839 | KERNEL_STACK_SIZE, 0); | 1839 | KERNEL_STACK_SIZE, 0); |
1840 | } | 1840 | } |
1841 | 1841 | ||
1842 | /* Do per-CPU MCA-related initialization. */ | 1842 | /* Do per-CPU MCA-related initialization. */ |
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c index dfe40cbdf3b3..45f956ad715a 100644 --- a/arch/ia64/kernel/mca_drv.c +++ b/arch/ia64/kernel/mca_drv.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/kallsyms.h> | 16 | #include <linux/kallsyms.h> |
17 | #include <linux/bootmem.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/acpi.h> | 18 | #include <linux/acpi.h> |
19 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 0e6c2d9fb498..583a3746d70b 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | 28 | ||
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | #include <linux/bootmem.h> | ||
31 | #include <linux/console.h> | 30 | #include <linux/console.h> |
32 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
33 | #include <linux/cpu.h> | 32 | #include <linux/cpu.h> |
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c index 9a960829a01d..99099f73b207 100644 --- a/arch/ia64/kernel/signal.c +++ b/arch/ia64/kernel/signal.c | |||
@@ -344,10 +344,10 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall) | |||
344 | get_signal(&ksig); | 344 | get_signal(&ksig); |
345 | 345 | ||
346 | /* | 346 | /* |
347 | * get_signal_to_deliver() may have run a debugger (via notify_parent()) | 347 | * get_signal() may have run a debugger (via notify_parent()) |
348 | * and the debugger may have modified the state (e.g., to arrange for an | 348 | * and the debugger may have modified the state (e.g., to arrange for an |
349 | * inferior call), thus it's important to check for restarting _after_ | 349 | * inferior call), thus it's important to check for restarting _after_ |
350 | * get_signal_to_deliver(). | 350 | * get_signal(). |
351 | */ | 351 | */ |
352 | if ((long) scr->pt.r10 != -1) | 352 | if ((long) scr->pt.r10 != -1) |
353 | /* | 353 | /* |
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index 74fe317477e6..51ec944b036c 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
27 | #include <linux/bootmem.h> | 27 | #include <linux/memblock.h> |
28 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index 9b820f7a6a98..e311ee13e61d 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/node.h> | 19 | #include <linux/node.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/nodemask.h> | 23 | #include <linux/nodemask.h> |
24 | #include <linux/notifier.h> | 24 | #include <linux/notifier.h> |
25 | #include <linux/export.h> | 25 | #include <linux/export.h> |
diff --git a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c index e04efa088902..7601fe0622d2 100644 --- a/arch/ia64/kernel/unwind.c +++ b/arch/ia64/kernel/unwind.c | |||
@@ -28,7 +28,7 @@ | |||
28 | * acquired, then the read-write lock must be acquired first. | 28 | * acquired, then the read-write lock must be acquired first. |
29 | */ | 29 | */ |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/bootmem.h> | 31 | #include <linux/memblock.h> |
32 | #include <linux/elf.h> | 32 | #include <linux/elf.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c index e2e40bbd391c..6e447234205c 100644 --- a/arch/ia64/mm/contig.c +++ b/arch/ia64/mm/contig.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * Routines used by ia64 machines with contiguous (or virtually contiguous) | 14 | * Routines used by ia64 machines with contiguous (or virtually contiguous) |
15 | * memory. | 15 | * memory. |
16 | */ | 16 | */ |
17 | #include <linux/bootmem.h> | ||
18 | #include <linux/efi.h> | 17 | #include <linux/efi.h> |
19 | #include <linux/memblock.h> | 18 | #include <linux/memblock.h> |
20 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
@@ -85,8 +84,9 @@ skip: | |||
85 | static inline void | 84 | static inline void |
86 | alloc_per_cpu_data(void) | 85 | alloc_per_cpu_data(void) |
87 | { | 86 | { |
88 | cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * num_possible_cpus(), | 87 | cpu_data = memblock_alloc_from(PERCPU_PAGE_SIZE * num_possible_cpus(), |
89 | PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); | 88 | PERCPU_PAGE_SIZE, |
89 | __pa(MAX_DMA_ADDRESS)); | ||
90 | } | 90 | } |
91 | 91 | ||
92 | /** | 92 | /** |
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c index 1928d5719e41..8a965784340c 100644 --- a/arch/ia64/mm/discontig.c +++ b/arch/ia64/mm/discontig.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/nmi.h> | 20 | #include <linux/nmi.h> |
21 | #include <linux/swap.h> | 21 | #include <linux/swap.h> |
22 | #include <linux/bootmem.h> | ||
23 | #include <linux/memblock.h> | 22 | #include <linux/memblock.h> |
24 | #include <linux/acpi.h> | 23 | #include <linux/acpi.h> |
25 | #include <linux/efi.h> | 24 | #include <linux/efi.h> |
@@ -451,8 +450,10 @@ static void __init *memory_less_node_alloc(int nid, unsigned long pernodesize) | |||
451 | if (bestnode == -1) | 450 | if (bestnode == -1) |
452 | bestnode = anynode; | 451 | bestnode = anynode; |
453 | 452 | ||
454 | ptr = __alloc_bootmem_node(pgdat_list[bestnode], pernodesize, | 453 | ptr = memblock_alloc_try_nid(pernodesize, PERCPU_PAGE_SIZE, |
455 | PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); | 454 | __pa(MAX_DMA_ADDRESS), |
455 | MEMBLOCK_ALLOC_ACCESSIBLE, | ||
456 | bestnode); | ||
456 | 457 | ||
457 | return ptr; | 458 | return ptr; |
458 | } | 459 | } |
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 3b85c3ecac38..d5e12ff1d73c 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | 10 | ||
11 | #include <linux/bootmem.h> | ||
12 | #include <linux/efi.h> | 11 | #include <linux/efi.h> |
13 | #include <linux/elf.h> | 12 | #include <linux/elf.h> |
14 | #include <linux/memblock.h> | 13 | #include <linux/memblock.h> |
@@ -447,19 +446,19 @@ int __init create_mem_map_page_table(u64 start, u64 end, void *arg) | |||
447 | for (address = start_page; address < end_page; address += PAGE_SIZE) { | 446 | for (address = start_page; address < end_page; address += PAGE_SIZE) { |
448 | pgd = pgd_offset_k(address); | 447 | pgd = pgd_offset_k(address); |
449 | if (pgd_none(*pgd)) | 448 | if (pgd_none(*pgd)) |
450 | pgd_populate(&init_mm, pgd, alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE)); | 449 | pgd_populate(&init_mm, pgd, memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node)); |
451 | pud = pud_offset(pgd, address); | 450 | pud = pud_offset(pgd, address); |
452 | 451 | ||
453 | if (pud_none(*pud)) | 452 | if (pud_none(*pud)) |
454 | pud_populate(&init_mm, pud, alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE)); | 453 | pud_populate(&init_mm, pud, memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node)); |
455 | pmd = pmd_offset(pud, address); | 454 | pmd = pmd_offset(pud, address); |
456 | 455 | ||
457 | if (pmd_none(*pmd)) | 456 | if (pmd_none(*pmd)) |
458 | pmd_populate_kernel(&init_mm, pmd, alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE)); | 457 | pmd_populate_kernel(&init_mm, pmd, memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node)); |
459 | pte = pte_offset_kernel(pmd, address); | 458 | pte = pte_offset_kernel(pmd, address); |
460 | 459 | ||
461 | if (pte_none(*pte)) | 460 | if (pte_none(*pte)) |
462 | set_pte(pte, pfn_pte(__pa(alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE)) >> PAGE_SHIFT, | 461 | set_pte(pte, pfn_pte(__pa(memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node)) >> PAGE_SHIFT, |
463 | PAGE_KERNEL)); | 462 | PAGE_KERNEL)); |
464 | } | 463 | } |
465 | return 0; | 464 | return 0; |
@@ -627,7 +626,7 @@ mem_init (void) | |||
627 | 626 | ||
628 | set_max_mapnr(max_low_pfn); | 627 | set_max_mapnr(max_low_pfn); |
629 | high_memory = __va(max_low_pfn * PAGE_SIZE); | 628 | high_memory = __va(max_low_pfn * PAGE_SIZE); |
630 | free_all_bootmem(); | 629 | memblock_free_all(); |
631 | mem_init_print_info(NULL); | 630 | mem_init_print_info(NULL); |
632 | 631 | ||
633 | /* | 632 | /* |
diff --git a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c index aa19b7ac8222..3861d6e32d5f 100644 --- a/arch/ia64/mm/numa.c +++ b/arch/ia64/mm/numa.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/node.h> | 16 | #include <linux/node.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/bootmem.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <asm/mmzone.h> | 20 | #include <asm/mmzone.h> |
21 | #include <asm/numa.h> | 21 | #include <asm/numa.h> |
diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c index acf10eb9da15..9340bcb4f29c 100644 --- a/arch/ia64/mm/tlb.c +++ b/arch/ia64/mm/tlb.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/smp.h> | 22 | #include <linux/smp.h> |
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/bootmem.h> | 24 | #include <linux/memblock.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | 26 | ||
27 | #include <asm/delay.h> | 27 | #include <asm/delay.h> |
@@ -59,8 +59,10 @@ struct ia64_tr_entry *ia64_idtrs[NR_CPUS]; | |||
59 | void __init | 59 | void __init |
60 | mmu_context_init (void) | 60 | mmu_context_init (void) |
61 | { | 61 | { |
62 | ia64_ctx.bitmap = alloc_bootmem((ia64_ctx.max_ctx+1)>>3); | 62 | ia64_ctx.bitmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, |
63 | ia64_ctx.flushmap = alloc_bootmem((ia64_ctx.max_ctx+1)>>3); | 63 | SMP_CACHE_BYTES); |
64 | ia64_ctx.flushmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, | ||
65 | SMP_CACHE_BYTES); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | /* | 68 | /* |
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 5d71800df431..196a0dd7ff97 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/export.h> | 24 | #include <linux/export.h> |
25 | 25 | ||
26 | #include <asm/machvec.h> | 26 | #include <asm/machvec.h> |
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c index 9146192b86f5..9900e6d4add6 100644 --- a/arch/ia64/sn/kernel/bte.c +++ b/arch/ia64/sn/kernel/bte.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <asm/nodedata.h> | 16 | #include <asm/nodedata.h> |
17 | #include <asm/delay.h> | 17 | #include <asm/delay.h> |
18 | 18 | ||
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c index 102aabad6d20..8df13d0d96fa 100644 --- a/arch/ia64/sn/kernel/io_common.c +++ b/arch/ia64/sn/kernel/io_common.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (C) 2006 Silicon Graphics, Inc. All rights reserved. | 6 | * Copyright (C) 2006 Silicon Graphics, Inc. All rights reserved. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/bootmem.h> | 9 | #include <linux/memblock.h> |
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <asm/sn/types.h> | 12 | #include <asm/sn/types.h> |
@@ -385,16 +385,15 @@ void __init hubdev_init_node(nodepda_t * npda, cnodeid_t node) | |||
385 | { | 385 | { |
386 | struct hubdev_info *hubdev_info; | 386 | struct hubdev_info *hubdev_info; |
387 | int size; | 387 | int size; |
388 | pg_data_t *pg; | ||
389 | 388 | ||
390 | size = sizeof(struct hubdev_info); | 389 | size = sizeof(struct hubdev_info); |
391 | 390 | ||
392 | if (node >= num_online_nodes()) /* Headless/memless IO nodes */ | 391 | if (node >= num_online_nodes()) /* Headless/memless IO nodes */ |
393 | pg = NODE_DATA(0); | 392 | node = 0; |
394 | else | ||
395 | pg = NODE_DATA(node); | ||
396 | 393 | ||
397 | hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size); | 394 | hubdev_info = (struct hubdev_info *)memblock_alloc_node(size, |
395 | SMP_CACHE_BYTES, | ||
396 | node); | ||
398 | 397 | ||
399 | npda->pdinfo = (void *)hubdev_info; | 398 | npda->pdinfo = (void *)hubdev_info; |
400 | } | 399 | } |
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c index 5f6b6b48c1d5..a6d40a2c5bff 100644 --- a/arch/ia64/sn/kernel/setup.c +++ b/arch/ia64/sn/kernel/setup.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/mm.h> | 20 | #include <linux/mm.h> |
21 | #include <linux/serial.h> | 21 | #include <linux/serial.h> |
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/mmzone.h> | 24 | #include <linux/mmzone.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
@@ -511,7 +511,8 @@ static void __init sn_init_pdas(char **cmdline_p) | |||
511 | */ | 511 | */ |
512 | for_each_online_node(cnode) { | 512 | for_each_online_node(cnode) { |
513 | nodepdaindr[cnode] = | 513 | nodepdaindr[cnode] = |
514 | alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t)); | 514 | memblock_alloc_node(sizeof(nodepda_t), SMP_CACHE_BYTES, |
515 | cnode); | ||
515 | memset(nodepdaindr[cnode]->phys_cpuid, -1, | 516 | memset(nodepdaindr[cnode]->phys_cpuid, -1, |
516 | sizeof(nodepdaindr[cnode]->phys_cpuid)); | 517 | sizeof(nodepdaindr[cnode]->phys_cpuid)); |
517 | spin_lock_init(&nodepdaindr[cnode]->ptc_lock); | 518 | spin_lock_init(&nodepdaindr[cnode]->ptc_lock); |
@@ -522,7 +523,7 @@ static void __init sn_init_pdas(char **cmdline_p) | |||
522 | */ | 523 | */ |
523 | for (cnode = num_online_nodes(); cnode < num_cnodes; cnode++) | 524 | for (cnode = num_online_nodes(); cnode < num_cnodes; cnode++) |
524 | nodepdaindr[cnode] = | 525 | nodepdaindr[cnode] = |
525 | alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t)); | 526 | memblock_alloc_node(sizeof(nodepda_t), SMP_CACHE_BYTES, 0); |
526 | 527 | ||
527 | /* | 528 | /* |
528 | * Now copy the array of nodepda pointers to each nodepda. | 529 | * Now copy the array of nodepda pointers to each nodepda. |
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index c7b2a8d60a41..1bc9f1ba759a 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig | |||
@@ -27,9 +27,7 @@ config M68K | |||
27 | select OLD_SIGSUSPEND3 | 27 | select OLD_SIGSUSPEND3 |
28 | select OLD_SIGACTION | 28 | select OLD_SIGACTION |
29 | select DMA_DIRECT_OPS if HAS_DMA | 29 | select DMA_DIRECT_OPS if HAS_DMA |
30 | select HAVE_MEMBLOCK | ||
31 | select ARCH_DISCARD_MEMBLOCK | 30 | select ARCH_DISCARD_MEMBLOCK |
32 | select NO_BOOTMEM | ||
33 | 31 | ||
34 | config CPU_BIG_ENDIAN | 32 | config CPU_BIG_ENDIAN |
35 | def_bool y | 33 | def_bool y |
diff --git a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c index c83d66442612..6ffc204eb07d 100644 --- a/arch/m68k/atari/stram.c +++ b/arch/m68k/atari/stram.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/vmalloc.h> | 18 | #include <linux/vmalloc.h> |
19 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
@@ -95,7 +95,8 @@ void __init atari_stram_reserve_pages(void *start_mem) | |||
95 | { | 95 | { |
96 | if (kernel_in_stram) { | 96 | if (kernel_in_stram) { |
97 | pr_debug("atari_stram pool: kernel in ST-RAM, using alloc_bootmem!\n"); | 97 | pr_debug("atari_stram pool: kernel in ST-RAM, using alloc_bootmem!\n"); |
98 | stram_pool.start = (resource_size_t)alloc_bootmem_low_pages(pool_size); | 98 | stram_pool.start = (resource_size_t)memblock_alloc_low(pool_size, |
99 | PAGE_SIZE); | ||
99 | stram_pool.end = stram_pool.start + pool_size - 1; | 100 | stram_pool.end = stram_pool.start + pool_size - 1; |
100 | request_resource(&iomem_resource, &stram_pool); | 101 | request_resource(&iomem_resource, &stram_pool); |
101 | stram_virt_offset = 0; | 102 | stram_virt_offset = 0; |
diff --git a/arch/m68k/coldfire/m54xx.c b/arch/m68k/coldfire/m54xx.c index adad03ca6e11..360c723c0ae6 100644 --- a/arch/m68k/coldfire/m54xx.c +++ b/arch/m68k/coldfire/m54xx.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <asm/pgalloc.h> | 20 | #include <asm/pgalloc.h> |
21 | #include <asm/machdep.h> | 21 | #include <asm/machdep.h> |
22 | #include <asm/coldfire.h> | 22 | #include <asm/coldfire.h> |
diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h index 464e9f5f50ee..3750819ac5a1 100644 --- a/arch/m68k/include/asm/processor.h +++ b/arch/m68k/include/asm/processor.h | |||
@@ -8,12 +8,6 @@ | |||
8 | #ifndef __ASM_M68K_PROCESSOR_H | 8 | #ifndef __ASM_M68K_PROCESSOR_H |
9 | #define __ASM_M68K_PROCESSOR_H | 9 | #define __ASM_M68K_PROCESSOR_H |
10 | 10 | ||
11 | /* | ||
12 | * Default implementation of macro that returns current | ||
13 | * instruction pointer ("program counter"). | ||
14 | */ | ||
15 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
16 | |||
17 | #include <linux/thread_info.h> | 11 | #include <linux/thread_info.h> |
18 | #include <asm/segment.h> | 12 | #include <asm/segment.h> |
19 | #include <asm/fpu.h> | 13 | #include <asm/fpu.h> |
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c index 5d3596c180f9..a1a3eaeaf58c 100644 --- a/arch/m68k/kernel/setup_mm.c +++ b/arch/m68k/kernel/setup_mm.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
25 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
26 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c index cfd5475bfc31..3c5def10d486 100644 --- a/arch/m68k/kernel/setup_no.c +++ b/arch/m68k/kernel/setup_no.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/console.h> | 27 | #include <linux/console.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/string.h> | 29 | #include <linux/string.h> |
30 | #include <linux/bootmem.h> | ||
31 | #include <linux/memblock.h> | 30 | #include <linux/memblock.h> |
32 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
diff --git a/arch/m68k/kernel/uboot.c b/arch/m68k/kernel/uboot.c index 107082877064..1b4c562753da 100644 --- a/arch/m68k/kernel/uboot.c +++ b/arch/m68k/kernel/uboot.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/console.h> | 16 | #include <linux/console.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/seq_file.h> | 20 | #include <linux/seq_file.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/initrd.h> | 22 | #include <linux/initrd.h> |
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index 38e2b272c220..933c33e76a48 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
22 | 22 | ||
23 | #include <asm/setup.h> | 23 | #include <asm/setup.h> |
@@ -93,7 +93,7 @@ void __init paging_init(void) | |||
93 | 93 | ||
94 | high_memory = (void *) end_mem; | 94 | high_memory = (void *) end_mem; |
95 | 95 | ||
96 | empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); | 96 | empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
97 | 97 | ||
98 | /* | 98 | /* |
99 | * Set up SFC/DFC registers (user data space). | 99 | * Set up SFC/DFC registers (user data space). |
@@ -140,7 +140,7 @@ static inline void init_pointer_tables(void) | |||
140 | void __init mem_init(void) | 140 | void __init mem_init(void) |
141 | { | 141 | { |
142 | /* this will put all memory onto the freelists */ | 142 | /* this will put all memory onto the freelists */ |
143 | free_all_bootmem(); | 143 | memblock_free_all(); |
144 | init_pointer_tables(); | 144 | init_pointer_tables(); |
145 | mem_init_print_info(NULL); | 145 | mem_init_print_info(NULL); |
146 | } | 146 | } |
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c index f5453d944ff5..0de4999a3810 100644 --- a/arch/m68k/mm/mcfmmu.c +++ b/arch/m68k/mm/mcfmmu.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/string.h> | 15 | #include <linux/string.h> |
16 | #include <linux/bootmem.h> | ||
17 | #include <linux/memblock.h> | 16 | #include <linux/memblock.h> |
18 | 17 | ||
19 | #include <asm/setup.h> | 18 | #include <asm/setup.h> |
@@ -44,7 +43,7 @@ void __init paging_init(void) | |||
44 | enum zone_type zone; | 43 | enum zone_type zone; |
45 | int i; | 44 | int i; |
46 | 45 | ||
47 | empty_zero_page = (void *) alloc_bootmem_pages(PAGE_SIZE); | 46 | empty_zero_page = (void *) memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
48 | memset((void *) empty_zero_page, 0, PAGE_SIZE); | 47 | memset((void *) empty_zero_page, 0, PAGE_SIZE); |
49 | 48 | ||
50 | pg_dir = swapper_pg_dir; | 49 | pg_dir = swapper_pg_dir; |
@@ -52,7 +51,7 @@ void __init paging_init(void) | |||
52 | 51 | ||
53 | size = num_pages * sizeof(pte_t); | 52 | size = num_pages * sizeof(pte_t); |
54 | size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1); | 53 | size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1); |
55 | next_pgtable = (unsigned long) alloc_bootmem_pages(size); | 54 | next_pgtable = (unsigned long) memblock_alloc(size, PAGE_SIZE); |
56 | 55 | ||
57 | bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK; | 56 | bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK; |
58 | pg_dir += PAGE_OFFSET >> PGDIR_SHIFT; | 57 | pg_dir += PAGE_OFFSET >> PGDIR_SHIFT; |
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index 4e17ecb5928a..7497cf30bf1c 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/bootmem.h> | ||
22 | #include <linux/memblock.h> | 21 | #include <linux/memblock.h> |
23 | #include <linux/gfp.h> | 22 | #include <linux/gfp.h> |
24 | 23 | ||
@@ -55,7 +54,7 @@ static pte_t * __init kernel_page_table(void) | |||
55 | { | 54 | { |
56 | pte_t *ptablep; | 55 | pte_t *ptablep; |
57 | 56 | ||
58 | ptablep = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE); | 57 | ptablep = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); |
59 | 58 | ||
60 | clear_page(ptablep); | 59 | clear_page(ptablep); |
61 | __flush_page_to_ram(ptablep); | 60 | __flush_page_to_ram(ptablep); |
@@ -95,7 +94,8 @@ static pmd_t * __init kernel_ptr_table(void) | |||
95 | 94 | ||
96 | last_pgtable += PTRS_PER_PMD; | 95 | last_pgtable += PTRS_PER_PMD; |
97 | if (((unsigned long)last_pgtable & ~PAGE_MASK) == 0) { | 96 | if (((unsigned long)last_pgtable & ~PAGE_MASK) == 0) { |
98 | last_pgtable = (pmd_t *)alloc_bootmem_low_pages(PAGE_SIZE); | 97 | last_pgtable = (pmd_t *)memblock_alloc_low(PAGE_SIZE, |
98 | PAGE_SIZE); | ||
99 | 99 | ||
100 | clear_page(last_pgtable); | 100 | clear_page(last_pgtable); |
101 | __flush_page_to_ram(last_pgtable); | 101 | __flush_page_to_ram(last_pgtable); |
@@ -275,7 +275,7 @@ void __init paging_init(void) | |||
275 | * initialize the bad page table and bad page to point | 275 | * initialize the bad page table and bad page to point |
276 | * to a couple of allocated pages | 276 | * to a couple of allocated pages |
277 | */ | 277 | */ |
278 | empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); | 278 | empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
279 | 279 | ||
280 | /* | 280 | /* |
281 | * Set up SFC/DFC registers | 281 | * Set up SFC/DFC registers |
diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c index 4a9979908357..f736db48a2e1 100644 --- a/arch/m68k/mm/sun3mmu.c +++ b/arch/m68k/mm/sun3mmu.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | 20 | ||
21 | #include <asm/setup.h> | 21 | #include <asm/setup.h> |
22 | #include <linux/uaccess.h> | 22 | #include <linux/uaccess.h> |
@@ -45,7 +45,7 @@ void __init paging_init(void) | |||
45 | unsigned long zones_size[MAX_NR_ZONES] = { 0, }; | 45 | unsigned long zones_size[MAX_NR_ZONES] = { 0, }; |
46 | unsigned long size; | 46 | unsigned long size; |
47 | 47 | ||
48 | empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); | 48 | empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
49 | 49 | ||
50 | address = PAGE_OFFSET; | 50 | address = PAGE_OFFSET; |
51 | pg_dir = swapper_pg_dir; | 51 | pg_dir = swapper_pg_dir; |
@@ -55,7 +55,7 @@ void __init paging_init(void) | |||
55 | size = num_pages * sizeof(pte_t); | 55 | size = num_pages * sizeof(pte_t); |
56 | size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1); | 56 | size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1); |
57 | 57 | ||
58 | next_pgtable = (unsigned long)alloc_bootmem_pages(size); | 58 | next_pgtable = (unsigned long)memblock_alloc(size, PAGE_SIZE); |
59 | bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK; | 59 | bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK; |
60 | 60 | ||
61 | /* Map whole memory from PAGE_OFFSET (0x0E000000) */ | 61 | /* Map whole memory from PAGE_OFFSET (0x0E000000) */ |
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c index 79a2bb857906..542c4404861c 100644 --- a/arch/m68k/sun3/config.c +++ b/arch/m68k/sun3/config.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/tty.h> | 15 | #include <linux/tty.h> |
16 | #include <linux/console.h> | 16 | #include <linux/console.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/bootmem.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | 20 | ||
21 | #include <asm/oplib.h> | 21 | #include <asm/oplib.h> |
diff --git a/arch/m68k/sun3/dvma.c b/arch/m68k/sun3/dvma.c index 5f92c72b05c3..a2c1c9304895 100644 --- a/arch/m68k/sun3/dvma.c +++ b/arch/m68k/sun3/dvma.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/list.h> | 15 | #include <linux/list.h> |
16 | #include <asm/page.h> | 16 | #include <asm/page.h> |
17 | #include <asm/pgtable.h> | 17 | #include <asm/pgtable.h> |
diff --git a/arch/m68k/sun3/mmu_emu.c b/arch/m68k/sun3/mmu_emu.c index d30da12a1702..582a1284059a 100644 --- a/arch/m68k/sun3/mmu_emu.c +++ b/arch/m68k/sun3/mmu_emu.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/ptrace.h> | 14 | #include <linux/ptrace.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/sched/mm.h> | 19 | #include <linux/sched/mm.h> |
diff --git a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c index 8546922adb47..4d64711d3d47 100644 --- a/arch/m68k/sun3/sun3dvma.c +++ b/arch/m68k/sun3/sun3dvma.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Contains common routines for sun3/sun3x DVMA management. | 7 | * Contains common routines for sun3/sun3x DVMA management. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
@@ -267,7 +267,8 @@ void __init dvma_init(void) | |||
267 | 267 | ||
268 | list_add(&(hole->list), &hole_list); | 268 | list_add(&(hole->list), &hole_list); |
269 | 269 | ||
270 | iommu_use = alloc_bootmem(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long)); | 270 | iommu_use = memblock_alloc(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long), |
271 | SMP_CACHE_BYTES); | ||
271 | 272 | ||
272 | dvma_unmap_iommu(DVMA_START, DVMA_SIZE); | 273 | dvma_unmap_iommu(DVMA_START, DVMA_SIZE); |
273 | 274 | ||
diff --git a/arch/m68k/sun3x/dvma.c b/arch/m68k/sun3x/dvma.c index b2acbc862f60..89e630e66555 100644 --- a/arch/m68k/sun3x/dvma.c +++ b/arch/m68k/sun3x/dvma.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/bitops.h> | 16 | #include <linux/bitops.h> |
17 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
18 | #include <linux/bootmem.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/vmalloc.h> | 19 | #include <linux/vmalloc.h> |
20 | 20 | ||
21 | #include <asm/sun3x.h> | 21 | #include <asm/sun3x.h> |
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 164a4857737a..effed2efd306 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
@@ -28,8 +28,6 @@ config MICROBLAZE | |||
28 | select HAVE_FTRACE_MCOUNT_RECORD | 28 | select HAVE_FTRACE_MCOUNT_RECORD |
29 | select HAVE_FUNCTION_GRAPH_TRACER | 29 | select HAVE_FUNCTION_GRAPH_TRACER |
30 | select HAVE_FUNCTION_TRACER | 30 | select HAVE_FUNCTION_TRACER |
31 | select NO_BOOTMEM | ||
32 | select HAVE_MEMBLOCK | ||
33 | select HAVE_MEMBLOCK_NODE_MAP | 31 | select HAVE_MEMBLOCK_NODE_MAP |
34 | select HAVE_OPROFILE | 32 | select HAVE_OPROFILE |
35 | select IRQ_DOMAIN | 33 | select IRQ_DOMAIN |
diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h index 330d556860ba..66b537b8d138 100644 --- a/arch/microblaze/include/asm/processor.h +++ b/arch/microblaze/include/asm/processor.h | |||
@@ -46,12 +46,6 @@ extern void ret_from_kernel_thread(void); | |||
46 | # define TASK_SIZE (0x81000000 - 0x80000000) | 46 | # define TASK_SIZE (0x81000000 - 0x80000000) |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Default implementation of macro that returns current | ||
50 | * instruction pointer ("program counter"). | ||
51 | */ | ||
52 | # define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
53 | |||
54 | /* | ||
55 | * This decides where the kernel will search for a free chunk of vm | 49 | * This decides where the kernel will search for a free chunk of vm |
56 | * space during mmap's. We won't be using it | 50 | * space during mmap's. We won't be using it |
57 | */ | 51 | */ |
@@ -92,12 +86,6 @@ extern unsigned long get_wchan(struct task_struct *p); | |||
92 | 86 | ||
93 | # ifndef __ASSEMBLY__ | 87 | # ifndef __ASSEMBLY__ |
94 | 88 | ||
95 | /* | ||
96 | * Default implementation of macro that returns current | ||
97 | * instruction pointer ("program counter"). | ||
98 | */ | ||
99 | # define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
100 | |||
101 | /* If you change this, you must change the associated assembly-languages | 89 | /* If you change this, you must change the associated assembly-languages |
102 | * constants defined below, THREAD_*. | 90 | * constants defined below, THREAD_*. |
103 | */ | 91 | */ |
diff --git a/arch/microblaze/mm/consistent.c b/arch/microblaze/mm/consistent.c index d801cc5f5b95..45e0a1aa9357 100644 --- a/arch/microblaze/mm/consistent.c +++ b/arch/microblaze/mm/consistent.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/bootmem.h> | 31 | #include <linux/memblock.h> |
32 | #include <linux/highmem.h> | 32 | #include <linux/highmem.h> |
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index df6de7ccdc2e..b17fd8aafd64 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c | |||
@@ -7,10 +7,9 @@ | |||
7 | * for more details. | 7 | * for more details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/memblock.h> | ||
14 | #include <linux/mm.h> /* mem_init */ | 13 | #include <linux/mm.h> /* mem_init */ |
15 | #include <linux/initrd.h> | 14 | #include <linux/initrd.h> |
16 | #include <linux/pagemap.h> | 15 | #include <linux/pagemap.h> |
@@ -204,7 +203,7 @@ void __init mem_init(void) | |||
204 | high_memory = (void *)__va(memory_start + lowmem_size - 1); | 203 | high_memory = (void *)__va(memory_start + lowmem_size - 1); |
205 | 204 | ||
206 | /* this will put all memory onto the freelists */ | 205 | /* this will put all memory onto the freelists */ |
207 | free_all_bootmem(); | 206 | memblock_free_all(); |
208 | #ifdef CONFIG_HIGHMEM | 207 | #ifdef CONFIG_HIGHMEM |
209 | highmem_setup(); | 208 | highmem_setup(); |
210 | #endif | 209 | #endif |
@@ -377,7 +376,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) | |||
377 | if (mem_init_done) | 376 | if (mem_init_done) |
378 | p = kzalloc(size, mask); | 377 | p = kzalloc(size, mask); |
379 | else { | 378 | else { |
380 | p = alloc_bootmem(size); | 379 | p = memblock_alloc(size, SMP_CACHE_BYTES); |
381 | if (p) | 380 | if (p) |
382 | memset(p, 0, size); | 381 | memset(p, 0, size); |
383 | } | 382 | } |
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 2ffd171af8b6..6b89a66ec1a5 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <linux/shmem_fs.h> | 25 | #include <linux/shmem_fs.h> |
26 | #include <linux/list.h> | 26 | #include <linux/list.h> |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 80778b40f8fa..8272ea4c7264 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -60,7 +60,6 @@ config MIPS | |||
60 | select HAVE_IRQ_TIME_ACCOUNTING | 60 | select HAVE_IRQ_TIME_ACCOUNTING |
61 | select HAVE_KPROBES | 61 | select HAVE_KPROBES |
62 | select HAVE_KRETPROBES | 62 | select HAVE_KRETPROBES |
63 | select HAVE_MEMBLOCK | ||
64 | select HAVE_MEMBLOCK_NODE_MAP | 63 | select HAVE_MEMBLOCK_NODE_MAP |
65 | select HAVE_MOD_ARCH_SPECIFIC | 64 | select HAVE_MOD_ARCH_SPECIFIC |
66 | select HAVE_NMI | 65 | select HAVE_NMI |
@@ -78,7 +77,6 @@ config MIPS | |||
78 | select RTC_LIB | 77 | select RTC_LIB |
79 | select SYSCTL_EXCEPTION_TRACE | 78 | select SYSCTL_EXCEPTION_TRACE |
80 | select VIRT_TO_BUS | 79 | select VIRT_TO_BUS |
81 | select NO_BOOTMEM | ||
82 | 80 | ||
83 | menu "Machine selection" | 81 | menu "Machine selection" |
84 | 82 | ||
diff --git a/arch/mips/ar7/memory.c b/arch/mips/ar7/memory.c index 0332f0514d05..80390a9ec264 100644 --- a/arch/mips/ar7/memory.c +++ b/arch/mips/ar7/memory.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | */ | 18 | */ |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/pfn.h> | 22 | #include <linux/pfn.h> |
diff --git a/arch/mips/ath79/setup.c b/arch/mips/ath79/setup.c index 4c7a93f4039a..9728abcb18fa 100644 --- a/arch/mips/ath79/setup.c +++ b/arch/mips/ath79/setup.c | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/bootmem.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
20 | #include <linux/clk-provider.h> | 20 | #include <linux/clk-provider.h> |
diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c index 7019e2967009..77a836e661c9 100644 --- a/arch/mips/bcm63xx/prom.c +++ b/arch/mips/bcm63xx/prom.c | |||
@@ -7,7 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/smp.h> | 11 | #include <linux/smp.h> |
12 | #include <asm/bootinfo.h> | 12 | #include <asm/bootinfo.h> |
13 | #include <asm/bmips.h> | 13 | #include <asm/bmips.h> |
diff --git a/arch/mips/bcm63xx/setup.c b/arch/mips/bcm63xx/setup.c index 2be9caaa2085..e28ee9a7cc7e 100644 --- a/arch/mips/bcm63xx/setup.c +++ b/arch/mips/bcm63xx/setup.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
12 | #include <linux/bootmem.h> | 12 | #include <linux/memblock.h> |
13 | #include <linux/ioport.h> | 13 | #include <linux/ioport.h> |
14 | #include <linux/pm.h> | 14 | #include <linux/pm.h> |
15 | #include <asm/bootinfo.h> | 15 | #include <asm/bootinfo.h> |
diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c index 6329c5f780d6..1738a06396f9 100644 --- a/arch/mips/bmips/setup.c +++ b/arch/mips/bmips/setup.c | |||
@@ -9,7 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/bitops.h> | 11 | #include <linux/bitops.h> |
12 | #include <linux/bootmem.h> | 12 | #include <linux/memblock.h> |
13 | #include <linux/clk-provider.h> | 13 | #include <linux/clk-provider.h> |
14 | #include <linux/ioport.h> | 14 | #include <linux/ioport.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c index 236833be6fbe..e8eb60ed99f2 100644 --- a/arch/mips/cavium-octeon/dma-octeon.c +++ b/arch/mips/cavium-octeon/dma-octeon.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * Copyright (C) 2010 Cavium Networks, Inc. | 11 | * Copyright (C) 2010 Cavium Networks, Inc. |
12 | */ | 12 | */ |
13 | #include <linux/dma-direct.h> | 13 | #include <linux/dma-direct.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/swiotlb.h> | 15 | #include <linux/swiotlb.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
@@ -244,7 +244,7 @@ void __init plat_swiotlb_setup(void) | |||
244 | swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE); | 244 | swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE); |
245 | swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT; | 245 | swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT; |
246 | 246 | ||
247 | octeon_swiotlb = alloc_bootmem_low_pages(swiotlbsize); | 247 | octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE); |
248 | 248 | ||
249 | if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM) | 249 | if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM) |
250 | panic("Cannot allocate SWIOTLB buffer"); | 250 | panic("Cannot allocate SWIOTLB buffer"); |
diff --git a/arch/mips/dec/prom/memory.c b/arch/mips/dec/prom/memory.c index a2acc6454cf3..5073d2ed78bb 100644 --- a/arch/mips/dec/prom/memory.c +++ b/arch/mips/dec/prom/memory.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | 13 | ||
14 | #include <asm/addrspace.h> | 14 | #include <asm/addrspace.h> |
diff --git a/arch/mips/emma/common/prom.c b/arch/mips/emma/common/prom.c index cae42259d6da..675337b8a4a0 100644 --- a/arch/mips/emma/common/prom.c +++ b/arch/mips/emma/common/prom.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
25 | #include <linux/bootmem.h> | 25 | #include <linux/memblock.h> |
26 | 26 | ||
27 | #include <asm/addrspace.h> | 27 | #include <asm/addrspace.h> |
28 | #include <asm/bootinfo.h> | 28 | #include <asm/bootinfo.h> |
diff --git a/arch/mips/fw/arc/memory.c b/arch/mips/fw/arc/memory.c index dd9496f26e6a..429b7f8d2aeb 100644 --- a/arch/mips/fw/arc/memory.c +++ b/arch/mips/fw/arc/memory.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/swap.h> | 21 | #include <linux/swap.h> |
22 | 22 | ||
23 | #include <asm/sgialib.h> | 23 | #include <asm/sgialib.h> |
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index c373eb605040..ce3ed4d17813 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h | |||
@@ -24,11 +24,6 @@ | |||
24 | #include <asm/prefetch.h> | 24 | #include <asm/prefetch.h> |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * Return current * instruction pointer ("program counter"). | ||
28 | */ | ||
29 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
30 | |||
31 | /* | ||
32 | * System setup and hardware flags.. | 27 | * System setup and hardware flags.. |
33 | */ | 28 | */ |
34 | 29 | ||
diff --git a/arch/mips/jazz/jazzdma.c b/arch/mips/jazz/jazzdma.c index 0a0aaf39fd16..4c41ed0a637e 100644 --- a/arch/mips/jazz/jazzdma.c +++ b/arch/mips/jazz/jazzdma.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/export.h> | 13 | #include <linux/export.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/spinlock.h> | 17 | #include <linux/spinlock.h> |
18 | #include <linux/gfp.h> | 18 | #include <linux/gfp.h> |
19 | #include <linux/dma-direct.h> | 19 | #include <linux/dma-direct.h> |
diff --git a/arch/mips/kernel/crash.c b/arch/mips/kernel/crash.c index 2c7288041a99..81845ba04835 100644 --- a/arch/mips/kernel/crash.c +++ b/arch/mips/kernel/crash.c | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <linux/smp.h> | 3 | #include <linux/smp.h> |
4 | #include <linux/reboot.h> | 4 | #include <linux/reboot.h> |
5 | #include <linux/kexec.h> | 5 | #include <linux/kexec.h> |
6 | #include <linux/bootmem.h> | 6 | #include <linux/memblock.h> |
7 | #include <linux/crash_dump.h> | 7 | #include <linux/crash_dump.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/irq.h> | 9 | #include <linux/irq.h> |
diff --git a/arch/mips/kernel/crash_dump.c b/arch/mips/kernel/crash_dump.c index a8657d29c62e..01b2bd95ba1f 100644 --- a/arch/mips/kernel/crash_dump.c +++ b/arch/mips/kernel/crash_dump.c | |||
@@ -1,6 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | #include <linux/highmem.h> | 2 | #include <linux/highmem.h> |
3 | #include <linux/bootmem.h> | 3 | #include <linux/memblock.h> |
4 | #include <linux/crash_dump.h> | 4 | #include <linux/crash_dump.h> |
5 | #include <linux/uaccess.h> | 5 | #include <linux/uaccess.h> |
6 | #include <linux/slab.h> | 6 | #include <linux/slab.h> |
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 89950b7bf536..93b8e0b4332f 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/export.h> | 12 | #include <linux/export.h> |
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/bootmem.h> | 15 | #include <linux/memblock.h> |
16 | #include <linux/debugfs.h> | 16 | #include <linux/debugfs.h> |
17 | #include <linux/of.h> | 17 | #include <linux/of.h> |
18 | #include <linux/of_fdt.h> | 18 | #include <linux/of_fdt.h> |
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 01a5ff4c41ff..ea09ed6a80a9 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/export.h> | 15 | #include <linux/export.h> |
16 | #include <linux/screen_info.h> | 16 | #include <linux/screen_info.h> |
17 | #include <linux/memblock.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/bootmem.h> | ||
19 | #include <linux/initrd.h> | 18 | #include <linux/initrd.h> |
20 | #include <linux/root_dev.h> | 19 | #include <linux/root_dev.h> |
21 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
@@ -561,7 +560,7 @@ static void __init bootmem_init(void) | |||
561 | extern void show_kernel_relocation(const char *level); | 560 | extern void show_kernel_relocation(const char *level); |
562 | 561 | ||
563 | offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS); | 562 | offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS); |
564 | free_bootmem(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset); | 563 | memblock_free(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset); |
565 | 564 | ||
566 | #if defined(CONFIG_DEBUG_KERNEL) && defined(CONFIG_DEBUG_INFO) | 565 | #if defined(CONFIG_DEBUG_KERNEL) && defined(CONFIG_DEBUG_INFO) |
567 | /* | 566 | /* |
@@ -859,7 +858,7 @@ static void __init arch_mem_init(char **cmdline_p) | |||
859 | * Prevent memblock from allocating high memory. | 858 | * Prevent memblock from allocating high memory. |
860 | * This cannot be done before max_low_pfn is detected, so up | 859 | * This cannot be done before max_low_pfn is detected, so up |
861 | * to this point is possible to only reserve physical memory | 860 | * to this point is possible to only reserve physical memory |
862 | * with memblock_reserve; memblock_virt_alloc* can be used | 861 | * with memblock_reserve; memblock_alloc* can be used |
863 | * only after this point | 862 | * only after this point |
864 | */ | 863 | */ |
865 | memblock_set_current_limit(PFN_PHYS(max_low_pfn)); | 864 | memblock_set_current_limit(PFN_PHYS(max_low_pfn)); |
@@ -917,7 +916,7 @@ static void __init resource_init(void) | |||
917 | if (end >= HIGHMEM_START) | 916 | if (end >= HIGHMEM_START) |
918 | end = HIGHMEM_START - 1; | 917 | end = HIGHMEM_START - 1; |
919 | 918 | ||
920 | res = alloc_bootmem(sizeof(struct resource)); | 919 | res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES); |
921 | 920 | ||
922 | res->start = start; | 921 | res->start = start; |
923 | res->end = end; | 922 | res->end = end; |
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 5feef28deac8..0f852e1b5891 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/smp.h> | 28 | #include <linux/smp.h> |
29 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include <linux/kallsyms.h> | 30 | #include <linux/kallsyms.h> |
31 | #include <linux/bootmem.h> | ||
32 | #include <linux/memblock.h> | 31 | #include <linux/memblock.h> |
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
34 | #include <linux/ptrace.h> | 33 | #include <linux/ptrace.h> |
@@ -2263,7 +2262,7 @@ void __init trap_init(void) | |||
2263 | 2262 | ||
2264 | memblock_set_bottom_up(true); | 2263 | memblock_set_bottom_up(true); |
2265 | ebase = (unsigned long) | 2264 | ebase = (unsigned long) |
2266 | __alloc_bootmem(size, 1 << fls(size), 0); | 2265 | memblock_alloc_from(size, 1 << fls(size), 0); |
2267 | memblock_set_bottom_up(false); | 2266 | memblock_set_bottom_up(false); |
2268 | 2267 | ||
2269 | /* | 2268 | /* |
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index 0bef238d2c0c..6176b9acba95 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/moduleloader.h> | 26 | #include <linux/moduleloader.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/poll.h> | 28 | #include <linux/poll.h> |
29 | #include <linux/bootmem.h> | 29 | #include <linux/memblock.h> |
30 | #include <asm/mipsregs.h> | 30 | #include <asm/mipsregs.h> |
31 | #include <asm/mipsmtregs.h> | 31 | #include <asm/mipsmtregs.h> |
32 | #include <asm/cacheflush.h> | 32 | #include <asm/cacheflush.h> |
diff --git a/arch/mips/kvm/commpage.c b/arch/mips/kvm/commpage.c index f43629979a0e..5812e6145801 100644 --- a/arch/mips/kvm/commpage.c +++ b/arch/mips/kvm/commpage.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/err.h> | 14 | #include <linux/err.h> |
15 | #include <linux/vmalloc.h> | 15 | #include <linux/vmalloc.h> |
16 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
17 | #include <linux/bootmem.h> | 17 | #include <linux/memblock.h> |
18 | #include <asm/page.h> | 18 | #include <asm/page.h> |
19 | #include <asm/cacheflush.h> | 19 | #include <asm/cacheflush.h> |
20 | #include <asm/mmu_context.h> | 20 | #include <asm/mmu_context.h> |
diff --git a/arch/mips/kvm/dyntrans.c b/arch/mips/kvm/dyntrans.c index f8e772564d74..d77b61b3d6ee 100644 --- a/arch/mips/kvm/dyntrans.c +++ b/arch/mips/kvm/dyntrans.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/uaccess.h> | 16 | #include <linux/uaccess.h> |
17 | #include <linux/vmalloc.h> | 17 | #include <linux/vmalloc.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <asm/cacheflush.h> | 20 | #include <asm/cacheflush.h> |
21 | 21 | ||
22 | #include "commpage.h" | 22 | #include "commpage.h" |
diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c index 4144bfaef137..ec9ed23bca7f 100644 --- a/arch/mips/kvm/emulate.c +++ b/arch/mips/kvm/emulate.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/kvm_host.h> | 15 | #include <linux/kvm_host.h> |
16 | #include <linux/vmalloc.h> | 16 | #include <linux/vmalloc.h> |
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/bootmem.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/random.h> | 19 | #include <linux/random.h> |
20 | #include <asm/page.h> | 20 | #include <asm/page.h> |
21 | #include <asm/cacheflush.h> | 21 | #include <asm/cacheflush.h> |
diff --git a/arch/mips/kvm/interrupt.c b/arch/mips/kvm/interrupt.c index aa0a1a00faf6..7257e8b6f5a9 100644 --- a/arch/mips/kvm/interrupt.c +++ b/arch/mips/kvm/interrupt.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/vmalloc.h> | 14 | #include <linux/vmalloc.h> |
15 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | #include <asm/page.h> | 17 | #include <asm/page.h> |
18 | #include <asm/cacheflush.h> | 18 | #include <asm/cacheflush.h> |
19 | 19 | ||
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index f7ea8e21656b..1fcc4d149054 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/vmalloc.h> | 18 | #include <linux/vmalloc.h> |
19 | #include <linux/sched/signal.h> | 19 | #include <linux/sched/signal.h> |
20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | 22 | ||
23 | #include <asm/fpu.h> | 23 | #include <asm/fpu.h> |
24 | #include <asm/page.h> | 24 | #include <asm/page.h> |
diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c index d984bd5c2ec5..14d4c5e2b42f 100644 --- a/arch/mips/lantiq/prom.c +++ b/arch/mips/lantiq/prom.c | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
10 | #include <linux/clk.h> | 10 | #include <linux/clk.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/of_fdt.h> | 12 | #include <linux/of_fdt.h> |
13 | 13 | ||
14 | #include <asm/bootinfo.h> | 14 | #include <asm/bootinfo.h> |
diff --git a/arch/mips/lasat/prom.c b/arch/mips/lasat/prom.c index 37b8fc5b9ac9..5ce1407de2d5 100644 --- a/arch/mips/lasat/prom.c +++ b/arch/mips/lasat/prom.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/ctype.h> | 8 | #include <linux/ctype.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/ioport.h> | 12 | #include <linux/ioport.h> |
13 | #include <asm/bootinfo.h> | 13 | #include <asm/bootinfo.h> |
14 | #include <asm/lasat/lasat.h> | 14 | #include <asm/lasat/lasat.h> |
diff --git a/arch/mips/loongson64/common/init.c b/arch/mips/loongson64/common/init.c index 6ef17120722f..c073fbcb9805 100644 --- a/arch/mips/loongson64/common/init.c +++ b/arch/mips/loongson64/common/init.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * option) any later version. | 8 | * option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <asm/bootinfo.h> | 12 | #include <asm/bootinfo.h> |
13 | #include <asm/traps.h> | 13 | #include <asm/traps.h> |
14 | #include <asm/smp-ops.h> | 14 | #include <asm/smp-ops.h> |
diff --git a/arch/mips/loongson64/loongson-3/numa.c b/arch/mips/loongson64/loongson-3/numa.c index c1e6ec52c614..622761878cd1 100644 --- a/arch/mips/loongson64/loongson-3/numa.c +++ b/arch/mips/loongson64/loongson-3/numa.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/nodemask.h> | 18 | #include <linux/nodemask.h> |
19 | #include <linux/swap.h> | 19 | #include <linux/swap.h> |
20 | #include <linux/memblock.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/bootmem.h> | ||
22 | #include <linux/pfn.h> | 21 | #include <linux/pfn.h> |
23 | #include <linux/highmem.h> | 22 | #include <linux/highmem.h> |
24 | #include <asm/page.h> | 23 | #include <asm/page.h> |
@@ -272,7 +271,7 @@ void __init paging_init(void) | |||
272 | void __init mem_init(void) | 271 | void __init mem_init(void) |
273 | { | 272 | { |
274 | high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); | 273 | high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); |
275 | free_all_bootmem(); | 274 | memblock_free_all(); |
276 | setup_zero_pages(); /* This comes from node 0 */ | 275 | setup_zero_pages(); /* This comes from node 0 */ |
277 | mem_init_print_info(NULL); | 276 | mem_init_print_info(NULL); |
278 | } | 277 | } |
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 15cae0f11880..b521d8e2d359 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/ptrace.h> | 22 | #include <linux/ptrace.h> |
23 | #include <linux/mman.h> | 23 | #include <linux/mman.h> |
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <linux/bootmem.h> | 25 | #include <linux/memblock.h> |
26 | #include <linux/highmem.h> | 26 | #include <linux/highmem.h> |
27 | #include <linux/swap.h> | 27 | #include <linux/swap.h> |
28 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
@@ -243,7 +243,8 @@ void __init fixrange_init(unsigned long start, unsigned long end, | |||
243 | pmd = (pmd_t *)pud; | 243 | pmd = (pmd_t *)pud; |
244 | for (; (k < PTRS_PER_PMD) && (vaddr < end); pmd++, k++) { | 244 | for (; (k < PTRS_PER_PMD) && (vaddr < end); pmd++, k++) { |
245 | if (pmd_none(*pmd)) { | 245 | if (pmd_none(*pmd)) { |
246 | pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); | 246 | pte = (pte_t *) memblock_alloc_low(PAGE_SIZE, |
247 | PAGE_SIZE); | ||
247 | set_pmd(pmd, __pmd((unsigned long)pte)); | 248 | set_pmd(pmd, __pmd((unsigned long)pte)); |
248 | BUG_ON(pte != pte_offset_kernel(pmd, 0)); | 249 | BUG_ON(pte != pte_offset_kernel(pmd, 0)); |
249 | } | 250 | } |
@@ -462,7 +463,7 @@ void __init mem_init(void) | |||
462 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); | 463 | high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); |
463 | 464 | ||
464 | maar_init(); | 465 | maar_init(); |
465 | free_all_bootmem(); | 466 | memblock_free_all(); |
466 | setup_zero_pages(); /* Setup zeroed pages. */ | 467 | setup_zero_pages(); /* Setup zeroed pages. */ |
467 | mem_init_free_highmem(); | 468 | mem_init_free_highmem(); |
468 | mem_init_print_info(NULL); | 469 | mem_init_print_info(NULL); |
diff --git a/arch/mips/mm/pgtable-32.c b/arch/mips/mm/pgtable-32.c index b19a3c506b1e..e2a33adc0f29 100644 --- a/arch/mips/mm/pgtable-32.c +++ b/arch/mips/mm/pgtable-32.c | |||
@@ -7,7 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/highmem.h> | 11 | #include <linux/highmem.h> |
12 | #include <asm/fixmap.h> | 12 | #include <asm/fixmap.h> |
13 | #include <asm/pgtable.h> | 13 | #include <asm/pgtable.h> |
diff --git a/arch/mips/mti-malta/malta-memory.c b/arch/mips/mti-malta/malta-memory.c index a47556723b85..868921adef1d 100644 --- a/arch/mips/mti-malta/malta-memory.c +++ b/arch/mips/mti-malta/malta-memory.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * Steven J. Hill <sjhill@mips.com> | 12 | * Steven J. Hill <sjhill@mips.com> |
13 | */ | 13 | */ |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/bootmem.h> | 15 | #include <linux/memblock.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | 17 | ||
18 | #include <asm/bootinfo.h> | 18 | #include <asm/bootinfo.h> |
diff --git a/arch/mips/netlogic/xlp/dt.c b/arch/mips/netlogic/xlp/dt.c index b5ba83f4c646..c856f2a3ea42 100644 --- a/arch/mips/netlogic/xlp/dt.c +++ b/arch/mips/netlogic/xlp/dt.c | |||
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/bootmem.h> | 36 | #include <linux/memblock.h> |
37 | 37 | ||
38 | #include <linux/of_fdt.h> | 38 | #include <linux/of_fdt.h> |
39 | #include <linux/of_platform.h> | 39 | #include <linux/of_platform.h> |
diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index 3c3b1e6abb53..687513880fbf 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/bug.h> | 11 | #include <linux/bug.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/export.h> | 15 | #include <linux/export.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index c2e94cf5ecda..e68b44b27c0d 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/bug.h> | 11 | #include <linux/bug.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/export.h> | 15 | #include <linux/export.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c index 1ada8492733b..d544e7b07f7a 100644 --- a/arch/mips/ralink/of.c +++ b/arch/mips/ralink/of.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/sizes.h> | 14 | #include <linux/sizes.h> |
15 | #include <linux/of_fdt.h> | 15 | #include <linux/of_fdt.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/bootmem.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
19 | #include <linux/of_address.h> | 19 | #include <linux/of_address.h> |
20 | 20 | ||
diff --git a/arch/mips/rb532/prom.c b/arch/mips/rb532/prom.c index 6484e4a4597b..361a690facbf 100644 --- a/arch/mips/rb532/prom.c +++ b/arch/mips/rb532/prom.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/export.h> | 29 | #include <linux/export.h> |
30 | #include <linux/string.h> | 30 | #include <linux/string.h> |
31 | #include <linux/console.h> | 31 | #include <linux/console.h> |
32 | #include <linux/bootmem.h> | 32 | #include <linux/memblock.h> |
33 | #include <linux/ioport.h> | 33 | #include <linux/ioport.h> |
34 | #include <linux/blkdev.h> | 34 | #include <linux/blkdev.h> |
35 | 35 | ||
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index 6f7bef052b7f..d8b8444d6795 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/export.h> | 18 | #include <linux/export.h> |
19 | #include <linux/nodemask.h> | 19 | #include <linux/nodemask.h> |
20 | #include <linux/swap.h> | 20 | #include <linux/swap.h> |
21 | #include <linux/bootmem.h> | ||
22 | #include <linux/pfn.h> | 21 | #include <linux/pfn.h> |
23 | #include <linux/highmem.h> | 22 | #include <linux/highmem.h> |
24 | #include <asm/page.h> | 23 | #include <asm/page.h> |
@@ -475,7 +474,7 @@ void __init paging_init(void) | |||
475 | void __init mem_init(void) | 474 | void __init mem_init(void) |
476 | { | 475 | { |
477 | high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); | 476 | high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); |
478 | free_all_bootmem(); | 477 | memblock_free_all(); |
479 | setup_zero_pages(); /* This comes from node 0 */ | 478 | setup_zero_pages(); /* This comes from node 0 */ |
480 | mem_init_print_info(NULL); | 479 | mem_init_print_info(NULL); |
481 | } | 480 | } |
diff --git a/arch/mips/sibyte/common/cfe.c b/arch/mips/sibyte/common/cfe.c index 092fb2a6ec4a..12a780f251e1 100644 --- a/arch/mips/sibyte/common/cfe.c +++ b/arch/mips/sibyte/common/cfe.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/linkage.h> | 21 | #include <linux/linkage.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/blkdev.h> | 23 | #include <linux/blkdev.h> |
24 | #include <linux/bootmem.h> | 24 | #include <linux/memblock.h> |
25 | #include <linux/pm.h> | 25 | #include <linux/pm.h> |
26 | #include <linux/smp.h> | 26 | #include <linux/smp.h> |
27 | 27 | ||
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c index 152ca71cc2d7..3b034b7178d6 100644 --- a/arch/mips/sibyte/swarm/setup.c +++ b/arch/mips/sibyte/swarm/setup.c | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/mm.h> | 25 | #include <linux/mm.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/blkdev.h> | 27 | #include <linux/blkdev.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/arch/mips/txx9/rbtx4938/prom.c b/arch/mips/txx9/rbtx4938/prom.c index bcb469247e8c..2b36a2ee744c 100644 --- a/arch/mips/txx9/rbtx4938/prom.c +++ b/arch/mips/txx9/rbtx4938/prom.c | |||
@@ -11,7 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <asm/bootinfo.h> | 15 | #include <asm/bootinfo.h> |
16 | #include <asm/txx9/generic.h> | 16 | #include <asm/txx9/generic.h> |
17 | #include <asm/txx9/rbtx4938.h> | 17 | #include <asm/txx9/rbtx4938.h> |
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig index 56992330026a..7a04adacb2f0 100644 --- a/arch/nds32/Kconfig +++ b/arch/nds32/Kconfig | |||
@@ -29,14 +29,12 @@ config NDS32 | |||
29 | select HANDLE_DOMAIN_IRQ | 29 | select HANDLE_DOMAIN_IRQ |
30 | select HAVE_ARCH_TRACEHOOK | 30 | select HAVE_ARCH_TRACEHOOK |
31 | select HAVE_DEBUG_KMEMLEAK | 31 | select HAVE_DEBUG_KMEMLEAK |
32 | select HAVE_MEMBLOCK | ||
33 | select HAVE_REGS_AND_STACK_ACCESS_API | 32 | select HAVE_REGS_AND_STACK_ACCESS_API |
34 | select IRQ_DOMAIN | 33 | select IRQ_DOMAIN |
35 | select LOCKDEP_SUPPORT | 34 | select LOCKDEP_SUPPORT |
36 | select MODULES_USE_ELF_RELA | 35 | select MODULES_USE_ELF_RELA |
37 | select OF | 36 | select OF |
38 | select OF_EARLY_FLATTREE | 37 | select OF_EARLY_FLATTREE |
39 | select NO_BOOTMEM | ||
40 | select NO_IOPORT_MAP | 38 | select NO_IOPORT_MAP |
41 | select RTC_LIB | 39 | select RTC_LIB |
42 | select THREAD_INFO_IN_TASK | 40 | select THREAD_INFO_IN_TASK |
diff --git a/arch/nds32/include/asm/processor.h b/arch/nds32/include/asm/processor.h index 9c83caf4269f..c2660f566bac 100644 --- a/arch/nds32/include/asm/processor.h +++ b/arch/nds32/include/asm/processor.h | |||
@@ -4,12 +4,6 @@ | |||
4 | #ifndef __ASM_NDS32_PROCESSOR_H | 4 | #ifndef __ASM_NDS32_PROCESSOR_H |
5 | #define __ASM_NDS32_PROCESSOR_H | 5 | #define __ASM_NDS32_PROCESSOR_H |
6 | 6 | ||
7 | /* | ||
8 | * Default implementation of macro that returns current | ||
9 | * instruction pointer ("program counter"). | ||
10 | */ | ||
11 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
12 | |||
13 | #ifdef __KERNEL__ | 7 | #ifdef __KERNEL__ |
14 | 8 | ||
15 | #include <asm/ptrace.h> | 9 | #include <asm/ptrace.h> |
diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c index 63a1a5ef5219..eacc79024879 100644 --- a/arch/nds32/kernel/setup.c +++ b/arch/nds32/kernel/setup.c | |||
@@ -2,9 +2,8 @@ | |||
2 | // Copyright (C) 2005-2017 Andes Technology Corporation | 2 | // Copyright (C) 2005-2017 Andes Technology Corporation |
3 | 3 | ||
4 | #include <linux/cpu.h> | 4 | #include <linux/cpu.h> |
5 | #include <linux/bootmem.h> | ||
6 | #include <linux/seq_file.h> | ||
7 | #include <linux/memblock.h> | 5 | #include <linux/memblock.h> |
6 | #include <linux/seq_file.h> | ||
8 | #include <linux/console.h> | 7 | #include <linux/console.h> |
9 | #include <linux/screen_info.h> | 8 | #include <linux/screen_info.h> |
10 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
diff --git a/arch/nds32/mm/highmem.c b/arch/nds32/mm/highmem.c index e17cb8a69315..022779af6148 100644 --- a/arch/nds32/mm/highmem.c +++ b/arch/nds32/mm/highmem.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/smp.h> | 7 | #include <linux/smp.h> |
8 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
9 | #include <linux/bootmem.h> | 9 | #include <linux/memblock.h> |
10 | #include <asm/fixmap.h> | 10 | #include <asm/fixmap.h> |
11 | #include <asm/tlbflush.h> | 11 | #include <asm/tlbflush.h> |
12 | 12 | ||
diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c index c713d2ad55dc..131104bd2538 100644 --- a/arch/nds32/mm/init.c +++ b/arch/nds32/mm/init.c | |||
@@ -7,12 +7,11 @@ | |||
7 | #include <linux/errno.h> | 7 | #include <linux/errno.h> |
8 | #include <linux/swap.h> | 8 | #include <linux/swap.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/bootmem.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/mman.h> | 11 | #include <linux/mman.h> |
12 | #include <linux/nodemask.h> | 12 | #include <linux/nodemask.h> |
13 | #include <linux/initrd.h> | 13 | #include <linux/initrd.h> |
14 | #include <linux/highmem.h> | 14 | #include <linux/highmem.h> |
15 | #include <linux/memblock.h> | ||
16 | 15 | ||
17 | #include <asm/sections.h> | 16 | #include <asm/sections.h> |
18 | #include <asm/setup.h> | 17 | #include <asm/setup.h> |
@@ -81,7 +80,7 @@ static void __init map_ram(void) | |||
81 | } | 80 | } |
82 | 81 | ||
83 | /* Alloc one page for holding PTE's... */ | 82 | /* Alloc one page for holding PTE's... */ |
84 | pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 83 | pte = (pte_t *) __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
85 | memset(pte, 0, PAGE_SIZE); | 84 | memset(pte, 0, PAGE_SIZE); |
86 | set_pmd(pme, __pmd(__pa(pte) + _PAGE_KERNEL_TABLE)); | 85 | set_pmd(pme, __pmd(__pa(pte) + _PAGE_KERNEL_TABLE)); |
87 | 86 | ||
@@ -114,7 +113,7 @@ static void __init fixedrange_init(void) | |||
114 | pgd = swapper_pg_dir + pgd_index(vaddr); | 113 | pgd = swapper_pg_dir + pgd_index(vaddr); |
115 | pud = pud_offset(pgd, vaddr); | 114 | pud = pud_offset(pgd, vaddr); |
116 | pmd = pmd_offset(pud, vaddr); | 115 | pmd = pmd_offset(pud, vaddr); |
117 | fixmap_pmd_p = (pmd_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 116 | fixmap_pmd_p = (pmd_t *) __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
118 | memset(fixmap_pmd_p, 0, PAGE_SIZE); | 117 | memset(fixmap_pmd_p, 0, PAGE_SIZE); |
119 | set_pmd(pmd, __pmd(__pa(fixmap_pmd_p) + _PAGE_KERNEL_TABLE)); | 118 | set_pmd(pmd, __pmd(__pa(fixmap_pmd_p) + _PAGE_KERNEL_TABLE)); |
120 | 119 | ||
@@ -127,7 +126,7 @@ static void __init fixedrange_init(void) | |||
127 | pgd = swapper_pg_dir + pgd_index(vaddr); | 126 | pgd = swapper_pg_dir + pgd_index(vaddr); |
128 | pud = pud_offset(pgd, vaddr); | 127 | pud = pud_offset(pgd, vaddr); |
129 | pmd = pmd_offset(pud, vaddr); | 128 | pmd = pmd_offset(pud, vaddr); |
130 | pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 129 | pte = (pte_t *) __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
131 | memset(pte, 0, PAGE_SIZE); | 130 | memset(pte, 0, PAGE_SIZE); |
132 | set_pmd(pmd, __pmd(__pa(pte) + _PAGE_KERNEL_TABLE)); | 131 | set_pmd(pmd, __pmd(__pa(pte) + _PAGE_KERNEL_TABLE)); |
133 | pkmap_page_table = pte; | 132 | pkmap_page_table = pte; |
@@ -153,7 +152,7 @@ void __init paging_init(void) | |||
153 | fixedrange_init(); | 152 | fixedrange_init(); |
154 | 153 | ||
155 | /* allocate space for empty_zero_page */ | 154 | /* allocate space for empty_zero_page */ |
156 | zero_page = __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 155 | zero_page = __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
157 | memset(zero_page, 0, PAGE_SIZE); | 156 | memset(zero_page, 0, PAGE_SIZE); |
158 | zone_sizes_init(); | 157 | zone_sizes_init(); |
159 | 158 | ||
@@ -192,7 +191,7 @@ void __init mem_init(void) | |||
192 | free_highmem(); | 191 | free_highmem(); |
193 | 192 | ||
194 | /* this will put all low memory onto the freelists */ | 193 | /* this will put all low memory onto the freelists */ |
195 | free_all_bootmem(); | 194 | memblock_free_all(); |
196 | mem_init_print_info(NULL); | 195 | mem_init_print_info(NULL); |
197 | 196 | ||
198 | pr_info("virtual kernel memory layout:\n" | 197 | pr_info("virtual kernel memory layout:\n" |
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 2df0c57f2833..7e95506e957a 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig | |||
@@ -23,9 +23,7 @@ config NIOS2 | |||
23 | select SPARSE_IRQ | 23 | select SPARSE_IRQ |
24 | select USB_ARCH_HAS_HCD if USB_SUPPORT | 24 | select USB_ARCH_HAS_HCD if USB_SUPPORT |
25 | select CPU_NO_EFFICIENT_FFS | 25 | select CPU_NO_EFFICIENT_FFS |
26 | select HAVE_MEMBLOCK | ||
27 | select ARCH_DISCARD_MEMBLOCK | 26 | select ARCH_DISCARD_MEMBLOCK |
28 | select NO_BOOTMEM | ||
29 | 27 | ||
30 | config GENERIC_CSUM | 28 | config GENERIC_CSUM |
31 | def_bool y | 29 | def_bool y |
diff --git a/arch/nios2/include/asm/processor.h b/arch/nios2/include/asm/processor.h index 4944e2e1d8b0..94bcb86f679f 100644 --- a/arch/nios2/include/asm/processor.h +++ b/arch/nios2/include/asm/processor.h | |||
@@ -38,12 +38,6 @@ | |||
38 | #define KUSER_SIZE (PAGE_SIZE) | 38 | #define KUSER_SIZE (PAGE_SIZE) |
39 | #ifndef __ASSEMBLY__ | 39 | #ifndef __ASSEMBLY__ |
40 | 40 | ||
41 | /* | ||
42 | * Default implementation of macro that returns current | ||
43 | * instruction pointer ("program counter"). | ||
44 | */ | ||
45 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
46 | |||
47 | # define TASK_SIZE 0x7FFF0000UL | 41 | # define TASK_SIZE 0x7FFF0000UL |
48 | # define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) | 42 | # define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) |
49 | 43 | ||
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c index a6d4f7530247..232a36b511aa 100644 --- a/arch/nios2/kernel/prom.c +++ b/arch/nios2/kernel/prom.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/bootmem.h> | 28 | #include <linux/memblock.h> |
29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
30 | #include <linux/of_fdt.h> | 30 | #include <linux/of_fdt.h> |
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c index 2d0011ddd4d5..6bbd4ae2beb0 100644 --- a/arch/nios2/kernel/setup.c +++ b/arch/nios2/kernel/setup.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/sched/task.h> | 17 | #include <linux/sched/task.h> |
18 | #include <linux/console.h> | 18 | #include <linux/console.h> |
19 | #include <linux/bootmem.h> | ||
20 | #include <linux/memblock.h> | 19 | #include <linux/memblock.h> |
21 | #include <linux/initrd.h> | 20 | #include <linux/initrd.h> |
22 | #include <linux/of_fdt.h> | 21 | #include <linux/of_fdt.h> |
diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index c92fe4234009..16cea5776b87 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/pagemap.h> | 25 | #include <linux/pagemap.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/binfmts.h> | 28 | #include <linux/binfmts.h> |
29 | 29 | ||
@@ -73,7 +73,7 @@ void __init mem_init(void) | |||
73 | high_memory = __va(end_mem); | 73 | high_memory = __va(end_mem); |
74 | 74 | ||
75 | /* this will put all memory onto the freelists */ | 75 | /* this will put all memory onto the freelists */ |
76 | free_all_bootmem(); | 76 | memblock_free_all(); |
77 | mem_init_print_info(NULL); | 77 | mem_init_print_info(NULL); |
78 | } | 78 | } |
79 | 79 | ||
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index a655ae280637..285f7d05c8ed 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig | |||
@@ -12,7 +12,6 @@ config OPENRISC | |||
12 | select OF_EARLY_FLATTREE | 12 | select OF_EARLY_FLATTREE |
13 | select IRQ_DOMAIN | 13 | select IRQ_DOMAIN |
14 | select HANDLE_DOMAIN_IRQ | 14 | select HANDLE_DOMAIN_IRQ |
15 | select HAVE_MEMBLOCK | ||
16 | select GPIOLIB | 15 | select GPIOLIB |
17 | select HAVE_ARCH_TRACEHOOK | 16 | select HAVE_ARCH_TRACEHOOK |
18 | select SPARSE_IRQ | 17 | select SPARSE_IRQ |
@@ -32,7 +31,6 @@ config OPENRISC | |||
32 | select HAVE_DEBUG_STACKOVERFLOW | 31 | select HAVE_DEBUG_STACKOVERFLOW |
33 | select OR1K_PIC | 32 | select OR1K_PIC |
34 | select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1 | 33 | select CPU_NO_EFFICIENT_FFS if !OPENRISC_HAVE_INST_FF1 |
35 | select NO_BOOTMEM | ||
36 | select ARCH_USE_QUEUED_SPINLOCKS | 34 | select ARCH_USE_QUEUED_SPINLOCKS |
37 | select ARCH_USE_QUEUED_RWLOCKS | 35 | select ARCH_USE_QUEUED_RWLOCKS |
38 | select OMPIC if SMP | 36 | select OMPIC if SMP |
diff --git a/arch/openrisc/include/asm/processor.h b/arch/openrisc/include/asm/processor.h index af31a9fe736a..351d3aed7a06 100644 --- a/arch/openrisc/include/asm/processor.h +++ b/arch/openrisc/include/asm/processor.h | |||
@@ -30,11 +30,6 @@ | |||
30 | | SPR_SR_DCE | SPR_SR_SM) | 30 | | SPR_SR_DCE | SPR_SR_SM) |
31 | #define USER_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \ | 31 | #define USER_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \ |
32 | | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE) | 32 | | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE) |
33 | /* | ||
34 | * Default implementation of macro that returns current | ||
35 | * instruction pointer ("program counter"). | ||
36 | */ | ||
37 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
38 | 33 | ||
39 | /* | 34 | /* |
40 | * User space process size. This is hardcoded into a few places, | 35 | * User space process size. This is hardcoded into a few places, |
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c index e17fcd83120f..c605bdad1746 100644 --- a/arch/openrisc/kernel/setup.c +++ b/arch/openrisc/kernel/setup.c | |||
@@ -30,13 +30,12 @@ | |||
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/console.h> | 31 | #include <linux/console.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/memblock.h> |
34 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
35 | #include <linux/serial.h> | 35 | #include <linux/serial.h> |
36 | #include <linux/initrd.h> | 36 | #include <linux/initrd.h> |
37 | #include <linux/of_fdt.h> | 37 | #include <linux/of_fdt.h> |
38 | #include <linux/of.h> | 38 | #include <linux/of.h> |
39 | #include <linux/memblock.h> | ||
40 | #include <linux/device.h> | 39 | #include <linux/device.h> |
41 | 40 | ||
42 | #include <asm/sections.h> | 41 | #include <asm/sections.h> |
diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 6972d5d6f23f..d157310eb377 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c | |||
@@ -26,12 +26,11 @@ | |||
26 | #include <linux/mm.h> | 26 | #include <linux/mm.h> |
27 | #include <linux/swap.h> | 27 | #include <linux/swap.h> |
28 | #include <linux/smp.h> | 28 | #include <linux/smp.h> |
29 | #include <linux/bootmem.h> | 29 | #include <linux/memblock.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/blkdev.h> /* for initrd_* */ | 32 | #include <linux/blkdev.h> /* for initrd_* */ |
33 | #include <linux/pagemap.h> | 33 | #include <linux/pagemap.h> |
34 | #include <linux/memblock.h> | ||
35 | 34 | ||
36 | #include <asm/segment.h> | 35 | #include <asm/segment.h> |
37 | #include <asm/pgalloc.h> | 36 | #include <asm/pgalloc.h> |
@@ -106,7 +105,7 @@ static void __init map_ram(void) | |||
106 | } | 105 | } |
107 | 106 | ||
108 | /* Alloc one page for holding PTE's... */ | 107 | /* Alloc one page for holding PTE's... */ |
109 | pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 108 | pte = (pte_t *) __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
110 | set_pmd(pme, __pmd(_KERNPG_TABLE + __pa(pte))); | 109 | set_pmd(pme, __pmd(_KERNPG_TABLE + __pa(pte))); |
111 | 110 | ||
112 | /* Fill the newly allocated page with PTE'S */ | 111 | /* Fill the newly allocated page with PTE'S */ |
@@ -213,7 +212,7 @@ void __init mem_init(void) | |||
213 | memset((void *)empty_zero_page, 0, PAGE_SIZE); | 212 | memset((void *)empty_zero_page, 0, PAGE_SIZE); |
214 | 213 | ||
215 | /* this will put all low memory onto the freelists */ | 214 | /* this will put all low memory onto the freelists */ |
216 | free_all_bootmem(); | 215 | memblock_free_all(); |
217 | 216 | ||
218 | mem_init_print_info(NULL); | 217 | mem_init_print_info(NULL); |
219 | 218 | ||
diff --git a/arch/openrisc/mm/ioremap.c b/arch/openrisc/mm/ioremap.c index 2175e4bfd9fc..c9697529b3f0 100644 --- a/arch/openrisc/mm/ioremap.c +++ b/arch/openrisc/mm/ioremap.c | |||
@@ -126,7 +126,7 @@ pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm, | |||
126 | if (likely(mem_init_done)) { | 126 | if (likely(mem_init_done)) { |
127 | pte = (pte_t *) __get_free_page(GFP_KERNEL); | 127 | pte = (pte_t *) __get_free_page(GFP_KERNEL); |
128 | } else { | 128 | } else { |
129 | pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 129 | pte = (pte_t *) __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
130 | } | 130 | } |
131 | 131 | ||
132 | if (pte) | 132 | if (pte) |
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index f1cd12afd943..92a339ee28b3 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig | |||
@@ -15,8 +15,6 @@ config PARISC | |||
15 | select RTC_CLASS | 15 | select RTC_CLASS |
16 | select RTC_DRV_GENERIC | 16 | select RTC_DRV_GENERIC |
17 | select INIT_ALL_POSSIBLE | 17 | select INIT_ALL_POSSIBLE |
18 | select HAVE_MEMBLOCK | ||
19 | select NO_BOOTMEM | ||
20 | select BUG | 18 | select BUG |
21 | select BUILDTIME_EXTABLE_SORT | 19 | select BUILDTIME_EXTABLE_SORT |
22 | select HAVE_PERF_EVENTS | 20 | select HAVE_PERF_EVENTS |
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h index 2bd5e695bdad..6e2a8176b0dd 100644 --- a/arch/parisc/include/asm/processor.h +++ b/arch/parisc/include/asm/processor.h | |||
@@ -20,17 +20,6 @@ | |||
20 | #include <asm/percpu.h> | 20 | #include <asm/percpu.h> |
21 | #endif /* __ASSEMBLY__ */ | 21 | #endif /* __ASSEMBLY__ */ |
22 | 22 | ||
23 | /* | ||
24 | * Default implementation of macro that returns current | ||
25 | * instruction pointer ("program counter"). | ||
26 | */ | ||
27 | #ifdef CONFIG_PA20 | ||
28 | #define current_ia(x) __asm__("mfia %0" : "=r"(x)) | ||
29 | #else /* mfia added in pa2.0 */ | ||
30 | #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x)) | ||
31 | #endif | ||
32 | #define current_text_addr() ({ void *pc; current_ia(pc); pc; }) | ||
33 | |||
34 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | 23 | #define HAVE_ARCH_PICK_MMAP_LAYOUT |
35 | 24 | ||
36 | #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size) | 25 | #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size) |
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index f88a52b8531c..2d7cffcaa476 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/bootmem.h> | ||
18 | #include <linux/memblock.h> | 17 | #include <linux/memblock.h> |
19 | #include <linux/gfp.h> | 18 | #include <linux/gfp.h> |
20 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
@@ -621,7 +620,7 @@ void __init mem_init(void) | |||
621 | 620 | ||
622 | high_memory = __va((max_pfn << PAGE_SHIFT)); | 621 | high_memory = __va((max_pfn << PAGE_SHIFT)); |
623 | set_max_mapnr(page_to_pfn(virt_to_page(high_memory - 1)) + 1); | 622 | set_max_mapnr(page_to_pfn(virt_to_page(high_memory - 1)) + 1); |
624 | free_all_bootmem(); | 623 | memblock_free_all(); |
625 | 624 | ||
626 | #ifdef CONFIG_PA11 | 625 | #ifdef CONFIG_PA11 |
627 | if (boot_cpu_data.cpu_type == pcxl2 || boot_cpu_data.cpu_type == pcxl) { | 626 | if (boot_cpu_data.cpu_type == pcxl2 || boot_cpu_data.cpu_type == pcxl) { |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index e84943d24e5c..2d51b2bd4aa1 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -206,7 +206,6 @@ config PPC | |||
206 | select HAVE_KRETPROBES | 206 | select HAVE_KRETPROBES |
207 | select HAVE_LD_DEAD_CODE_DATA_ELIMINATION | 207 | select HAVE_LD_DEAD_CODE_DATA_ELIMINATION |
208 | select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS | 208 | select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS |
209 | select HAVE_MEMBLOCK | ||
210 | select HAVE_MEMBLOCK_NODE_MAP | 209 | select HAVE_MEMBLOCK_NODE_MAP |
211 | select HAVE_MOD_ARCH_SPECIFIC | 210 | select HAVE_MOD_ARCH_SPECIFIC |
212 | select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) | 211 | select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) |
@@ -231,7 +230,6 @@ config PPC | |||
231 | select MODULES_USE_ELF_RELA | 230 | select MODULES_USE_ELF_RELA |
232 | select NEED_DMA_MAP_STATE if PPC64 || NOT_COHERENT_CACHE | 231 | select NEED_DMA_MAP_STATE if PPC64 || NOT_COHERENT_CACHE |
233 | select NEED_SG_DMA_LENGTH | 232 | select NEED_SG_DMA_LENGTH |
234 | select NO_BOOTMEM | ||
235 | select OF | 233 | select OF |
236 | select OF_EARLY_FLATTREE | 234 | select OF_EARLY_FLATTREE |
237 | select OF_RESERVED_MEM | 235 | select OF_RESERVED_MEM |
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index 7d04d60a39c9..ee58526cb6c2 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h | |||
@@ -67,12 +67,6 @@ extern int _chrp_type; | |||
67 | 67 | ||
68 | #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */ | 68 | #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */ |
69 | 69 | ||
70 | /* | ||
71 | * Default implementation of macro that returns current | ||
72 | * instruction pointer ("program counter"). | ||
73 | */ | ||
74 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
75 | |||
76 | /* Macros for adjusting thread priority (hardware multi-threading) */ | 70 | /* Macros for adjusting thread priority (hardware multi-threading) */ |
77 | #define HMT_very_low() asm volatile("or 31,31,31 # very low priority") | 71 | #define HMT_very_low() asm volatile("or 31,31,31 # very low priority") |
78 | #define HMT_low() asm volatile("or 1,1,1 # low priority") | 72 | #define HMT_low() asm volatile("or 1,1,1 # low priority") |
diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c index f432054234a4..8be3721d9302 100644 --- a/arch/powerpc/kernel/dt_cpu_ftrs.c +++ b/arch/powerpc/kernel/dt_cpu_ftrs.c | |||
@@ -1008,9 +1008,7 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char | |||
1008 | /* Count and allocate space for cpu features */ | 1008 | /* Count and allocate space for cpu features */ |
1009 | of_scan_flat_dt_subnodes(node, count_cpufeatures_subnodes, | 1009 | of_scan_flat_dt_subnodes(node, count_cpufeatures_subnodes, |
1010 | &nr_dt_cpu_features); | 1010 | &nr_dt_cpu_features); |
1011 | dt_cpu_features = __va( | 1011 | dt_cpu_features = __va(memblock_phys_alloc(sizeof(struct dt_cpu_feature) * nr_dt_cpu_features, PAGE_SIZE)); |
1012 | memblock_alloc(sizeof(struct dt_cpu_feature)* | ||
1013 | nr_dt_cpu_features, PAGE_SIZE)); | ||
1014 | 1012 | ||
1015 | cpufeatures_setup_start(isa); | 1013 | cpufeatures_setup_start(isa); |
1016 | 1014 | ||
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 0ee3e6d50f28..913bfca09c4f 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c | |||
@@ -198,7 +198,7 @@ void __init allocate_paca_ptrs(void) | |||
198 | paca_nr_cpu_ids = nr_cpu_ids; | 198 | paca_nr_cpu_ids = nr_cpu_ids; |
199 | 199 | ||
200 | paca_ptrs_size = sizeof(struct paca_struct *) * nr_cpu_ids; | 200 | paca_ptrs_size = sizeof(struct paca_struct *) * nr_cpu_ids; |
201 | paca_ptrs = __va(memblock_alloc(paca_ptrs_size, 0)); | 201 | paca_ptrs = __va(memblock_phys_alloc(paca_ptrs_size, SMP_CACHE_BYTES)); |
202 | memset(paca_ptrs, 0x88, paca_ptrs_size); | 202 | memset(paca_ptrs, 0x88, paca_ptrs_size); |
203 | } | 203 | } |
204 | 204 | ||
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 4da8ed576229..d3f04f2d8249 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/capability.h> | 10 | #include <linux/capability.h> |
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
13 | #include <linux/bootmem.h> | 13 | #include <linux/memblock.h> |
14 | #include <linux/syscalls.h> | 14 | #include <linux/syscalls.h> |
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/list.h> | 16 | #include <linux/list.h> |
@@ -203,7 +203,8 @@ pci_create_OF_bus_map(void) | |||
203 | struct property* of_prop; | 203 | struct property* of_prop; |
204 | struct device_node *dn; | 204 | struct device_node *dn; |
205 | 205 | ||
206 | of_prop = memblock_virt_alloc(sizeof(struct property) + 256, 0); | 206 | of_prop = memblock_alloc(sizeof(struct property) + 256, |
207 | SMP_CACHE_BYTES); | ||
207 | dn = of_find_node_by_path("/"); | 208 | dn = of_find_node_by_path("/"); |
208 | if (dn) { | 209 | if (dn) { |
209 | memset(of_prop, -1, sizeof(struct property) + 256); | 210 | memset(of_prop, -1, sizeof(struct property) + 256); |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index c4d7078e5295..fe758cedb93f 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -126,7 +126,7 @@ static void __init move_device_tree(void) | |||
126 | if ((memory_limit && (start + size) > PHYSICAL_START + memory_limit) || | 126 | if ((memory_limit && (start + size) > PHYSICAL_START + memory_limit) || |
127 | overlaps_crashkernel(start, size) || | 127 | overlaps_crashkernel(start, size) || |
128 | overlaps_initrd(start, size)) { | 128 | overlaps_initrd(start, size)) { |
129 | p = __va(memblock_alloc(size, PAGE_SIZE)); | 129 | p = __va(memblock_phys_alloc(size, PAGE_SIZE)); |
130 | memcpy(p, initial_boot_params, size); | 130 | memcpy(p, initial_boot_params, size); |
131 | initial_boot_params = p; | 131 | initial_boot_params = p; |
132 | DBG("Moved device tree to 0x%p\n", p); | 132 | DBG("Moved device tree to 0x%p\n", p); |
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 9ca9db707bcb..93ee3703b42f 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/serial_8250.h> | 33 | #include <linux/serial_8250.h> |
34 | #include <linux/percpu.h> | 34 | #include <linux/percpu.h> |
35 | #include <linux/memblock.h> | 35 | #include <linux/memblock.h> |
36 | #include <linux/bootmem.h> | ||
37 | #include <linux/of_platform.h> | 36 | #include <linux/of_platform.h> |
38 | #include <linux/hugetlb.h> | 37 | #include <linux/hugetlb.h> |
39 | #include <asm/debugfs.h> | 38 | #include <asm/debugfs.h> |
@@ -460,8 +459,7 @@ void __init smp_setup_cpu_maps(void) | |||
460 | 459 | ||
461 | DBG("smp_setup_cpu_maps()\n"); | 460 | DBG("smp_setup_cpu_maps()\n"); |
462 | 461 | ||
463 | cpu_to_phys_id = __va(memblock_alloc(nr_cpu_ids * sizeof(u32), | 462 | cpu_to_phys_id = __va(memblock_phys_alloc(nr_cpu_ids * sizeof(u32), __alignof__(u32))); |
464 | __alignof__(u32))); | ||
465 | memset(cpu_to_phys_id, 0, nr_cpu_ids * sizeof(u32)); | 463 | memset(cpu_to_phys_id, 0, nr_cpu_ids * sizeof(u32)); |
466 | 464 | ||
467 | for_each_node_by_type(dn, "cpu") { | 465 | for_each_node_by_type(dn, "cpu") { |
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 8c507be12c3c..81909600013a 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -206,9 +206,9 @@ void __init irqstack_early_init(void) | |||
206 | * as the memblock is limited to lowmem by default */ | 206 | * as the memblock is limited to lowmem by default */ |
207 | for_each_possible_cpu(i) { | 207 | for_each_possible_cpu(i) { |
208 | softirq_ctx[i] = (struct thread_info *) | 208 | softirq_ctx[i] = (struct thread_info *) |
209 | __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); | 209 | __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); |
210 | hardirq_ctx[i] = (struct thread_info *) | 210 | hardirq_ctx[i] = (struct thread_info *) |
211 | __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); | 211 | __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
@@ -227,12 +227,12 @@ void __init exc_lvl_early_init(void) | |||
227 | #endif | 227 | #endif |
228 | 228 | ||
229 | critirq_ctx[hw_cpu] = (struct thread_info *) | 229 | critirq_ctx[hw_cpu] = (struct thread_info *) |
230 | __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); | 230 | __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); |
231 | #ifdef CONFIG_BOOKE | 231 | #ifdef CONFIG_BOOKE |
232 | dbgirq_ctx[hw_cpu] = (struct thread_info *) | 232 | dbgirq_ctx[hw_cpu] = (struct thread_info *) |
233 | __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); | 233 | __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); |
234 | mcheckirq_ctx[hw_cpu] = (struct thread_info *) | 234 | mcheckirq_ctx[hw_cpu] = (struct thread_info *) |
235 | __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); | 235 | __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); |
236 | #endif | 236 | #endif |
237 | } | 237 | } |
238 | } | 238 | } |
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index faf00222b324..2a51e4cc8246 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -29,10 +29,9 @@ | |||
29 | #include <linux/unistd.h> | 29 | #include <linux/unistd.h> |
30 | #include <linux/serial.h> | 30 | #include <linux/serial.h> |
31 | #include <linux/serial_8250.h> | 31 | #include <linux/serial_8250.h> |
32 | #include <linux/bootmem.h> | 32 | #include <linux/memblock.h> |
33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
34 | #include <linux/lockdep.h> | 34 | #include <linux/lockdep.h> |
35 | #include <linux/memblock.h> | ||
36 | #include <linux/memory.h> | 35 | #include <linux/memory.h> |
37 | #include <linux/nmi.h> | 36 | #include <linux/nmi.h> |
38 | 37 | ||
@@ -763,13 +762,15 @@ void __init emergency_stack_init(void) | |||
763 | 762 | ||
764 | static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align) | 763 | static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align) |
765 | { | 764 | { |
766 | return __alloc_bootmem_node(NODE_DATA(early_cpu_to_node(cpu)), size, align, | 765 | return memblock_alloc_try_nid(size, align, __pa(MAX_DMA_ADDRESS), |
767 | __pa(MAX_DMA_ADDRESS)); | 766 | MEMBLOCK_ALLOC_ACCESSIBLE, |
767 | early_cpu_to_node(cpu)); | ||
768 | |||
768 | } | 769 | } |
769 | 770 | ||
770 | static void __init pcpu_fc_free(void *ptr, size_t size) | 771 | static void __init pcpu_fc_free(void *ptr, size_t size) |
771 | { | 772 | { |
772 | free_bootmem(__pa(ptr), size); | 773 | memblock_free(__pa(ptr), size); |
773 | } | 774 | } |
774 | 775 | ||
775 | static int pcpu_cpu_distance(unsigned int from, unsigned int to) | 776 | static int pcpu_cpu_distance(unsigned int from, unsigned int to) |
diff --git a/arch/powerpc/lib/alloc.c b/arch/powerpc/lib/alloc.c index 06796dec01ea..dedf88a76f58 100644 --- a/arch/powerpc/lib/alloc.c +++ b/arch/powerpc/lib/alloc.c | |||
@@ -2,7 +2,7 @@ | |||
2 | #include <linux/types.h> | 2 | #include <linux/types.h> |
3 | #include <linux/init.h> | 3 | #include <linux/init.h> |
4 | #include <linux/slab.h> | 4 | #include <linux/slab.h> |
5 | #include <linux/bootmem.h> | 5 | #include <linux/memblock.h> |
6 | #include <linux/string.h> | 6 | #include <linux/string.h> |
7 | #include <asm/setup.h> | 7 | #include <asm/setup.h> |
8 | 8 | ||
@@ -14,7 +14,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) | |||
14 | if (slab_is_available()) | 14 | if (slab_is_available()) |
15 | p = kzalloc(size, mask); | 15 | p = kzalloc(size, mask); |
16 | else { | 16 | else { |
17 | p = memblock_virt_alloc(size, 0); | 17 | p = memblock_alloc(size, SMP_CACHE_BYTES); |
18 | } | 18 | } |
19 | return p; | 19 | return p; |
20 | } | 20 | } |
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index a7226ed9cae6..8cf035e68378 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/export.h> | 15 | #include <linux/export.h> |
16 | #include <linux/of_fdt.h> | 16 | #include <linux/of_fdt.h> |
17 | #include <linux/memblock.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/bootmem.h> | ||
19 | #include <linux/moduleparam.h> | 18 | #include <linux/moduleparam.h> |
20 | #include <linux/swap.h> | 19 | #include <linux/swap.h> |
21 | #include <linux/swapops.h> | 20 | #include <linux/swapops.h> |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index dd949d6649a2..0a64fffabee1 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -27,12 +27,11 @@ | |||
27 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
28 | #include <linux/stddef.h> | 28 | #include <linux/stddef.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/bootmem.h> | 30 | #include <linux/memblock.h> |
31 | #include <linux/highmem.h> | 31 | #include <linux/highmem.h> |
32 | #include <linux/initrd.h> | 32 | #include <linux/initrd.h> |
33 | #include <linux/pagemap.h> | 33 | #include <linux/pagemap.h> |
34 | #include <linux/suspend.h> | 34 | #include <linux/suspend.h> |
35 | #include <linux/memblock.h> | ||
36 | #include <linux/hugetlb.h> | 35 | #include <linux/hugetlb.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
38 | #include <linux/vmalloc.h> | 37 | #include <linux/vmalloc.h> |
@@ -349,7 +348,7 @@ void __init mem_init(void) | |||
349 | 348 | ||
350 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); | 349 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); |
351 | set_max_mapnr(max_pfn); | 350 | set_max_mapnr(max_pfn); |
352 | free_all_bootmem(); | 351 | memblock_free_all(); |
353 | 352 | ||
354 | #ifdef CONFIG_HIGHMEM | 353 | #ifdef CONFIG_HIGHMEM |
355 | { | 354 | { |
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c index 4d80239ef83c..2faca46ad720 100644 --- a/arch/powerpc/mm/mmu_context_nohash.c +++ b/arch/powerpc/mm/mmu_context_nohash.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/mm.h> | 44 | #include <linux/mm.h> |
45 | #include <linux/init.h> | 45 | #include <linux/init.h> |
46 | #include <linux/spinlock.h> | 46 | #include <linux/spinlock.h> |
47 | #include <linux/bootmem.h> | 47 | #include <linux/memblock.h> |
48 | #include <linux/notifier.h> | 48 | #include <linux/notifier.h> |
49 | #include <linux/cpu.h> | 49 | #include <linux/cpu.h> |
50 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
@@ -461,10 +461,11 @@ void __init mmu_context_init(void) | |||
461 | /* | 461 | /* |
462 | * Allocate the maps used by context management | 462 | * Allocate the maps used by context management |
463 | */ | 463 | */ |
464 | context_map = memblock_virt_alloc(CTX_MAP_SIZE, 0); | 464 | context_map = memblock_alloc(CTX_MAP_SIZE, SMP_CACHE_BYTES); |
465 | context_mm = memblock_virt_alloc(sizeof(void *) * (LAST_CONTEXT + 1), 0); | 465 | context_mm = memblock_alloc(sizeof(void *) * (LAST_CONTEXT + 1), |
466 | SMP_CACHE_BYTES); | ||
466 | #ifdef CONFIG_SMP | 467 | #ifdef CONFIG_SMP |
467 | stale_map[boot_cpuid] = memblock_virt_alloc(CTX_MAP_SIZE, 0); | 468 | stale_map[boot_cpuid] = memblock_alloc(CTX_MAP_SIZE, SMP_CACHE_BYTES); |
468 | 469 | ||
469 | cpuhp_setup_state_nocalls(CPUHP_POWERPC_MMU_CTX_PREPARE, | 470 | cpuhp_setup_state_nocalls(CPUHP_POWERPC_MMU_CTX_PREPARE, |
470 | "powerpc/mmu/ctx:prepare", | 471 | "powerpc/mmu/ctx:prepare", |
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 693ae1c1acba..3a048e98a132 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #define pr_fmt(fmt) "numa: " fmt | 11 | #define pr_fmt(fmt) "numa: " fmt |
12 | 12 | ||
13 | #include <linux/threads.h> | 13 | #include <linux/threads.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/mmzone.h> | 17 | #include <linux/mmzone.h> |
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/nodemask.h> | 19 | #include <linux/nodemask.h> |
20 | #include <linux/cpu.h> | 20 | #include <linux/cpu.h> |
21 | #include <linux/notifier.h> | 21 | #include <linux/notifier.h> |
22 | #include <linux/memblock.h> | ||
23 | #include <linux/of.h> | 22 | #include <linux/of.h> |
24 | #include <linux/pfn.h> | 23 | #include <linux/pfn.h> |
25 | #include <linux/cpuset.h> | 24 | #include <linux/cpuset.h> |
@@ -788,7 +787,7 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) | |||
788 | void *nd; | 787 | void *nd; |
789 | int tnid; | 788 | int tnid; |
790 | 789 | ||
791 | nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); | 790 | nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); |
792 | nd = __va(nd_pa); | 791 | nd = __va(nd_pa); |
793 | 792 | ||
794 | /* report and initialize */ | 793 | /* report and initialize */ |
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index 5877f5aa8f5d..bda3c6f1bd32 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c | |||
@@ -50,7 +50,7 @@ __ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) | |||
50 | if (slab_is_available()) { | 50 | if (slab_is_available()) { |
51 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); | 51 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); |
52 | } else { | 52 | } else { |
53 | pte = __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); | 53 | pte = __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); |
54 | if (pte) | 54 | if (pte) |
55 | clear_page(pte); | 55 | clear_page(pte); |
56 | } | 56 | } |
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c index 38a793bfca37..f6f575bae3bc 100644 --- a/arch/powerpc/mm/ppc_mmu_32.c +++ b/arch/powerpc/mm/ppc_mmu_32.c | |||
@@ -224,7 +224,7 @@ void __init MMU_init_hw(void) | |||
224 | * Find some memory for the hash table. | 224 | * Find some memory for the hash table. |
225 | */ | 225 | */ |
226 | if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322); | 226 | if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322); |
227 | Hash = __va(memblock_alloc(Hash_size, Hash_size)); | 227 | Hash = __va(memblock_phys_alloc(Hash_size, Hash_size)); |
228 | memset(Hash, 0, Hash_size); | 228 | memset(Hash, 0, Hash_size); |
229 | _SDR1 = __pa(Hash) | SDR1_LOW_BITS; | 229 | _SDR1 = __pa(Hash) | SDR1_LOW_BITS; |
230 | 230 | ||
diff --git a/arch/powerpc/platforms/pasemi/iommu.c b/arch/powerpc/platforms/pasemi/iommu.c index f06c83f321e6..f2971522fb4a 100644 --- a/arch/powerpc/platforms/pasemi/iommu.c +++ b/arch/powerpc/platforms/pasemi/iommu.c | |||
@@ -213,7 +213,7 @@ static int __init iob_init(struct device_node *dn) | |||
213 | pr_info("IOBMAP L2 allocated at: %p\n", iob_l2_base); | 213 | pr_info("IOBMAP L2 allocated at: %p\n", iob_l2_base); |
214 | 214 | ||
215 | /* Allocate a spare page to map all invalid IOTLB pages. */ | 215 | /* Allocate a spare page to map all invalid IOTLB pages. */ |
216 | tmp = memblock_alloc(IOBMAP_PAGE_SIZE, IOBMAP_PAGE_SIZE); | 216 | tmp = memblock_phys_alloc(IOBMAP_PAGE_SIZE, IOBMAP_PAGE_SIZE); |
217 | if (!tmp) | 217 | if (!tmp) |
218 | panic("IOBMAP: Cannot allocate spare page!"); | 218 | panic("IOBMAP: Cannot allocate spare page!"); |
219 | /* Empty l1 is marked invalid */ | 219 | /* Empty l1 is marked invalid */ |
diff --git a/arch/powerpc/platforms/powermac/nvram.c b/arch/powerpc/platforms/powermac/nvram.c index 60b03a1703d1..ae54d7fe68f3 100644 --- a/arch/powerpc/platforms/powermac/nvram.c +++ b/arch/powerpc/platforms/powermac/nvram.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/errno.h> | 18 | #include <linux/errno.h> |
19 | #include <linux/adb.h> | 19 | #include <linux/adb.h> |
20 | #include <linux/pmu.h> | 20 | #include <linux/pmu.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | #include <linux/completion.h> | 22 | #include <linux/completion.h> |
23 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
24 | #include <asm/sections.h> | 24 | #include <asm/sections.h> |
@@ -513,7 +513,7 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr) | |||
513 | printk(KERN_ERR "nvram: no address\n"); | 513 | printk(KERN_ERR "nvram: no address\n"); |
514 | return -EINVAL; | 514 | return -EINVAL; |
515 | } | 515 | } |
516 | nvram_image = memblock_virt_alloc(NVRAM_SIZE, 0); | 516 | nvram_image = memblock_alloc(NVRAM_SIZE, SMP_CACHE_BYTES); |
517 | nvram_data = ioremap(addr, NVRAM_SIZE*2); | 517 | nvram_data = ioremap(addr, NVRAM_SIZE*2); |
518 | nvram_naddrs = 1; /* Make sure we get the correct case */ | 518 | nvram_naddrs = 1; /* Make sure we get the correct case */ |
519 | 519 | ||
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c index a29fdf8a2e56..84d038ed3882 100644 --- a/arch/powerpc/platforms/powernv/memtrace.c +++ b/arch/powerpc/platforms/powernv/memtrace.c | |||
@@ -70,6 +70,7 @@ static int change_memblock_state(struct memory_block *mem, void *arg) | |||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* called with device_hotplug_lock held */ | ||
73 | static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages) | 74 | static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages) |
74 | { | 75 | { |
75 | u64 end_pfn = start_pfn + nr_pages - 1; | 76 | u64 end_pfn = start_pfn + nr_pages - 1; |
@@ -110,6 +111,7 @@ static u64 memtrace_alloc_node(u32 nid, u64 size) | |||
110 | /* Trace memory needs to be aligned to the size */ | 111 | /* Trace memory needs to be aligned to the size */ |
111 | end_pfn = round_down(end_pfn - nr_pages, nr_pages); | 112 | end_pfn = round_down(end_pfn - nr_pages, nr_pages); |
112 | 113 | ||
114 | lock_device_hotplug(); | ||
113 | for (base_pfn = end_pfn; base_pfn > start_pfn; base_pfn -= nr_pages) { | 115 | for (base_pfn = end_pfn; base_pfn > start_pfn; base_pfn -= nr_pages) { |
114 | if (memtrace_offline_pages(nid, base_pfn, nr_pages) == true) { | 116 | if (memtrace_offline_pages(nid, base_pfn, nr_pages) == true) { |
115 | /* | 117 | /* |
@@ -118,15 +120,15 @@ static u64 memtrace_alloc_node(u32 nid, u64 size) | |||
118 | * we never try to remove memory that spans two iomem | 120 | * we never try to remove memory that spans two iomem |
119 | * resources. | 121 | * resources. |
120 | */ | 122 | */ |
121 | lock_device_hotplug(); | ||
122 | end_pfn = base_pfn + nr_pages; | 123 | end_pfn = base_pfn + nr_pages; |
123 | for (pfn = base_pfn; pfn < end_pfn; pfn += bytes>> PAGE_SHIFT) { | 124 | for (pfn = base_pfn; pfn < end_pfn; pfn += bytes>> PAGE_SHIFT) { |
124 | remove_memory(nid, pfn << PAGE_SHIFT, bytes); | 125 | __remove_memory(nid, pfn << PAGE_SHIFT, bytes); |
125 | } | 126 | } |
126 | unlock_device_hotplug(); | 127 | unlock_device_hotplug(); |
127 | return base_pfn << PAGE_SHIFT; | 128 | return base_pfn << PAGE_SHIFT; |
128 | } | 129 | } |
129 | } | 130 | } |
131 | unlock_device_hotplug(); | ||
130 | 132 | ||
131 | return 0; | 133 | return 0; |
132 | } | 134 | } |
@@ -242,9 +244,11 @@ static int memtrace_online(void) | |||
242 | * we need to online the memory ourselves. | 244 | * we need to online the memory ourselves. |
243 | */ | 245 | */ |
244 | if (!memhp_auto_online) { | 246 | if (!memhp_auto_online) { |
247 | lock_device_hotplug(); | ||
245 | walk_memory_range(PFN_DOWN(ent->start), | 248 | walk_memory_range(PFN_DOWN(ent->start), |
246 | PFN_UP(ent->start + ent->size - 1), | 249 | PFN_UP(ent->start + ent->size - 1), |
247 | NULL, online_mem_block); | 250 | NULL, online_mem_block); |
251 | unlock_device_hotplug(); | ||
248 | } | 252 | } |
249 | 253 | ||
250 | /* | 254 | /* |
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index a4641515956f..beed86f4224b 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c | |||
@@ -171,7 +171,7 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node, | |||
171 | /* | 171 | /* |
172 | * Allocate a buffer to hold the MC recoverable ranges. | 172 | * Allocate a buffer to hold the MC recoverable ranges. |
173 | */ | 173 | */ |
174 | mc_recoverable_range =__va(memblock_alloc(size, __alignof__(u64))); | 174 | mc_recoverable_range =__va(memblock_phys_alloc(size, __alignof__(u64))); |
175 | memset(mc_recoverable_range, 0, size); | 175 | memset(mc_recoverable_range, 0, size); |
176 | 176 | ||
177 | for (i = 0; i < mc_recoverable_range_len; i++) { | 177 | for (i = 0; i < mc_recoverable_range_len; i++) { |
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index cde710297a4e..dd807446801e 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c | |||
@@ -17,11 +17,10 @@ | |||
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/irq.h> | 21 | #include <linux/irq.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/msi.h> | 23 | #include <linux/msi.h> |
24 | #include <linux/memblock.h> | ||
25 | #include <linux/iommu.h> | 24 | #include <linux/iommu.h> |
26 | #include <linux/rculist.h> | 25 | #include <linux/rculist.h> |
27 | #include <linux/sizes.h> | 26 | #include <linux/sizes.h> |
@@ -3770,7 +3769,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, | |||
3770 | phb_id = be64_to_cpup(prop64); | 3769 | phb_id = be64_to_cpup(prop64); |
3771 | pr_debug(" PHB-ID : 0x%016llx\n", phb_id); | 3770 | pr_debug(" PHB-ID : 0x%016llx\n", phb_id); |
3772 | 3771 | ||
3773 | phb = memblock_virt_alloc(sizeof(*phb), 0); | 3772 | phb = memblock_alloc(sizeof(*phb), SMP_CACHE_BYTES); |
3774 | 3773 | ||
3775 | /* Allocate PCI controller */ | 3774 | /* Allocate PCI controller */ |
3776 | phb->hose = hose = pcibios_alloc_controller(np); | 3775 | phb->hose = hose = pcibios_alloc_controller(np); |
@@ -3816,7 +3815,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, | |||
3816 | else | 3815 | else |
3817 | phb->diag_data_size = PNV_PCI_DIAG_BUF_SIZE; | 3816 | phb->diag_data_size = PNV_PCI_DIAG_BUF_SIZE; |
3818 | 3817 | ||
3819 | phb->diag_data = memblock_virt_alloc(phb->diag_data_size, 0); | 3818 | phb->diag_data = memblock_alloc(phb->diag_data_size, SMP_CACHE_BYTES); |
3820 | 3819 | ||
3821 | /* Parse 32-bit and IO ranges (if any) */ | 3820 | /* Parse 32-bit and IO ranges (if any) */ |
3822 | pci_process_bridge_OF_ranges(hose, np, !hose->global_number); | 3821 | pci_process_bridge_OF_ranges(hose, np, !hose->global_number); |
@@ -3875,7 +3874,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, | |||
3875 | } | 3874 | } |
3876 | pemap_off = size; | 3875 | pemap_off = size; |
3877 | size += phb->ioda.total_pe_num * sizeof(struct pnv_ioda_pe); | 3876 | size += phb->ioda.total_pe_num * sizeof(struct pnv_ioda_pe); |
3878 | aux = memblock_virt_alloc(size, 0); | 3877 | aux = memblock_alloc(size, SMP_CACHE_BYTES); |
3879 | phb->ioda.pe_alloc = aux; | 3878 | phb->ioda.pe_alloc = aux; |
3880 | phb->ioda.m64_segmap = aux + m64map_off; | 3879 | phb->ioda.m64_segmap = aux + m64map_off; |
3881 | phb->ioda.m32_segmap = aux + m32map_off; | 3880 | phb->ioda.m32_segmap = aux + m32map_off; |
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c index 77a37520068d..658bfab3350b 100644 --- a/arch/powerpc/platforms/ps3/setup.c +++ b/arch/powerpc/platforms/ps3/setup.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/root_dev.h> | 24 | #include <linux/root_dev.h> |
25 | #include <linux/console.h> | 25 | #include <linux/console.h> |
26 | #include <linux/export.h> | 26 | #include <linux/export.h> |
27 | #include <linux/bootmem.h> | 27 | #include <linux/memblock.h> |
28 | 28 | ||
29 | #include <asm/machdep.h> | 29 | #include <asm/machdep.h> |
30 | #include <asm/firmware.h> | 30 | #include <asm/firmware.h> |
@@ -126,7 +126,7 @@ static void __init prealloc(struct ps3_prealloc *p) | |||
126 | if (!p->size) | 126 | if (!p->size) |
127 | return; | 127 | return; |
128 | 128 | ||
129 | p->address = memblock_virt_alloc(p->size, p->align); | 129 | p->address = memblock_alloc(p->size, p->align); |
130 | 130 | ||
131 | printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size, | 131 | printk(KERN_INFO "%s: %lu bytes at %p\n", p->name, p->size, |
132 | p->address); | 132 | p->address); |
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 2b796da822c2..2a983b5a52e1 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c | |||
@@ -300,7 +300,7 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz | |||
300 | nid = memory_add_physaddr_to_nid(base); | 300 | nid = memory_add_physaddr_to_nid(base); |
301 | 301 | ||
302 | for (i = 0; i < sections_per_block; i++) { | 302 | for (i = 0; i < sections_per_block; i++) { |
303 | remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE); | 303 | __remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE); |
304 | base += MIN_MEMORY_BLOCK_SIZE; | 304 | base += MIN_MEMORY_BLOCK_SIZE; |
305 | } | 305 | } |
306 | 306 | ||
@@ -389,7 +389,7 @@ static int dlpar_remove_lmb(struct drmem_lmb *lmb) | |||
389 | block_sz = pseries_memory_block_size(); | 389 | block_sz = pseries_memory_block_size(); |
390 | nid = memory_add_physaddr_to_nid(lmb->base_addr); | 390 | nid = memory_add_physaddr_to_nid(lmb->base_addr); |
391 | 391 | ||
392 | remove_memory(nid, lmb->base_addr, block_sz); | 392 | __remove_memory(nid, lmb->base_addr, block_sz); |
393 | 393 | ||
394 | /* Update memory regions for memory remove */ | 394 | /* Update memory regions for memory remove */ |
395 | memblock_remove(lmb->base_addr, block_sz); | 395 | memblock_remove(lmb->base_addr, block_sz); |
@@ -668,7 +668,7 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb) | |||
668 | nid = memory_add_physaddr_to_nid(lmb->base_addr); | 668 | nid = memory_add_physaddr_to_nid(lmb->base_addr); |
669 | 669 | ||
670 | /* Add the memory */ | 670 | /* Add the memory */ |
671 | rc = add_memory(nid, lmb->base_addr, block_sz); | 671 | rc = __add_memory(nid, lmb->base_addr, block_sz); |
672 | if (rc) { | 672 | if (rc) { |
673 | invalidate_lmb_associativity_index(lmb); | 673 | invalidate_lmb_associativity_index(lmb); |
674 | return rc; | 674 | return rc; |
@@ -676,7 +676,7 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb) | |||
676 | 676 | ||
677 | rc = dlpar_online_lmb(lmb); | 677 | rc = dlpar_online_lmb(lmb); |
678 | if (rc) { | 678 | if (rc) { |
679 | remove_memory(nid, lmb->base_addr, block_sz); | 679 | __remove_memory(nid, lmb->base_addr, block_sz); |
680 | invalidate_lmb_associativity_index(lmb); | 680 | invalidate_lmb_associativity_index(lmb); |
681 | } else { | 681 | } else { |
682 | lmb->flags |= DRCONF_MEM_ASSIGNED; | 682 | lmb->flags |= DRCONF_MEM_ASSIGNED; |
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index 5ca3e22d0512..a5b40d1460f1 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c | |||
@@ -261,7 +261,7 @@ static void allocate_dart(void) | |||
261 | * that to work around what looks like a problem with the HT bridge | 261 | * that to work around what looks like a problem with the HT bridge |
262 | * prefetching into invalid pages and corrupting data | 262 | * prefetching into invalid pages and corrupting data |
263 | */ | 263 | */ |
264 | tmp = memblock_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE); | 264 | tmp = memblock_phys_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE); |
265 | dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) & | 265 | dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) & |
266 | DARTMAP_RPNMASK); | 266 | DARTMAP_RPNMASK); |
267 | 267 | ||
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c index e64a411d1a00..d45450f6666a 100644 --- a/arch/powerpc/sysdev/msi_bitmap.c +++ b/arch/powerpc/sysdev/msi_bitmap.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/kmemleak.h> | 13 | #include <linux/kmemleak.h> |
14 | #include <linux/bitmap.h> | 14 | #include <linux/bitmap.h> |
15 | #include <linux/bootmem.h> | 15 | #include <linux/memblock.h> |
16 | #include <asm/msi_bitmap.h> | 16 | #include <asm/msi_bitmap.h> |
17 | #include <asm/setup.h> | 17 | #include <asm/setup.h> |
18 | 18 | ||
@@ -128,7 +128,7 @@ int __ref msi_bitmap_alloc(struct msi_bitmap *bmp, unsigned int irq_count, | |||
128 | if (bmp->bitmap_from_slab) | 128 | if (bmp->bitmap_from_slab) |
129 | bmp->bitmap = kzalloc(size, GFP_KERNEL); | 129 | bmp->bitmap = kzalloc(size, GFP_KERNEL); |
130 | else { | 130 | else { |
131 | bmp->bitmap = memblock_virt_alloc(size, 0); | 131 | bmp->bitmap = memblock_alloc(size, SMP_CACHE_BYTES); |
132 | /* the bitmap won't be freed from memblock allocator */ | 132 | /* the bitmap won't be freed from memblock allocator */ |
133 | kmemleak_not_leak(bmp->bitmap); | 133 | kmemleak_not_leak(bmp->bitmap); |
134 | } | 134 | } |
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index fe451348ae57..d86842c21710 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig | |||
@@ -28,14 +28,12 @@ config RISCV | |||
28 | select GENERIC_STRNLEN_USER | 28 | select GENERIC_STRNLEN_USER |
29 | select GENERIC_SMP_IDLE_THREAD | 29 | select GENERIC_SMP_IDLE_THREAD |
30 | select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A | 30 | select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A |
31 | select HAVE_MEMBLOCK | ||
32 | select HAVE_MEMBLOCK_NODE_MAP | 31 | select HAVE_MEMBLOCK_NODE_MAP |
33 | select HAVE_DMA_CONTIGUOUS | 32 | select HAVE_DMA_CONTIGUOUS |
34 | select HAVE_FUTEX_CMPXCHG if FUTEX | 33 | select HAVE_FUTEX_CMPXCHG if FUTEX |
35 | select HAVE_GENERIC_DMA_COHERENT | 34 | select HAVE_GENERIC_DMA_COHERENT |
36 | select HAVE_PERF_EVENTS | 35 | select HAVE_PERF_EVENTS |
37 | select IRQ_DOMAIN | 36 | select IRQ_DOMAIN |
38 | select NO_BOOTMEM | ||
39 | select RISCV_ISA_A if SMP | 37 | select RISCV_ISA_A if SMP |
40 | select SPARSE_IRQ | 38 | select SPARSE_IRQ |
41 | select SYSCTL_EXCEPTION_TRACE | 39 | select SYSCTL_EXCEPTION_TRACE |
diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 50de774d827a..0531f49af5c3 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h | |||
@@ -33,12 +33,6 @@ | |||
33 | struct task_struct; | 33 | struct task_struct; |
34 | struct pt_regs; | 34 | struct pt_regs; |
35 | 35 | ||
36 | /* | ||
37 | * Default implementation of macro that returns current | ||
38 | * instruction pointer ("program counter"). | ||
39 | */ | ||
40 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
41 | |||
42 | /* CPU-specific state of a task */ | 36 | /* CPU-specific state of a task */ |
43 | struct thread_struct { | 37 | struct thread_struct { |
44 | /* Callee-saved registers */ | 38 | /* Callee-saved registers */ |
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 58a522f9bcc3..1d9bfaff60bc 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c | |||
@@ -13,9 +13,8 @@ | |||
13 | 13 | ||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/bootmem.h> | ||
17 | #include <linux/initrd.h> | ||
18 | #include <linux/memblock.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/initrd.h> | ||
19 | #include <linux/swap.h> | 18 | #include <linux/swap.h> |
20 | #include <linux/sizes.h> | 19 | #include <linux/sizes.h> |
21 | 20 | ||
@@ -55,7 +54,7 @@ void __init mem_init(void) | |||
55 | #endif /* CONFIG_FLATMEM */ | 54 | #endif /* CONFIG_FLATMEM */ |
56 | 55 | ||
57 | high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); | 56 | high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); |
58 | free_all_bootmem(); | 57 | memblock_free_all(); |
59 | 58 | ||
60 | mem_init_print_info(NULL); | 59 | mem_init_print_info(NULL); |
61 | } | 60 | } |
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 8b25e1f45b27..5173366af8f3 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
@@ -163,7 +163,6 @@ config S390 | |||
163 | select HAVE_LIVEPATCH | 163 | select HAVE_LIVEPATCH |
164 | select HAVE_PERF_REGS | 164 | select HAVE_PERF_REGS |
165 | select HAVE_PERF_USER_STACK_DUMP | 165 | select HAVE_PERF_USER_STACK_DUMP |
166 | select HAVE_MEMBLOCK | ||
167 | select HAVE_MEMBLOCK_NODE_MAP | 166 | select HAVE_MEMBLOCK_NODE_MAP |
168 | select HAVE_MEMBLOCK_PHYS_MAP | 167 | select HAVE_MEMBLOCK_PHYS_MAP |
169 | select HAVE_MOD_ARCH_SPECIFIC | 168 | select HAVE_MOD_ARCH_SPECIFIC |
@@ -175,7 +174,6 @@ config S390 | |||
175 | select HAVE_SYSCALL_TRACEPOINTS | 174 | select HAVE_SYSCALL_TRACEPOINTS |
176 | select HAVE_VIRT_CPU_ACCOUNTING | 175 | select HAVE_VIRT_CPU_ACCOUNTING |
177 | select MODULES_USE_ELF_RELA | 176 | select MODULES_USE_ELF_RELA |
178 | select NO_BOOTMEM | ||
179 | select OLD_SIGACTION | 177 | select OLD_SIGACTION |
180 | select OLD_SIGSUSPEND3 | 178 | select OLD_SIGSUSPEND3 |
181 | select SPARSE_IRQ | 179 | select SPARSE_IRQ |
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h index 34768e6ef4fb..302795c47c06 100644 --- a/arch/s390/include/asm/processor.h +++ b/arch/s390/include/asm/processor.h | |||
@@ -73,12 +73,6 @@ static inline int test_cpu_flag_of(int flag, int cpu) | |||
73 | 73 | ||
74 | #define arch_needs_cpu() test_cpu_flag(CIF_NOHZ_DELAY) | 74 | #define arch_needs_cpu() test_cpu_flag(CIF_NOHZ_DELAY) |
75 | 75 | ||
76 | /* | ||
77 | * Default implementation of macro that returns current | ||
78 | * instruction pointer ("program counter"). | ||
79 | */ | ||
80 | #define current_text_addr() ({ void *pc; asm("basr %0,0" : "=a" (pc)); pc; }) | ||
81 | |||
82 | static inline void get_cpu_id(struct cpuid *ptr) | 76 | static inline void get_cpu_id(struct cpuid *ptr) |
83 | { | 77 | { |
84 | asm volatile("stidp %0" : "=Q" (*ptr)); | 78 | asm volatile("stidp %0" : "=Q" (*ptr)); |
diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index 376f6b6dfb3c..97eae3871868 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c | |||
@@ -13,10 +13,9 @@ | |||
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/gfp.h> | 14 | #include <linux/gfp.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/elf.h> | 17 | #include <linux/elf.h> |
18 | #include <asm/asm-offsets.h> | 18 | #include <asm/asm-offsets.h> |
19 | #include <linux/memblock.h> | ||
20 | #include <asm/os_info.h> | 19 | #include <asm/os_info.h> |
21 | #include <asm/elf.h> | 20 | #include <asm/elf.h> |
22 | #include <asm/ipl.h> | 21 | #include <asm/ipl.h> |
@@ -61,7 +60,7 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu) | |||
61 | { | 60 | { |
62 | struct save_area *sa; | 61 | struct save_area *sa; |
63 | 62 | ||
64 | sa = (void *) memblock_alloc(sizeof(*sa), 8); | 63 | sa = (void *) memblock_phys_alloc(sizeof(*sa), 8); |
65 | if (is_boot_cpu) | 64 | if (is_boot_cpu) |
66 | list_add(&sa->list, &dump_save_areas); | 65 | list_add(&sa->list, &dump_save_areas); |
67 | else | 66 | else |
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index a2e952b66248..72dd23ef771b 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/initrd.h> | 36 | #include <linux/initrd.h> |
37 | #include <linux/bootmem.h> | ||
38 | #include <linux/root_dev.h> | 37 | #include <linux/root_dev.h> |
39 | #include <linux/console.h> | 38 | #include <linux/console.h> |
40 | #include <linux/kernel_stat.h> | 39 | #include <linux/kernel_stat.h> |
@@ -378,7 +377,7 @@ static void __init setup_lowcore(void) | |||
378 | * Setup lowcore for boot cpu | 377 | * Setup lowcore for boot cpu |
379 | */ | 378 | */ |
380 | BUILD_BUG_ON(sizeof(struct lowcore) != LC_PAGES * PAGE_SIZE); | 379 | BUILD_BUG_ON(sizeof(struct lowcore) != LC_PAGES * PAGE_SIZE); |
381 | lc = memblock_virt_alloc_low(sizeof(*lc), sizeof(*lc)); | 380 | lc = memblock_alloc_low(sizeof(*lc), sizeof(*lc)); |
382 | lc->restart_psw.mask = PSW_KERNEL_BITS; | 381 | lc->restart_psw.mask = PSW_KERNEL_BITS; |
383 | lc->restart_psw.addr = (unsigned long) restart_int_handler; | 382 | lc->restart_psw.addr = (unsigned long) restart_int_handler; |
384 | lc->external_new_psw.mask = PSW_KERNEL_BITS | | 383 | lc->external_new_psw.mask = PSW_KERNEL_BITS | |
@@ -422,7 +421,7 @@ static void __init setup_lowcore(void) | |||
422 | * Allocate the global restart stack which is the same for | 421 | * Allocate the global restart stack which is the same for |
423 | * all CPUs in cast *one* of them does a PSW restart. | 422 | * all CPUs in cast *one* of them does a PSW restart. |
424 | */ | 423 | */ |
425 | restart_stack = memblock_virt_alloc(THREAD_SIZE, THREAD_SIZE); | 424 | restart_stack = memblock_alloc(THREAD_SIZE, THREAD_SIZE); |
426 | restart_stack += STACK_INIT_OFFSET; | 425 | restart_stack += STACK_INIT_OFFSET; |
427 | 426 | ||
428 | /* | 427 | /* |
@@ -488,7 +487,7 @@ static void __init setup_resources(void) | |||
488 | bss_resource.end = (unsigned long) __bss_stop - 1; | 487 | bss_resource.end = (unsigned long) __bss_stop - 1; |
489 | 488 | ||
490 | for_each_memblock(memory, reg) { | 489 | for_each_memblock(memory, reg) { |
491 | res = memblock_virt_alloc(sizeof(*res), 8); | 490 | res = memblock_alloc(sizeof(*res), 8); |
492 | res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM; | 491 | res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM; |
493 | 492 | ||
494 | res->name = "System RAM"; | 493 | res->name = "System RAM"; |
@@ -502,7 +501,7 @@ static void __init setup_resources(void) | |||
502 | std_res->start > res->end) | 501 | std_res->start > res->end) |
503 | continue; | 502 | continue; |
504 | if (std_res->end > res->end) { | 503 | if (std_res->end > res->end) { |
505 | sub_res = memblock_virt_alloc(sizeof(*sub_res), 8); | 504 | sub_res = memblock_alloc(sizeof(*sub_res), 8); |
506 | *sub_res = *std_res; | 505 | *sub_res = *std_res; |
507 | sub_res->end = res->end; | 506 | sub_res->end = res->end; |
508 | std_res->start = res->end + 1; | 507 | std_res->start = res->end + 1; |
@@ -967,7 +966,8 @@ static void __init setup_randomness(void) | |||
967 | { | 966 | { |
968 | struct sysinfo_3_2_2 *vmms; | 967 | struct sysinfo_3_2_2 *vmms; |
969 | 968 | ||
970 | vmms = (struct sysinfo_3_2_2 *) memblock_alloc(PAGE_SIZE, PAGE_SIZE); | 969 | vmms = (struct sysinfo_3_2_2 *) memblock_phys_alloc(PAGE_SIZE, |
970 | PAGE_SIZE); | ||
971 | if (stsi(vmms, 3, 2, 2) == 0 && vmms->count) | 971 | if (stsi(vmms, 3, 2, 2) == 0 && vmms->count) |
972 | add_device_randomness(&vmms->vm, sizeof(vmms->vm[0]) * vmms->count); | 972 | add_device_randomness(&vmms->vm, sizeof(vmms->vm[0]) * vmms->count); |
973 | memblock_free((unsigned long) vmms, PAGE_SIZE); | 973 | memblock_free((unsigned long) vmms, PAGE_SIZE); |
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 1b3188f57b58..f82b3d3c36e2 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 20 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
21 | 21 | ||
22 | #include <linux/workqueue.h> | 22 | #include <linux/workqueue.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/export.h> | 24 | #include <linux/export.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/mm.h> | 26 | #include <linux/mm.h> |
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/sched/hotplug.h> | 35 | #include <linux/sched/hotplug.h> |
36 | #include <linux/sched/task_stack.h> | 36 | #include <linux/sched/task_stack.h> |
37 | #include <linux/crash_dump.h> | 37 | #include <linux/crash_dump.h> |
38 | #include <linux/memblock.h> | ||
39 | #include <linux/kprobes.h> | 38 | #include <linux/kprobes.h> |
40 | #include <asm/asm-offsets.h> | 39 | #include <asm/asm-offsets.h> |
41 | #include <asm/diag.h> | 40 | #include <asm/diag.h> |
@@ -761,7 +760,7 @@ void __init smp_detect_cpus(void) | |||
761 | u16 address; | 760 | u16 address; |
762 | 761 | ||
763 | /* Get CPU information */ | 762 | /* Get CPU information */ |
764 | info = memblock_virt_alloc(sizeof(*info), 8); | 763 | info = memblock_alloc(sizeof(*info), 8); |
765 | smp_get_core_info(info, 1); | 764 | smp_get_core_info(info, 1); |
766 | /* Find boot CPU type */ | 765 | /* Find boot CPU type */ |
767 | if (sclp.has_core_type) { | 766 | if (sclp.has_core_type) { |
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index e8184a15578a..8992b04c0ade 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 8 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
9 | 9 | ||
10 | #include <linux/workqueue.h> | 10 | #include <linux/workqueue.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/uaccess.h> | 12 | #include <linux/uaccess.h> |
13 | #include <linux/sysctl.h> | 13 | #include <linux/sysctl.h> |
14 | #include <linux/cpuset.h> | 14 | #include <linux/cpuset.h> |
@@ -519,7 +519,7 @@ static void __init alloc_masks(struct sysinfo_15_1_x *info, | |||
519 | nr_masks *= info->mag[TOPOLOGY_NR_MAG - offset - 1 - i]; | 519 | nr_masks *= info->mag[TOPOLOGY_NR_MAG - offset - 1 - i]; |
520 | nr_masks = max(nr_masks, 1); | 520 | nr_masks = max(nr_masks, 1); |
521 | for (i = 0; i < nr_masks; i++) { | 521 | for (i = 0; i < nr_masks; i++) { |
522 | mask->next = memblock_virt_alloc(sizeof(*mask->next), 8); | 522 | mask->next = memblock_alloc(sizeof(*mask->next), 8); |
523 | mask = mask->next; | 523 | mask = mask->next; |
524 | } | 524 | } |
525 | } | 525 | } |
@@ -537,7 +537,7 @@ void __init topology_init_early(void) | |||
537 | } | 537 | } |
538 | if (!MACHINE_HAS_TOPOLOGY) | 538 | if (!MACHINE_HAS_TOPOLOGY) |
539 | goto out; | 539 | goto out; |
540 | tl_info = memblock_virt_alloc(PAGE_SIZE, PAGE_SIZE); | 540 | tl_info = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
541 | info = tl_info; | 541 | info = tl_info; |
542 | store_topology(info); | 542 | store_topology(info); |
543 | pr_info("The CPU configuration topology of the machine is: %d %d %d %d %d %d / %d\n", | 543 | pr_info("The CPU configuration topology of the machine is: %d %d %d %d %d %d / %d\n", |
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index ec31b48a42a5..ebe748a9f472 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/user.h> | 18 | #include <linux/user.h> |
19 | #include <linux/elf.h> | 19 | #include <linux/elf.h> |
20 | #include <linux/security.h> | 20 | #include <linux/security.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | #include <linux/compat.h> | 22 | #include <linux/compat.h> |
23 | #include <asm/asm-offsets.h> | 23 | #include <asm/asm-offsets.h> |
24 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c index 84111a43ea29..eba2def3414d 100644 --- a/arch/s390/mm/extmem.c +++ b/arch/s390/mm/extmem.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/list.h> | 16 | #include <linux/list.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/export.h> | 18 | #include <linux/export.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/ctype.h> | 20 | #include <linux/ctype.h> |
21 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
22 | #include <asm/diag.h> | 22 | #include <asm/diag.h> |
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 92d7a153e72a..76d0708438e9 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/smp.h> | 21 | #include <linux/smp.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/pagemap.h> | 23 | #include <linux/pagemap.h> |
24 | #include <linux/bootmem.h> | 24 | #include <linux/memblock.h> |
25 | #include <linux/memory.h> | 25 | #include <linux/memory.h> |
26 | #include <linux/pfn.h> | 26 | #include <linux/pfn.h> |
27 | #include <linux/poison.h> | 27 | #include <linux/poison.h> |
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/export.h> | 29 | #include <linux/export.h> |
30 | #include <linux/cma.h> | 30 | #include <linux/cma.h> |
31 | #include <linux/gfp.h> | 31 | #include <linux/gfp.h> |
32 | #include <linux/memblock.h> | ||
33 | #include <asm/processor.h> | 32 | #include <asm/processor.h> |
34 | #include <linux/uaccess.h> | 33 | #include <linux/uaccess.h> |
35 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
@@ -139,7 +138,7 @@ void __init mem_init(void) | |||
139 | cmma_init(); | 138 | cmma_init(); |
140 | 139 | ||
141 | /* this will put all low memory onto the freelists */ | 140 | /* this will put all low memory onto the freelists */ |
142 | free_all_bootmem(); | 141 | memblock_free_all(); |
143 | setup_zero_pages(); /* Setup zeroed pages. */ | 142 | setup_zero_pages(); /* Setup zeroed pages. */ |
144 | 143 | ||
145 | cmma_init_nodat(); | 144 | cmma_init_nodat(); |
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index db55561c5981..0472e27febdf 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c | |||
@@ -4,14 +4,13 @@ | |||
4 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> | 4 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com> |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | #include <linux/pfn.h> | 8 | #include <linux/pfn.h> |
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/list.h> | 11 | #include <linux/list.h> |
12 | #include <linux/hugetlb.h> | 12 | #include <linux/hugetlb.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/memblock.h> | ||
15 | #include <asm/cacheflush.h> | 14 | #include <asm/cacheflush.h> |
16 | #include <asm/pgalloc.h> | 15 | #include <asm/pgalloc.h> |
17 | #include <asm/pgtable.h> | 16 | #include <asm/pgtable.h> |
@@ -36,7 +35,7 @@ static void __ref *vmem_alloc_pages(unsigned int order) | |||
36 | 35 | ||
37 | if (slab_is_available()) | 36 | if (slab_is_available()) |
38 | return (void *)__get_free_pages(GFP_KERNEL, order); | 37 | return (void *)__get_free_pages(GFP_KERNEL, order); |
39 | return (void *) memblock_alloc(size, size); | 38 | return (void *) memblock_phys_alloc(size, size); |
40 | } | 39 | } |
41 | 40 | ||
42 | void *vmem_crst_alloc(unsigned long val) | 41 | void *vmem_crst_alloc(unsigned long val) |
@@ -57,7 +56,7 @@ pte_t __ref *vmem_pte_alloc(void) | |||
57 | if (slab_is_available()) | 56 | if (slab_is_available()) |
58 | pte = (pte_t *) page_table_alloc(&init_mm); | 57 | pte = (pte_t *) page_table_alloc(&init_mm); |
59 | else | 58 | else |
60 | pte = (pte_t *) memblock_alloc(size, size); | 59 | pte = (pte_t *) memblock_phys_alloc(size, size); |
61 | if (!pte) | 60 | if (!pte) |
62 | return NULL; | 61 | return NULL; |
63 | memset64((u64 *)pte, _PAGE_INVALID, PTRS_PER_PTE); | 62 | memset64((u64 *)pte, _PAGE_INVALID, PTRS_PER_PTE); |
diff --git a/arch/s390/numa/mode_emu.c b/arch/s390/numa/mode_emu.c index 83b222c57609..bfba273c32c0 100644 --- a/arch/s390/numa/mode_emu.c +++ b/arch/s390/numa/mode_emu.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/cpumask.h> | 23 | #include <linux/cpumask.h> |
24 | #include <linux/memblock.h> | 24 | #include <linux/memblock.h> |
25 | #include <linux/bootmem.h> | ||
26 | #include <linux/node.h> | 25 | #include <linux/node.h> |
27 | #include <linux/memory.h> | 26 | #include <linux/memory.h> |
28 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
@@ -313,7 +312,7 @@ static void __ref create_core_to_node_map(void) | |||
313 | { | 312 | { |
314 | int i; | 313 | int i; |
315 | 314 | ||
316 | emu_cores = memblock_virt_alloc(sizeof(*emu_cores), 8); | 315 | emu_cores = memblock_alloc(sizeof(*emu_cores), 8); |
317 | for (i = 0; i < ARRAY_SIZE(emu_cores->to_node_id); i++) | 316 | for (i = 0; i < ARRAY_SIZE(emu_cores->to_node_id); i++) |
318 | emu_cores->to_node_id[i] = NODE_ID_FREE; | 317 | emu_cores->to_node_id[i] = NODE_ID_FREE; |
319 | } | 318 | } |
diff --git a/arch/s390/numa/numa.c b/arch/s390/numa/numa.c index 5bd374491f94..ae0d9e889534 100644 --- a/arch/s390/numa/numa.c +++ b/arch/s390/numa/numa.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/mmzone.h> | 14 | #include <linux/mmzone.h> |
15 | #include <linux/cpumask.h> | 15 | #include <linux/cpumask.h> |
16 | #include <linux/bootmem.h> | ||
17 | #include <linux/memblock.h> | 16 | #include <linux/memblock.h> |
18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
19 | #include <linux/node.h> | 18 | #include <linux/node.h> |
@@ -64,7 +63,7 @@ static __init pg_data_t *alloc_node_data(void) | |||
64 | { | 63 | { |
65 | pg_data_t *res; | 64 | pg_data_t *res; |
66 | 65 | ||
67 | res = (pg_data_t *) memblock_alloc(sizeof(pg_data_t), 8); | 66 | res = (pg_data_t *) memblock_phys_alloc(sizeof(pg_data_t), 8); |
68 | memset(res, 0, sizeof(pg_data_t)); | 67 | memset(res, 0, sizeof(pg_data_t)); |
69 | return res; | 68 | return res; |
70 | } | 69 | } |
diff --git a/arch/s390/numa/toptree.c b/arch/s390/numa/toptree.c index 21d1e8a1546d..71a608cd4f61 100644 --- a/arch/s390/numa/toptree.c +++ b/arch/s390/numa/toptree.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/cpumask.h> | 12 | #include <linux/cpumask.h> |
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <linux/list_sort.h> | 14 | #include <linux/list_sort.h> |
@@ -34,7 +34,7 @@ struct toptree __ref *toptree_alloc(int level, int id) | |||
34 | if (slab_is_available()) | 34 | if (slab_is_available()) |
35 | res = kzalloc(sizeof(*res), GFP_KERNEL); | 35 | res = kzalloc(sizeof(*res), GFP_KERNEL); |
36 | else | 36 | else |
37 | res = memblock_virt_alloc(sizeof(*res), 8); | 37 | res = memblock_alloc(sizeof(*res), 8); |
38 | if (!res) | 38 | if (!res) |
39 | return res; | 39 | return res; |
40 | 40 | ||
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 475d786a65b0..f82a4da7adf3 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
@@ -9,9 +9,7 @@ config SUPERH | |||
9 | select CLKDEV_LOOKUP | 9 | select CLKDEV_LOOKUP |
10 | select DMA_DIRECT_OPS | 10 | select DMA_DIRECT_OPS |
11 | select HAVE_IDE if HAS_IOPORT_MAP | 11 | select HAVE_IDE if HAS_IOPORT_MAP |
12 | select HAVE_MEMBLOCK | ||
13 | select HAVE_MEMBLOCK_NODE_MAP | 12 | select HAVE_MEMBLOCK_NODE_MAP |
14 | select NO_BOOTMEM | ||
15 | select ARCH_DISCARD_MEMBLOCK | 13 | select ARCH_DISCARD_MEMBLOCK |
16 | select HAVE_OPROFILE | 14 | select HAVE_OPROFILE |
17 | select HAVE_GENERIC_DMA_COHERENT | 15 | select HAVE_GENERIC_DMA_COHERENT |
diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h index 95100d8a0b7b..0e0ecc0132e3 100644 --- a/arch/sh/include/asm/processor_32.h +++ b/arch/sh/include/asm/processor_32.h | |||
@@ -16,12 +16,6 @@ | |||
16 | #include <asm/types.h> | 16 | #include <asm/types.h> |
17 | #include <asm/hw_breakpoint.h> | 17 | #include <asm/hw_breakpoint.h> |
18 | 18 | ||
19 | /* | ||
20 | * Default implementation of macro that returns current | ||
21 | * instruction pointer ("program counter"). | ||
22 | */ | ||
23 | #define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n.align 2\n1:":"=z" (pc)); pc; }) | ||
24 | |||
25 | /* Core Processor Version Register */ | 19 | /* Core Processor Version Register */ |
26 | #define CCN_PVR 0xff000030 | 20 | #define CCN_PVR 0xff000030 |
27 | #define CCN_CVR 0xff000040 | 21 | #define CCN_CVR 0xff000040 |
diff --git a/arch/sh/include/asm/processor_64.h b/arch/sh/include/asm/processor_64.h index 777a16318aff..f3d7075648d0 100644 --- a/arch/sh/include/asm/processor_64.h +++ b/arch/sh/include/asm/processor_64.h | |||
@@ -19,21 +19,6 @@ | |||
19 | #include <asm/types.h> | 19 | #include <asm/types.h> |
20 | #include <cpu/registers.h> | 20 | #include <cpu/registers.h> |
21 | 21 | ||
22 | /* | ||
23 | * Default implementation of macro that returns current | ||
24 | * instruction pointer ("program counter"). | ||
25 | */ | ||
26 | #define current_text_addr() ({ \ | ||
27 | void *pc; \ | ||
28 | unsigned long long __dummy = 0; \ | ||
29 | __asm__("gettr tr0, %1\n\t" \ | ||
30 | "pta 4, tr0\n\t" \ | ||
31 | "gettr tr0, %0\n\t" \ | ||
32 | "ptabs %1, tr0\n\t" \ | ||
33 | :"=r" (pc), "=r" (__dummy) \ | ||
34 | : "1" (__dummy)); \ | ||
35 | pc; }) | ||
36 | |||
37 | #endif | 22 | #endif |
38 | 23 | ||
39 | /* | 24 | /* |
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 7713c084d040..c8c13c777162 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c | |||
@@ -11,12 +11,11 @@ | |||
11 | #include <linux/swap.h> | 11 | #include <linux/swap.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/proc_fs.h> | 15 | #include <linux/proc_fs.h> |
16 | #include <linux/pagemap.h> | 16 | #include <linux/pagemap.h> |
17 | #include <linux/percpu.h> | 17 | #include <linux/percpu.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/memblock.h> | ||
20 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
21 | #include <linux/export.h> | 20 | #include <linux/export.h> |
22 | #include <asm/mmu_context.h> | 21 | #include <asm/mmu_context.h> |
@@ -128,7 +127,7 @@ static pmd_t * __init one_md_table_init(pud_t *pud) | |||
128 | if (pud_none(*pud)) { | 127 | if (pud_none(*pud)) { |
129 | pmd_t *pmd; | 128 | pmd_t *pmd; |
130 | 129 | ||
131 | pmd = alloc_bootmem_pages(PAGE_SIZE); | 130 | pmd = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
132 | pud_populate(&init_mm, pud, pmd); | 131 | pud_populate(&init_mm, pud, pmd); |
133 | BUG_ON(pmd != pmd_offset(pud, 0)); | 132 | BUG_ON(pmd != pmd_offset(pud, 0)); |
134 | } | 133 | } |
@@ -141,7 +140,7 @@ static pte_t * __init one_page_table_init(pmd_t *pmd) | |||
141 | if (pmd_none(*pmd)) { | 140 | if (pmd_none(*pmd)) { |
142 | pte_t *pte; | 141 | pte_t *pte; |
143 | 142 | ||
144 | pte = alloc_bootmem_pages(PAGE_SIZE); | 143 | pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
145 | pmd_populate_kernel(&init_mm, pmd, pte); | 144 | pmd_populate_kernel(&init_mm, pmd, pte); |
146 | BUG_ON(pte != pte_offset_kernel(pmd, 0)); | 145 | BUG_ON(pte != pte_offset_kernel(pmd, 0)); |
147 | } | 146 | } |
@@ -350,7 +349,7 @@ void __init mem_init(void) | |||
350 | high_memory = max_t(void *, high_memory, | 349 | high_memory = max_t(void *, high_memory, |
351 | __va(pgdat_end_pfn(pgdat) << PAGE_SHIFT)); | 350 | __va(pgdat_end_pfn(pgdat) << PAGE_SHIFT)); |
352 | 351 | ||
353 | free_all_bootmem(); | 352 | memblock_free_all(); |
354 | 353 | ||
355 | /* Set this up early, so we can take care of the zero page */ | 354 | /* Set this up early, so we can take care of the zero page */ |
356 | cpu_cache_init(); | 355 | cpu_cache_init(); |
diff --git a/arch/sh/mm/ioremap_fixed.c b/arch/sh/mm/ioremap_fixed.c index 927a1294c465..07e744d75fa0 100644 --- a/arch/sh/mm/ioremap_fixed.c +++ b/arch/sh/mm/ioremap_fixed.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/bootmem.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/proc_fs.h> | 18 | #include <linux/proc_fs.h> |
19 | #include <asm/fixmap.h> | 19 | #include <asm/fixmap.h> |
20 | #include <asm/page.h> | 20 | #include <asm/page.h> |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 7e2aa59fcc29..490b2c95c212 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
@@ -45,8 +45,6 @@ config SPARC | |||
45 | select LOCKDEP_SMALL if LOCKDEP | 45 | select LOCKDEP_SMALL if LOCKDEP |
46 | select NEED_DMA_MAP_STATE | 46 | select NEED_DMA_MAP_STATE |
47 | select NEED_SG_DMA_LENGTH | 47 | select NEED_SG_DMA_LENGTH |
48 | select HAVE_MEMBLOCK | ||
49 | select NO_BOOTMEM | ||
50 | 48 | ||
51 | config SPARC32 | 49 | config SPARC32 |
52 | def_bool !64BIT | 50 | def_bool !64BIT |
diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h index 192493c257fa..3c4bc2189092 100644 --- a/arch/sparc/include/asm/processor_32.h +++ b/arch/sparc/include/asm/processor_32.h | |||
@@ -7,12 +7,6 @@ | |||
7 | #ifndef __ASM_SPARC_PROCESSOR_H | 7 | #ifndef __ASM_SPARC_PROCESSOR_H |
8 | #define __ASM_SPARC_PROCESSOR_H | 8 | #define __ASM_SPARC_PROCESSOR_H |
9 | 9 | ||
10 | /* | ||
11 | * Sparc32 implementation of macro that returns current | ||
12 | * instruction pointer ("program counter"). | ||
13 | */ | ||
14 | #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; }) | ||
15 | |||
16 | #include <asm/psr.h> | 10 | #include <asm/psr.h> |
17 | #include <asm/ptrace.h> | 11 | #include <asm/ptrace.h> |
18 | #include <asm/head.h> | 12 | #include <asm/head.h> |
diff --git a/arch/sparc/include/asm/processor_64.h b/arch/sparc/include/asm/processor_64.h index aac23d4a4ddd..5cf145f18f36 100644 --- a/arch/sparc/include/asm/processor_64.h +++ b/arch/sparc/include/asm/processor_64.h | |||
@@ -8,12 +8,6 @@ | |||
8 | #ifndef __ASM_SPARC64_PROCESSOR_H | 8 | #ifndef __ASM_SPARC64_PROCESSOR_H |
9 | #define __ASM_SPARC64_PROCESSOR_H | 9 | #define __ASM_SPARC64_PROCESSOR_H |
10 | 10 | ||
11 | /* | ||
12 | * Sparc64 implementation of macro that returns current | ||
13 | * instruction pointer ("program counter"). | ||
14 | */ | ||
15 | #define current_text_addr() ({ void *pc; __asm__("rd %%pc, %0" : "=r" (pc)); pc; }) | ||
16 | |||
17 | #include <asm/asi.h> | 11 | #include <asm/asi.h> |
18 | #include <asm/pstate.h> | 12 | #include <asm/pstate.h> |
19 | #include <asm/ptrace.h> | 13 | #include <asm/ptrace.h> |
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c index 39a2503fa3e1..9a26b442f820 100644 --- a/arch/sparc/kernel/mdesc.c +++ b/arch/sparc/kernel/mdesc.c | |||
@@ -5,13 +5,12 @@ | |||
5 | */ | 5 | */ |
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
8 | #include <linux/memblock.h> | ||
9 | #include <linux/log2.h> | 8 | #include <linux/log2.h> |
10 | #include <linux/list.h> | 9 | #include <linux/list.h> |
11 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
12 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
13 | #include <linux/miscdevice.h> | 12 | #include <linux/miscdevice.h> |
14 | #include <linux/bootmem.h> | 13 | #include <linux/memblock.h> |
15 | #include <linux/export.h> | 14 | #include <linux/export.h> |
16 | #include <linux/refcount.h> | 15 | #include <linux/refcount.h> |
17 | 16 | ||
@@ -170,7 +169,7 @@ static struct mdesc_handle * __init mdesc_memblock_alloc(unsigned int mdesc_size | |||
170 | mdesc_size); | 169 | mdesc_size); |
171 | alloc_size = PAGE_ALIGN(handle_size); | 170 | alloc_size = PAGE_ALIGN(handle_size); |
172 | 171 | ||
173 | paddr = memblock_alloc(alloc_size, PAGE_SIZE); | 172 | paddr = memblock_phys_alloc(alloc_size, PAGE_SIZE); |
174 | 173 | ||
175 | hp = NULL; | 174 | hp = NULL; |
176 | if (paddr) { | 175 | if (paddr) { |
@@ -190,7 +189,7 @@ static void __init mdesc_memblock_free(struct mdesc_handle *hp) | |||
190 | 189 | ||
191 | alloc_size = PAGE_ALIGN(hp->handle_size); | 190 | alloc_size = PAGE_ALIGN(hp->handle_size); |
192 | start = __pa(hp); | 191 | start = __pa(hp); |
193 | free_bootmem_late(start, alloc_size); | 192 | memblock_free_late(start, alloc_size); |
194 | } | 193 | } |
195 | 194 | ||
196 | static struct mdesc_mem_ops memblock_mdesc_ops = { | 195 | static struct mdesc_mem_ops memblock_mdesc_ops = { |
diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c index b51cbb9e87dc..d41e2a749c5d 100644 --- a/arch/sparc/kernel/prom_32.c +++ b/arch/sparc/kernel/prom_32.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | 23 | ||
24 | #include <asm/prom.h> | 24 | #include <asm/prom.h> |
25 | #include <asm/oplib.h> | 25 | #include <asm/oplib.h> |
@@ -32,7 +32,7 @@ void * __init prom_early_alloc(unsigned long size) | |||
32 | { | 32 | { |
33 | void *ret; | 33 | void *ret; |
34 | 34 | ||
35 | ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); | 35 | ret = memblock_alloc_from(size, SMP_CACHE_BYTES, 0UL); |
36 | if (ret != NULL) | 36 | if (ret != NULL) |
37 | memset(ret, 0, size); | 37 | memset(ret, 0, size); |
38 | 38 | ||
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c index baeaeed64993..c37955d127fe 100644 --- a/arch/sparc/kernel/prom_64.c +++ b/arch/sparc/kernel/prom_64.c | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | void * __init prom_early_alloc(unsigned long size) | 35 | void * __init prom_early_alloc(unsigned long size) |
36 | { | 36 | { |
37 | unsigned long paddr = memblock_alloc(size, SMP_CACHE_BYTES); | 37 | unsigned long paddr = memblock_phys_alloc(size, SMP_CACHE_BYTES); |
38 | void *ret; | 38 | void *ret; |
39 | 39 | ||
40 | if (!paddr) { | 40 | if (!paddr) { |
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c index 7944b3ca216a..cd2825cb8420 100644 --- a/arch/sparc/kernel/setup_64.c +++ b/arch/sparc/kernel/setup_64.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/initrd.h> | 32 | #include <linux/initrd.h> |
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/start_kernel.h> | 34 | #include <linux/start_kernel.h> |
35 | #include <linux/bootmem.h> | 35 | #include <linux/memblock.h> |
36 | 36 | ||
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | #include <asm/processor.h> | 38 | #include <asm/processor.h> |
@@ -621,12 +621,10 @@ void __init alloc_irqstack_bootmem(void) | |||
621 | for_each_possible_cpu(i) { | 621 | for_each_possible_cpu(i) { |
622 | node = cpu_to_node(i); | 622 | node = cpu_to_node(i); |
623 | 623 | ||
624 | softirq_stack[i] = __alloc_bootmem_node(NODE_DATA(node), | 624 | softirq_stack[i] = memblock_alloc_node(THREAD_SIZE, |
625 | THREAD_SIZE, | 625 | THREAD_SIZE, node); |
626 | THREAD_SIZE, 0); | 626 | hardirq_stack[i] = memblock_alloc_node(THREAD_SIZE, |
627 | hardirq_stack[i] = __alloc_bootmem_node(NODE_DATA(node), | 627 | THREAD_SIZE, node); |
628 | THREAD_SIZE, | ||
629 | THREAD_SIZE, 0); | ||
630 | } | 628 | } |
631 | } | 629 | } |
632 | 630 | ||
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index d3ea1f3c06a0..4792e08ad36b 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/cache.h> | 22 | #include <linux/cache.h> |
23 | #include <linux/jiffies.h> | 23 | #include <linux/jiffies.h> |
24 | #include <linux/profile.h> | 24 | #include <linux/profile.h> |
25 | #include <linux/bootmem.h> | 25 | #include <linux/memblock.h> |
26 | #include <linux/vmalloc.h> | 26 | #include <linux/vmalloc.h> |
27 | #include <linux/ftrace.h> | 27 | #include <linux/ftrace.h> |
28 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
@@ -1588,26 +1588,26 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size, | |||
1588 | void *ptr; | 1588 | void *ptr; |
1589 | 1589 | ||
1590 | if (!node_online(node) || !NODE_DATA(node)) { | 1590 | if (!node_online(node) || !NODE_DATA(node)) { |
1591 | ptr = __alloc_bootmem(size, align, goal); | 1591 | ptr = memblock_alloc_from(size, align, goal); |
1592 | pr_info("cpu %d has no node %d or node-local memory\n", | 1592 | pr_info("cpu %d has no node %d or node-local memory\n", |
1593 | cpu, node); | 1593 | cpu, node); |
1594 | pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n", | 1594 | pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n", |
1595 | cpu, size, __pa(ptr)); | 1595 | cpu, size, __pa(ptr)); |
1596 | } else { | 1596 | } else { |
1597 | ptr = __alloc_bootmem_node(NODE_DATA(node), | 1597 | ptr = memblock_alloc_try_nid(size, align, goal, |
1598 | size, align, goal); | 1598 | MEMBLOCK_ALLOC_ACCESSIBLE, node); |
1599 | pr_debug("per cpu data for cpu%d %lu bytes on node%d at " | 1599 | pr_debug("per cpu data for cpu%d %lu bytes on node%d at " |
1600 | "%016lx\n", cpu, size, node, __pa(ptr)); | 1600 | "%016lx\n", cpu, size, node, __pa(ptr)); |
1601 | } | 1601 | } |
1602 | return ptr; | 1602 | return ptr; |
1603 | #else | 1603 | #else |
1604 | return __alloc_bootmem(size, align, goal); | 1604 | return memblock_alloc_from(size, align, goal); |
1605 | #endif | 1605 | #endif |
1606 | } | 1606 | } |
1607 | 1607 | ||
1608 | static void __init pcpu_free_bootmem(void *ptr, size_t size) | 1608 | static void __init pcpu_free_bootmem(void *ptr, size_t size) |
1609 | { | 1609 | { |
1610 | free_bootmem(__pa(ptr), size); | 1610 | memblock_free(__pa(ptr), size); |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) | 1613 | static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) |
@@ -1627,7 +1627,7 @@ static void __init pcpu_populate_pte(unsigned long addr) | |||
1627 | if (pgd_none(*pgd)) { | 1627 | if (pgd_none(*pgd)) { |
1628 | pud_t *new; | 1628 | pud_t *new; |
1629 | 1629 | ||
1630 | new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); | 1630 | new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); |
1631 | pgd_populate(&init_mm, pgd, new); | 1631 | pgd_populate(&init_mm, pgd, new); |
1632 | } | 1632 | } |
1633 | 1633 | ||
@@ -1635,7 +1635,7 @@ static void __init pcpu_populate_pte(unsigned long addr) | |||
1635 | if (pud_none(*pud)) { | 1635 | if (pud_none(*pud)) { |
1636 | pmd_t *new; | 1636 | pmd_t *new; |
1637 | 1637 | ||
1638 | new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); | 1638 | new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); |
1639 | pud_populate(&init_mm, pud, new); | 1639 | pud_populate(&init_mm, pud, new); |
1640 | } | 1640 | } |
1641 | 1641 | ||
@@ -1643,7 +1643,7 @@ static void __init pcpu_populate_pte(unsigned long addr) | |||
1643 | if (!pmd_present(*pmd)) { | 1643 | if (!pmd_present(*pmd)) { |
1644 | pte_t *new; | 1644 | pte_t *new; |
1645 | 1645 | ||
1646 | new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); | 1646 | new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); |
1647 | pmd_populate_kernel(&init_mm, pmd, new); | 1647 | pmd_populate_kernel(&init_mm, pmd, new); |
1648 | } | 1648 | } |
1649 | } | 1649 | } |
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index 92634d4e440c..d900952bfc5f 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/initrd.h> | 22 | #include <linux/initrd.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/highmem.h> | 24 | #include <linux/highmem.h> |
25 | #include <linux/bootmem.h> | ||
26 | #include <linux/memblock.h> | 25 | #include <linux/memblock.h> |
27 | #include <linux/pagemap.h> | 26 | #include <linux/pagemap.h> |
28 | #include <linux/poison.h> | 27 | #include <linux/poison.h> |
@@ -265,7 +264,7 @@ void __init mem_init(void) | |||
265 | i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5); | 264 | i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5); |
266 | i += 1; | 265 | i += 1; |
267 | sparc_valid_addr_bitmap = (unsigned long *) | 266 | sparc_valid_addr_bitmap = (unsigned long *) |
268 | __alloc_bootmem(i << 2, SMP_CACHE_BYTES, 0UL); | 267 | memblock_alloc_from(i << 2, SMP_CACHE_BYTES, 0UL); |
269 | 268 | ||
270 | if (sparc_valid_addr_bitmap == NULL) { | 269 | if (sparc_valid_addr_bitmap == NULL) { |
271 | prom_printf("mem_init: Cannot alloc valid_addr_bitmap.\n"); | 270 | prom_printf("mem_init: Cannot alloc valid_addr_bitmap.\n"); |
@@ -277,7 +276,7 @@ void __init mem_init(void) | |||
277 | 276 | ||
278 | max_mapnr = last_valid_pfn - pfn_base; | 277 | max_mapnr = last_valid_pfn - pfn_base; |
279 | high_memory = __va(max_low_pfn << PAGE_SHIFT); | 278 | high_memory = __va(max_low_pfn << PAGE_SHIFT); |
280 | free_all_bootmem(); | 279 | memblock_free_all(); |
281 | 280 | ||
282 | for (i = 0; sp_banks[i].num_bytes != 0; i++) { | 281 | for (i = 0; sp_banks[i].num_bytes != 0; i++) { |
283 | unsigned long start_pfn = sp_banks[i].base_addr >> PAGE_SHIFT; | 282 | unsigned long start_pfn = sp_banks[i].base_addr >> PAGE_SHIFT; |
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 39822f611c01..3c8aac21f426 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/string.h> | 12 | #include <linux/string.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
16 | #include <linux/hugetlb.h> | 16 | #include <linux/hugetlb.h> |
17 | #include <linux/initrd.h> | 17 | #include <linux/initrd.h> |
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/sort.h> | 25 | #include <linux/sort.h> |
26 | #include <linux/ioport.h> | 26 | #include <linux/ioport.h> |
27 | #include <linux/percpu.h> | 27 | #include <linux/percpu.h> |
28 | #include <linux/memblock.h> | ||
29 | #include <linux/mmzone.h> | 28 | #include <linux/mmzone.h> |
30 | #include <linux/gfp.h> | 29 | #include <linux/gfp.h> |
31 | 30 | ||
@@ -1092,7 +1091,8 @@ static void __init allocate_node_data(int nid) | |||
1092 | #ifdef CONFIG_NEED_MULTIPLE_NODES | 1091 | #ifdef CONFIG_NEED_MULTIPLE_NODES |
1093 | unsigned long paddr; | 1092 | unsigned long paddr; |
1094 | 1093 | ||
1095 | paddr = memblock_alloc_try_nid(sizeof(struct pglist_data), SMP_CACHE_BYTES, nid); | 1094 | paddr = memblock_phys_alloc_try_nid(sizeof(struct pglist_data), |
1095 | SMP_CACHE_BYTES, nid); | ||
1096 | if (!paddr) { | 1096 | if (!paddr) { |
1097 | prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); | 1097 | prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); |
1098 | prom_halt(); | 1098 | prom_halt(); |
@@ -1266,8 +1266,8 @@ static int __init grab_mlgroups(struct mdesc_handle *md) | |||
1266 | if (!count) | 1266 | if (!count) |
1267 | return -ENOENT; | 1267 | return -ENOENT; |
1268 | 1268 | ||
1269 | paddr = memblock_alloc(count * sizeof(struct mdesc_mlgroup), | 1269 | paddr = memblock_phys_alloc(count * sizeof(struct mdesc_mlgroup), |
1270 | SMP_CACHE_BYTES); | 1270 | SMP_CACHE_BYTES); |
1271 | if (!paddr) | 1271 | if (!paddr) |
1272 | return -ENOMEM; | 1272 | return -ENOMEM; |
1273 | 1273 | ||
@@ -1307,8 +1307,8 @@ static int __init grab_mblocks(struct mdesc_handle *md) | |||
1307 | if (!count) | 1307 | if (!count) |
1308 | return -ENOENT; | 1308 | return -ENOENT; |
1309 | 1309 | ||
1310 | paddr = memblock_alloc(count * sizeof(struct mdesc_mblock), | 1310 | paddr = memblock_phys_alloc(count * sizeof(struct mdesc_mblock), |
1311 | SMP_CACHE_BYTES); | 1311 | SMP_CACHE_BYTES); |
1312 | if (!paddr) | 1312 | if (!paddr) |
1313 | return -ENOMEM; | 1313 | return -ENOMEM; |
1314 | 1314 | ||
@@ -1810,7 +1810,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, | |||
1810 | if (pgd_none(*pgd)) { | 1810 | if (pgd_none(*pgd)) { |
1811 | pud_t *new; | 1811 | pud_t *new; |
1812 | 1812 | ||
1813 | new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); | 1813 | new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, |
1814 | PAGE_SIZE); | ||
1814 | alloc_bytes += PAGE_SIZE; | 1815 | alloc_bytes += PAGE_SIZE; |
1815 | pgd_populate(&init_mm, pgd, new); | 1816 | pgd_populate(&init_mm, pgd, new); |
1816 | } | 1817 | } |
@@ -1822,7 +1823,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, | |||
1822 | vstart = kernel_map_hugepud(vstart, vend, pud); | 1823 | vstart = kernel_map_hugepud(vstart, vend, pud); |
1823 | continue; | 1824 | continue; |
1824 | } | 1825 | } |
1825 | new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); | 1826 | new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, |
1827 | PAGE_SIZE); | ||
1826 | alloc_bytes += PAGE_SIZE; | 1828 | alloc_bytes += PAGE_SIZE; |
1827 | pud_populate(&init_mm, pud, new); | 1829 | pud_populate(&init_mm, pud, new); |
1828 | } | 1830 | } |
@@ -1835,7 +1837,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, | |||
1835 | vstart = kernel_map_hugepmd(vstart, vend, pmd); | 1837 | vstart = kernel_map_hugepmd(vstart, vend, pmd); |
1836 | continue; | 1838 | continue; |
1837 | } | 1839 | } |
1838 | new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE); | 1840 | new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, |
1841 | PAGE_SIZE); | ||
1839 | alloc_bytes += PAGE_SIZE; | 1842 | alloc_bytes += PAGE_SIZE; |
1840 | pmd_populate_kernel(&init_mm, pmd, new); | 1843 | pmd_populate_kernel(&init_mm, pmd, new); |
1841 | } | 1844 | } |
@@ -2541,12 +2544,12 @@ void __init mem_init(void) | |||
2541 | { | 2544 | { |
2542 | high_memory = __va(last_valid_pfn << PAGE_SHIFT); | 2545 | high_memory = __va(last_valid_pfn << PAGE_SHIFT); |
2543 | 2546 | ||
2544 | free_all_bootmem(); | 2547 | memblock_free_all(); |
2545 | 2548 | ||
2546 | /* | 2549 | /* |
2547 | * Must be done after boot memory is put on freelist, because here we | 2550 | * Must be done after boot memory is put on freelist, because here we |
2548 | * might set fields in deferred struct pages that have not yet been | 2551 | * might set fields in deferred struct pages that have not yet been |
2549 | * initialized, and free_all_bootmem() initializes all the reserved | 2552 | * initialized, and memblock_free_all() initializes all the reserved |
2550 | * deferred pages for us. | 2553 | * deferred pages for us. |
2551 | */ | 2554 | */ |
2552 | register_page_bootmem_info(); | 2555 | register_page_bootmem_info(); |
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index be9cb0065179..a6142c5abf61 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/seq_file.h> | 12 | #include <linux/seq_file.h> |
13 | #include <linux/spinlock.h> | 13 | #include <linux/spinlock.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/pagemap.h> | 15 | #include <linux/pagemap.h> |
16 | #include <linux/vmalloc.h> | 16 | #include <linux/vmalloc.h> |
17 | #include <linux/kdebug.h> | 17 | #include <linux/kdebug.h> |
@@ -303,13 +303,13 @@ static void __init srmmu_nocache_init(void) | |||
303 | 303 | ||
304 | bitmap_bits = srmmu_nocache_size >> SRMMU_NOCACHE_BITMAP_SHIFT; | 304 | bitmap_bits = srmmu_nocache_size >> SRMMU_NOCACHE_BITMAP_SHIFT; |
305 | 305 | ||
306 | srmmu_nocache_pool = __alloc_bootmem(srmmu_nocache_size, | 306 | srmmu_nocache_pool = memblock_alloc_from(srmmu_nocache_size, |
307 | SRMMU_NOCACHE_ALIGN_MAX, 0UL); | 307 | SRMMU_NOCACHE_ALIGN_MAX, 0UL); |
308 | memset(srmmu_nocache_pool, 0, srmmu_nocache_size); | 308 | memset(srmmu_nocache_pool, 0, srmmu_nocache_size); |
309 | 309 | ||
310 | srmmu_nocache_bitmap = | 310 | srmmu_nocache_bitmap = |
311 | __alloc_bootmem(BITS_TO_LONGS(bitmap_bits) * sizeof(long), | 311 | memblock_alloc_from(BITS_TO_LONGS(bitmap_bits) * sizeof(long), |
312 | SMP_CACHE_BYTES, 0UL); | 312 | SMP_CACHE_BYTES, 0UL); |
313 | bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); | 313 | bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); |
314 | 314 | ||
315 | srmmu_swapper_pg_dir = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE); | 315 | srmmu_swapper_pg_dir = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE); |
@@ -467,7 +467,7 @@ static void __init sparc_context_init(int numctx) | |||
467 | unsigned long size; | 467 | unsigned long size; |
468 | 468 | ||
469 | size = numctx * sizeof(struct ctx_list); | 469 | size = numctx * sizeof(struct ctx_list); |
470 | ctx_list_pool = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL); | 470 | ctx_list_pool = memblock_alloc_from(size, SMP_CACHE_BYTES, 0UL); |
471 | 471 | ||
472 | for (ctx = 0; ctx < numctx; ctx++) { | 472 | for (ctx = 0; ctx < numctx; ctx++) { |
473 | struct ctx_list *clist; | 473 | struct ctx_list *clist; |
diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 10c15b8853ae..6b9938919f0b 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig | |||
@@ -12,8 +12,6 @@ config UML | |||
12 | select HAVE_UID16 | 12 | select HAVE_UID16 |
13 | select HAVE_FUTEX_CMPXCHG if FUTEX | 13 | select HAVE_FUTEX_CMPXCHG if FUTEX |
14 | select HAVE_DEBUG_KMEMLEAK | 14 | select HAVE_DEBUG_KMEMLEAK |
15 | select HAVE_MEMBLOCK | ||
16 | select NO_BOOTMEM | ||
17 | select GENERIC_IRQ_SHOW | 15 | select GENERIC_IRQ_SHOW |
18 | select GENERIC_CPU_DEVICES | 16 | select GENERIC_CPU_DEVICES |
19 | select GENERIC_CLOCKEVENTS | 17 | select GENERIC_CLOCKEVENTS |
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 3ef1b48e064a..624cb47cc9cd 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Licensed under the GPL. | 6 | * Licensed under the GPL. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/bootmem.h> | 9 | #include <linux/memblock.h> |
10 | #include <linux/etherdevice.h> | 10 | #include <linux/etherdevice.h> |
11 | #include <linux/ethtool.h> | 11 | #include <linux/ethtool.h> |
12 | #include <linux/inetdevice.h> | 12 | #include <linux/inetdevice.h> |
@@ -650,7 +650,7 @@ static int __init eth_setup(char *str) | |||
650 | return 1; | 650 | return 1; |
651 | } | 651 | } |
652 | 652 | ||
653 | new = alloc_bootmem(sizeof(*new)); | 653 | new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES); |
654 | 654 | ||
655 | INIT_LIST_HEAD(&new->list); | 655 | INIT_LIST_HEAD(&new->list); |
656 | new->index = n; | 656 | new->index = n; |
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index 50ee3bb5a63a..10d8d20eb9ec 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c | |||
@@ -9,7 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/version.h> | 11 | #include <linux/version.h> |
12 | #include <linux/bootmem.h> | 12 | #include <linux/memblock.h> |
13 | #include <linux/etherdevice.h> | 13 | #include <linux/etherdevice.h> |
14 | #include <linux/ethtool.h> | 14 | #include <linux/ethtool.h> |
15 | #include <linux/inetdevice.h> | 15 | #include <linux/inetdevice.h> |
@@ -1580,7 +1580,7 @@ static int __init vector_setup(char *str) | |||
1580 | str, error); | 1580 | str, error); |
1581 | return 1; | 1581 | return 1; |
1582 | } | 1582 | } |
1583 | new = alloc_bootmem(sizeof(*new)); | 1583 | new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES); |
1584 | INIT_LIST_HEAD(&new->list); | 1584 | INIT_LIST_HEAD(&new->list); |
1585 | new->unit = n; | 1585 | new->unit = n; |
1586 | new->arguments = str; | 1586 | new->arguments = str; |
diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c index 6f6e7896e53f..ce169ea87e61 100644 --- a/arch/um/kernel/initrd.c +++ b/arch/um/kernel/initrd.c | |||
@@ -4,7 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | #include <linux/initrd.h> | 8 | #include <linux/initrd.h> |
9 | #include <asm/types.h> | 9 | #include <asm/types.h> |
10 | #include <init.h> | 10 | #include <init.h> |
@@ -36,7 +36,7 @@ int __init read_initrd(void) | |||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | area = alloc_bootmem(size); | 39 | area = memblock_alloc(size, SMP_CACHE_BYTES); |
40 | 40 | ||
41 | if (load_initrd(initrd, area, size) == -1) | 41 | if (load_initrd(initrd, area, size) == -1) |
42 | return 0; | 42 | return 0; |
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 3c0e470ea646..1067469ba2ea 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | #include <linux/stddef.h> | 6 | #include <linux/stddef.h> |
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/highmem.h> | 9 | #include <linux/highmem.h> |
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
11 | #include <linux/swap.h> | 11 | #include <linux/swap.h> |
@@ -46,11 +46,11 @@ void __init mem_init(void) | |||
46 | */ | 46 | */ |
47 | brk_end = (unsigned long) UML_ROUND_UP(sbrk(0)); | 47 | brk_end = (unsigned long) UML_ROUND_UP(sbrk(0)); |
48 | map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0); | 48 | map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0); |
49 | free_bootmem(__pa(brk_end), uml_reserved - brk_end); | 49 | memblock_free(__pa(brk_end), uml_reserved - brk_end); |
50 | uml_reserved = brk_end; | 50 | uml_reserved = brk_end; |
51 | 51 | ||
52 | /* this will put all low memory onto the freelists */ | 52 | /* this will put all low memory onto the freelists */ |
53 | free_all_bootmem(); | 53 | memblock_free_all(); |
54 | max_low_pfn = totalram_pages; | 54 | max_low_pfn = totalram_pages; |
55 | max_pfn = totalram_pages; | 55 | max_pfn = totalram_pages; |
56 | mem_init_print_info(NULL); | 56 | mem_init_print_info(NULL); |
@@ -64,7 +64,8 @@ void __init mem_init(void) | |||
64 | static void __init one_page_table_init(pmd_t *pmd) | 64 | static void __init one_page_table_init(pmd_t *pmd) |
65 | { | 65 | { |
66 | if (pmd_none(*pmd)) { | 66 | if (pmd_none(*pmd)) { |
67 | pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); | 67 | pte_t *pte = (pte_t *) memblock_alloc_low(PAGE_SIZE, |
68 | PAGE_SIZE); | ||
68 | set_pmd(pmd, __pmd(_KERNPG_TABLE + | 69 | set_pmd(pmd, __pmd(_KERNPG_TABLE + |
69 | (unsigned long) __pa(pte))); | 70 | (unsigned long) __pa(pte))); |
70 | if (pte != pte_offset_kernel(pmd, 0)) | 71 | if (pte != pte_offset_kernel(pmd, 0)) |
@@ -75,7 +76,7 @@ static void __init one_page_table_init(pmd_t *pmd) | |||
75 | static void __init one_md_table_init(pud_t *pud) | 76 | static void __init one_md_table_init(pud_t *pud) |
76 | { | 77 | { |
77 | #ifdef CONFIG_3_LEVEL_PGTABLES | 78 | #ifdef CONFIG_3_LEVEL_PGTABLES |
78 | pmd_t *pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE); | 79 | pmd_t *pmd_table = (pmd_t *) memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); |
79 | set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table))); | 80 | set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table))); |
80 | if (pmd_table != pmd_offset(pud, 0)) | 81 | if (pmd_table != pmd_offset(pud, 0)) |
81 | BUG(); | 82 | BUG(); |
@@ -124,7 +125,7 @@ static void __init fixaddr_user_init( void) | |||
124 | return; | 125 | return; |
125 | 126 | ||
126 | fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir); | 127 | fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir); |
127 | v = (unsigned long) alloc_bootmem_low_pages(size); | 128 | v = (unsigned long) memblock_alloc_low(size, PAGE_SIZE); |
128 | memcpy((void *) v , (void *) FIXADDR_USER_START, size); | 129 | memcpy((void *) v , (void *) FIXADDR_USER_START, size); |
129 | p = __pa(v); | 130 | p = __pa(v); |
130 | for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE, | 131 | for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE, |
@@ -143,7 +144,8 @@ void __init paging_init(void) | |||
143 | unsigned long zones_size[MAX_NR_ZONES], vaddr; | 144 | unsigned long zones_size[MAX_NR_ZONES], vaddr; |
144 | int i; | 145 | int i; |
145 | 146 | ||
146 | empty_zero_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE); | 147 | empty_zero_page = (unsigned long *) memblock_alloc_low(PAGE_SIZE, |
148 | PAGE_SIZE); | ||
147 | for (i = 0; i < ARRAY_SIZE(zones_size); i++) | 149 | for (i = 0; i < ARRAY_SIZE(zones_size); i++) |
148 | zones_size[i] = 0; | 150 | zones_size[i] = 0; |
149 | 151 | ||
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index 296a91a04598..5bf56af4d5b9 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c | |||
@@ -4,7 +4,6 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/bootmem.h> | ||
8 | #include <linux/memblock.h> | 7 | #include <linux/memblock.h> |
9 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
10 | #include <linux/pfn.h> | 9 | #include <linux/pfn.h> |
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig index 0c5111b206bd..a4c05159dca5 100644 --- a/arch/unicore32/Kconfig +++ b/arch/unicore32/Kconfig | |||
@@ -5,8 +5,6 @@ config UNICORE32 | |||
5 | select ARCH_MIGHT_HAVE_PC_PARPORT | 5 | select ARCH_MIGHT_HAVE_PC_PARPORT |
6 | select ARCH_MIGHT_HAVE_PC_SERIO | 6 | select ARCH_MIGHT_HAVE_PC_SERIO |
7 | select DMA_DIRECT_OPS | 7 | select DMA_DIRECT_OPS |
8 | select HAVE_MEMBLOCK | ||
9 | select NO_BOOTMEM | ||
10 | select HAVE_GENERIC_DMA_COHERENT | 8 | select HAVE_GENERIC_DMA_COHERENT |
11 | select HAVE_KERNEL_GZIP | 9 | select HAVE_KERNEL_GZIP |
12 | select HAVE_KERNEL_BZIP2 | 10 | select HAVE_KERNEL_BZIP2 |
diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h index 4eaa42167667..b772ed1c0f25 100644 --- a/arch/unicore32/include/asm/processor.h +++ b/arch/unicore32/include/asm/processor.h | |||
@@ -13,12 +13,6 @@ | |||
13 | #ifndef __UNICORE_PROCESSOR_H__ | 13 | #ifndef __UNICORE_PROCESSOR_H__ |
14 | #define __UNICORE_PROCESSOR_H__ | 14 | #define __UNICORE_PROCESSOR_H__ |
15 | 15 | ||
16 | /* | ||
17 | * Default implementation of macro that returns current | ||
18 | * instruction pointer ("program counter"). | ||
19 | */ | ||
20 | #define current_text_addr() ({ __label__ _l; _l: &&_l; }) | ||
21 | |||
22 | #ifdef __KERNEL__ | 16 | #ifdef __KERNEL__ |
23 | 17 | ||
24 | #include <asm/ptrace.h> | 18 | #include <asm/ptrace.h> |
diff --git a/arch/unicore32/kernel/hibernate.c b/arch/unicore32/kernel/hibernate.c index 9969ec374abb..29b71c68eb7c 100644 --- a/arch/unicore32/kernel/hibernate.c +++ b/arch/unicore32/kernel/hibernate.c | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/gfp.h> | 14 | #include <linux/gfp.h> |
15 | #include <linux/suspend.h> | 15 | #include <linux/suspend.h> |
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | 17 | ||
18 | #include <asm/page.h> | 18 | #include <asm/page.h> |
19 | #include <asm/pgtable.h> | 19 | #include <asm/pgtable.h> |
diff --git a/arch/unicore32/kernel/setup.c b/arch/unicore32/kernel/setup.c index c2bffa5614a4..4b0cb68c355a 100644 --- a/arch/unicore32/kernel/setup.c +++ b/arch/unicore32/kernel/setup.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/utsname.h> | 17 | #include <linux/utsname.h> |
18 | #include <linux/initrd.h> | 18 | #include <linux/initrd.h> |
19 | #include <linux/console.h> | 19 | #include <linux/console.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
22 | #include <linux/screen_info.h> | 22 | #include <linux/screen_info.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/smp.h> | 27 | #include <linux/smp.h> |
28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | #include <linux/proc_fs.h> | 29 | #include <linux/proc_fs.h> |
30 | #include <linux/memblock.h> | ||
31 | #include <linux/elf.h> | 30 | #include <linux/elf.h> |
32 | #include <linux/io.h> | 31 | #include <linux/io.h> |
33 | 32 | ||
@@ -207,7 +206,7 @@ request_standard_resources(struct meminfo *mi) | |||
207 | if (mi->bank[i].size == 0) | 206 | if (mi->bank[i].size == 0) |
208 | continue; | 207 | continue; |
209 | 208 | ||
210 | res = alloc_bootmem_low(sizeof(*res)); | 209 | res = memblock_alloc_low(sizeof(*res), SMP_CACHE_BYTES); |
211 | res->name = "System RAM"; | 210 | res->name = "System RAM"; |
212 | res->start = mi->bank[i].start; | 211 | res->start = mi->bank[i].start; |
213 | res->end = mi->bank[i].start + mi->bank[i].size - 1; | 212 | res->end = mi->bank[i].start + mi->bank[i].size - 1; |
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index 8f8699e62bd5..cf4eb9481fd6 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c | |||
@@ -11,13 +11,12 @@ | |||
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/swap.h> | 12 | #include <linux/swap.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/mman.h> | 15 | #include <linux/mman.h> |
16 | #include <linux/nodemask.h> | 16 | #include <linux/nodemask.h> |
17 | #include <linux/initrd.h> | 17 | #include <linux/initrd.h> |
18 | #include <linux/highmem.h> | 18 | #include <linux/highmem.h> |
19 | #include <linux/gfp.h> | 19 | #include <linux/gfp.h> |
20 | #include <linux/memblock.h> | ||
21 | #include <linux/sort.h> | 20 | #include <linux/sort.h> |
22 | #include <linux/dma-mapping.h> | 21 | #include <linux/dma-mapping.h> |
23 | #include <linux/export.h> | 22 | #include <linux/export.h> |
@@ -238,7 +237,7 @@ free_memmap(unsigned long start_pfn, unsigned long end_pfn) | |||
238 | * free the section of the memmap array. | 237 | * free the section of the memmap array. |
239 | */ | 238 | */ |
240 | if (pg < pgend) | 239 | if (pg < pgend) |
241 | free_bootmem(pg, pgend - pg); | 240 | memblock_free(pg, pgend - pg); |
242 | } | 241 | } |
243 | 242 | ||
244 | /* | 243 | /* |
@@ -286,7 +285,7 @@ void __init mem_init(void) | |||
286 | free_unused_memmap(&meminfo); | 285 | free_unused_memmap(&meminfo); |
287 | 286 | ||
288 | /* this will put all unused low memory onto the freelists */ | 287 | /* this will put all unused low memory onto the freelists */ |
289 | free_all_bootmem(); | 288 | memblock_free_all(); |
290 | 289 | ||
291 | mem_init_print_info(NULL); | 290 | mem_init_print_info(NULL); |
292 | printk(KERN_NOTICE "Virtual kernel memory layout:\n" | 291 | printk(KERN_NOTICE "Virtual kernel memory layout:\n" |
diff --git a/arch/unicore32/mm/mmu.c b/arch/unicore32/mm/mmu.c index 0c94b7b4514d..040a8c279761 100644 --- a/arch/unicore32/mm/mmu.c +++ b/arch/unicore32/mm/mmu.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/nodemask.h> | 17 | #include <linux/nodemask.h> |
18 | #include <linux/memblock.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/fs.h> | 19 | #include <linux/fs.h> |
20 | #include <linux/bootmem.h> | ||
21 | #include <linux/io.h> | 20 | #include <linux/io.h> |
22 | 21 | ||
23 | #include <asm/cputype.h> | 22 | #include <asm/cputype.h> |
@@ -144,7 +143,7 @@ static void __init build_mem_type_table(void) | |||
144 | 143 | ||
145 | static void __init *early_alloc(unsigned long sz) | 144 | static void __init *early_alloc(unsigned long sz) |
146 | { | 145 | { |
147 | void *ptr = __va(memblock_alloc(sz, sz)); | 146 | void *ptr = __va(memblock_phys_alloc(sz, sz)); |
148 | memset(ptr, 0, sz); | 147 | memset(ptr, 0, sz); |
149 | return ptr; | 148 | return ptr; |
150 | } | 149 | } |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ffebfc3f43c1..c51c989c19c0 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -169,7 +169,6 @@ config X86 | |||
169 | select HAVE_KRETPROBES | 169 | select HAVE_KRETPROBES |
170 | select HAVE_KVM | 170 | select HAVE_KVM |
171 | select HAVE_LIVEPATCH if X86_64 | 171 | select HAVE_LIVEPATCH if X86_64 |
172 | select HAVE_MEMBLOCK | ||
173 | select HAVE_MEMBLOCK_NODE_MAP | 172 | select HAVE_MEMBLOCK_NODE_MAP |
174 | select HAVE_MIXED_BREAKPOINTS_REGS | 173 | select HAVE_MIXED_BREAKPOINTS_REGS |
175 | select HAVE_MOD_ARCH_SPECIFIC | 174 | select HAVE_MOD_ARCH_SPECIFIC |
@@ -834,9 +833,6 @@ config JAILHOUSE_GUEST | |||
834 | 833 | ||
835 | endif #HYPERVISOR_GUEST | 834 | endif #HYPERVISOR_GUEST |
836 | 835 | ||
837 | config NO_BOOTMEM | ||
838 | def_bool y | ||
839 | |||
840 | source "arch/x86/Kconfig.cpu" | 836 | source "arch/x86/Kconfig.cpu" |
841 | 837 | ||
842 | config HPET_TIMER | 838 | config HPET_TIMER |
diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 5125fca472bb..003f2daa3b0f 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #ifndef __ASSEMBLY__ | 21 | #ifndef __ASSEMBLY__ |
22 | 22 | ||
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <linux/kernel.h> | ||
24 | 25 | ||
25 | #include <asm/page.h> | 26 | #include <asm/page.h> |
26 | #include <asm/ptrace.h> | 27 | #include <asm/ptrace.h> |
@@ -132,7 +133,7 @@ static inline void crash_setup_regs(struct pt_regs *newregs, | |||
132 | asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs)); | 133 | asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs)); |
133 | asm volatile("pushfq; popq %0" :"=m"(newregs->flags)); | 134 | asm volatile("pushfq; popq %0" :"=m"(newregs->flags)); |
134 | #endif | 135 | #endif |
135 | newregs->ip = (unsigned long)current_text_addr(); | 136 | newregs->ip = _THIS_IP_; |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 617805981cce..071b2a6fff85 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -42,18 +42,6 @@ struct vm86; | |||
42 | #define NET_IP_ALIGN 0 | 42 | #define NET_IP_ALIGN 0 |
43 | 43 | ||
44 | #define HBP_NUM 4 | 44 | #define HBP_NUM 4 |
45 | /* | ||
46 | * Default implementation of macro that returns current | ||
47 | * instruction pointer ("program counter"). | ||
48 | */ | ||
49 | static inline void *current_text_addr(void) | ||
50 | { | ||
51 | void *pc; | ||
52 | |||
53 | asm volatile("mov $1f, %0; 1:":"=r" (pc)); | ||
54 | |||
55 | return pc; | ||
56 | } | ||
57 | 45 | ||
58 | /* | 46 | /* |
59 | * These alignment constraints are for performance in the vSMP case, | 47 | * These alignment constraints are for performance in the vSMP case, |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index e8fea7ffa306..92c76bf97ad8 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/dmi.h> | 32 | #include <linux/dmi.h> |
33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/bootmem.h> | 35 | #include <linux/memblock.h> |
36 | #include <linux/ioport.h> | 36 | #include <linux/ioport.h> |
37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
38 | #include <linux/efi-bgrt.h> | 38 | #include <linux/efi-bgrt.h> |
@@ -933,7 +933,8 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table) | |||
933 | * the resource tree during the lateinit timeframe. | 933 | * the resource tree during the lateinit timeframe. |
934 | */ | 934 | */ |
935 | #define HPET_RESOURCE_NAME_SIZE 9 | 935 | #define HPET_RESOURCE_NAME_SIZE 9 |
936 | hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE); | 936 | hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE, |
937 | SMP_CACHE_BYTES); | ||
937 | 938 | ||
938 | hpet_res->name = (void *)&hpet_res[1]; | 939 | hpet_res->name = (void *)&hpet_res[1]; |
939 | hpet_res->flags = IORESOURCE_MEM; | 940 | hpet_res->flags = IORESOURCE_MEM; |
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index f1915b744052..ca13851f0570 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c | |||
@@ -7,7 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/acpi.h> | 9 | #include <linux/acpi.h> |
10 | #include <linux/bootmem.h> | ||
11 | #include <linux/memblock.h> | 10 | #include <linux/memblock.h> |
12 | #include <linux/dmi.h> | 11 | #include <linux/dmi.h> |
13 | #include <linux/cpumask.h> | 12 | #include <linux/cpumask.h> |
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index ab731ab09f06..32b2b7a41ef5 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/acpi_pmtmr.h> | 20 | #include <linux/acpi_pmtmr.h> |
21 | #include <linux/clockchips.h> | 21 | #include <linux/clockchips.h> |
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/ftrace.h> | 24 | #include <linux/ftrace.h> |
25 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
26 | #include <linux/export.h> | 26 | #include <linux/export.h> |
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index ff0d14cd9e82..2953bbf05c08 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <linux/kthread.h> | 47 | #include <linux/kthread.h> |
48 | #include <linux/jiffies.h> /* time_after() */ | 48 | #include <linux/jiffies.h> /* time_after() */ |
49 | #include <linux/slab.h> | 49 | #include <linux/slab.h> |
50 | #include <linux/bootmem.h> | 50 | #include <linux/memblock.h> |
51 | 51 | ||
52 | #include <asm/irqdomain.h> | 52 | #include <asm/irqdomain.h> |
53 | #include <asm/io.h> | 53 | #include <asm/io.h> |
@@ -2578,7 +2578,7 @@ static struct resource * __init ioapic_setup_resources(void) | |||
2578 | n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource); | 2578 | n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource); |
2579 | n *= nr_ioapics; | 2579 | n *= nr_ioapics; |
2580 | 2580 | ||
2581 | mem = alloc_bootmem(n); | 2581 | mem = memblock_alloc(n, SMP_CACHE_BYTES); |
2582 | res = (void *)mem; | 2582 | res = (void *)mem; |
2583 | 2583 | ||
2584 | mem += sizeof(struct resource) * nr_ioapics; | 2584 | mem += sizeof(struct resource) * nr_ioapics; |
@@ -2621,7 +2621,8 @@ void __init io_apic_init_mappings(void) | |||
2621 | #ifdef CONFIG_X86_32 | 2621 | #ifdef CONFIG_X86_32 |
2622 | fake_ioapic_page: | 2622 | fake_ioapic_page: |
2623 | #endif | 2623 | #endif |
2624 | ioapic_phys = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); | 2624 | ioapic_phys = (unsigned long)memblock_alloc(PAGE_SIZE, |
2625 | PAGE_SIZE); | ||
2625 | ioapic_phys = __pa(ioapic_phys); | 2626 | ioapic_phys = __pa(ioapic_phys); |
2626 | } | 2627 | } |
2627 | set_fixmap_nocache(idx, ioapic_phys); | 2628 | set_fixmap_nocache(idx, ioapic_phys); |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 660d0b22e962..cbbd57ae06ee 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* cpu_feature_enabled() cannot be used this early */ | 1 | /* cpu_feature_enabled() cannot be used this early */ |
2 | #define USE_EARLY_PGTABLE_L5 | 2 | #define USE_EARLY_PGTABLE_L5 |
3 | 3 | ||
4 | #include <linux/bootmem.h> | 4 | #include <linux/memblock.h> |
5 | #include <linux/linkage.h> | 5 | #include <linux/linkage.h> |
6 | #include <linux/bitops.h> | 6 | #include <linux/bitops.h> |
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index d1f25c831447..50895c2f937d 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
@@ -9,11 +9,10 @@ | |||
9 | * allocation code routines via a platform independent interface (memblock, etc.). | 9 | * allocation code routines via a platform independent interface (memblock, etc.). |
10 | */ | 10 | */ |
11 | #include <linux/crash_dump.h> | 11 | #include <linux/crash_dump.h> |
12 | #include <linux/bootmem.h> | 12 | #include <linux/memblock.h> |
13 | #include <linux/suspend.h> | 13 | #include <linux/suspend.h> |
14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
15 | #include <linux/firmware-map.h> | 15 | #include <linux/firmware-map.h> |
16 | #include <linux/memblock.h> | ||
17 | #include <linux/sort.h> | 16 | #include <linux/sort.h> |
18 | 17 | ||
19 | #include <asm/e820/api.h> | 18 | #include <asm/e820/api.h> |
@@ -1094,7 +1093,8 @@ void __init e820__reserve_resources(void) | |||
1094 | struct resource *res; | 1093 | struct resource *res; |
1095 | u64 end; | 1094 | u64 end; |
1096 | 1095 | ||
1097 | res = alloc_bootmem(sizeof(*res) * e820_table->nr_entries); | 1096 | res = memblock_alloc(sizeof(*res) * e820_table->nr_entries, |
1097 | SMP_CACHE_BYTES); | ||
1098 | e820_res = res; | 1098 | e820_res = res; |
1099 | 1099 | ||
1100 | for (i = 0; i < e820_table->nr_entries; i++) { | 1100 | for (i = 0; i < e820_table->nr_entries; i++) { |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index f1c5eb99d445..3482460d984d 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/memblock.h> | 14 | #include <linux/memblock.h> |
16 | #include <linux/kernel_stat.h> | 15 | #include <linux/kernel_stat.h> |
17 | #include <linux/mc146818rtc.h> | 16 | #include <linux/mc146818rtc.h> |
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 7ba73fe0d917..f4562fcec681 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <linux/dma-debug.h> | 3 | #include <linux/dma-debug.h> |
4 | #include <linux/dmar.h> | 4 | #include <linux/dmar.h> |
5 | #include <linux/export.h> | 5 | #include <linux/export.h> |
6 | #include <linux/bootmem.h> | 6 | #include <linux/memblock.h> |
7 | #include <linux/gfp.h> | 7 | #include <linux/gfp.h> |
8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
9 | 9 | ||
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c index 71c0b01d93b1..bd08b9e1c9e2 100644 --- a/arch/x86/kernel/pci-swiotlb.c +++ b/arch/x86/kernel/pci-swiotlb.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/cache.h> | 5 | #include <linux/cache.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/swiotlb.h> | 7 | #include <linux/swiotlb.h> |
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/dma-direct.h> | 9 | #include <linux/dma-direct.h> |
10 | #include <linux/mem_encrypt.h> | 10 | #include <linux/mem_encrypt.h> |
11 | 11 | ||
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c index 637982efecd8..9b158b4716d2 100644 --- a/arch/x86/kernel/pvclock.c +++ b/arch/x86/kernel/pvclock.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/notifier.h> | 20 | #include <linux/notifier.h> |
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <linux/gfp.h> | 22 | #include <linux/gfp.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/nmi.h> | 24 | #include <linux/nmi.h> |
25 | 25 | ||
26 | #include <asm/fixmap.h> | 26 | #include <asm/fixmap.h> |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 7005f89bf3b2..b74e7bfed6ab 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/sfi.h> | 30 | #include <linux/sfi.h> |
31 | #include <linux/apm_bios.h> | 31 | #include <linux/apm_bios.h> |
32 | #include <linux/initrd.h> | 32 | #include <linux/initrd.h> |
33 | #include <linux/bootmem.h> | ||
34 | #include <linux/memblock.h> | 33 | #include <linux/memblock.h> |
35 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
36 | #include <linux/console.h> | 35 | #include <linux/console.h> |
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index ea554f812ee1..e8796fcd7e5a 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | #include <linux/export.h> | 5 | #include <linux/export.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | #include <linux/percpu.h> | 8 | #include <linux/percpu.h> |
9 | #include <linux/kexec.h> | 9 | #include <linux/kexec.h> |
10 | #include <linux/crash_dump.h> | 10 | #include <linux/crash_dump.h> |
@@ -106,20 +106,22 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size, | |||
106 | void *ptr; | 106 | void *ptr; |
107 | 107 | ||
108 | if (!node_online(node) || !NODE_DATA(node)) { | 108 | if (!node_online(node) || !NODE_DATA(node)) { |
109 | ptr = __alloc_bootmem_nopanic(size, align, goal); | 109 | ptr = memblock_alloc_from_nopanic(size, align, goal); |
110 | pr_info("cpu %d has no node %d or node-local memory\n", | 110 | pr_info("cpu %d has no node %d or node-local memory\n", |
111 | cpu, node); | 111 | cpu, node); |
112 | pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n", | 112 | pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n", |
113 | cpu, size, __pa(ptr)); | 113 | cpu, size, __pa(ptr)); |
114 | } else { | 114 | } else { |
115 | ptr = __alloc_bootmem_node_nopanic(NODE_DATA(node), | 115 | ptr = memblock_alloc_try_nid_nopanic(size, align, goal, |
116 | size, align, goal); | 116 | MEMBLOCK_ALLOC_ACCESSIBLE, |
117 | node); | ||
118 | |||
117 | pr_debug("per cpu data for cpu%d %lu bytes on node%d at %016lx\n", | 119 | pr_debug("per cpu data for cpu%d %lu bytes on node%d at %016lx\n", |
118 | cpu, size, node, __pa(ptr)); | 120 | cpu, size, node, __pa(ptr)); |
119 | } | 121 | } |
120 | return ptr; | 122 | return ptr; |
121 | #else | 123 | #else |
122 | return __alloc_bootmem_nopanic(size, align, goal); | 124 | return memblock_alloc_from_nopanic(size, align, goal); |
123 | #endif | 125 | #endif |
124 | } | 126 | } |
125 | 127 | ||
@@ -133,7 +135,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align) | |||
133 | 135 | ||
134 | static void __init pcpu_fc_free(void *ptr, size_t size) | 136 | static void __init pcpu_fc_free(void *ptr, size_t size) |
135 | { | 137 | { |
136 | free_bootmem(__pa(ptr), size); | 138 | memblock_free(__pa(ptr), size); |
137 | } | 139 | } |
138 | 140 | ||
139 | static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) | 141 | static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 5369d7fac797..a9134d1910b9 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <linux/sched/hotplug.h> | 49 | #include <linux/sched/hotplug.h> |
50 | #include <linux/sched/task_stack.h> | 50 | #include <linux/sched/task_stack.h> |
51 | #include <linux/percpu.h> | 51 | #include <linux/percpu.h> |
52 | #include <linux/bootmem.h> | 52 | #include <linux/memblock.h> |
53 | #include <linux/err.h> | 53 | #include <linux/err.h> |
54 | #include <linux/nmi.h> | 54 | #include <linux/nmi.h> |
55 | #include <linux/tboot.h> | 55 | #include <linux/tboot.h> |
diff --git a/arch/x86/kernel/tce_64.c b/arch/x86/kernel/tce_64.c index f386bad0984e..285aaa62d153 100644 --- a/arch/x86/kernel/tce_64.c +++ b/arch/x86/kernel/tce_64.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/string.h> | 30 | #include <linux/string.h> |
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/memblock.h> |
34 | #include <asm/tce.h> | 34 | #include <asm/tce.h> |
35 | #include <asm/calgary.h> | 35 | #include <asm/calgary.h> |
36 | #include <asm/proto.h> | 36 | #include <asm/proto.h> |
@@ -173,7 +173,7 @@ void * __init alloc_tce_table(void) | |||
173 | size = table_size_to_number_of_entries(specified_table_size); | 173 | size = table_size_to_number_of_entries(specified_table_size); |
174 | size *= TCE_ENTRY_SIZE; | 174 | size *= TCE_ENTRY_SIZE; |
175 | 175 | ||
176 | return __alloc_bootmem_low(size, size, 0); | 176 | return memblock_alloc_low(size, size); |
177 | } | 177 | } |
178 | 178 | ||
179 | void __init free_tce_table(void *tbl) | 179 | void __init free_tce_table(void *tbl) |
@@ -186,5 +186,5 @@ void __init free_tce_table(void *tbl) | |||
186 | size = table_size_to_number_of_entries(specified_table_size); | 186 | size = table_size_to_number_of_entries(specified_table_size); |
187 | size *= TCE_ENTRY_SIZE; | 187 | size *= TCE_ENTRY_SIZE; |
188 | 188 | ||
189 | free_bootmem(__pa(tbl), size); | 189 | memblock_free(__pa(tbl), size); |
190 | } | 190 | } |
diff --git a/arch/x86/mm/amdtopology.c b/arch/x86/mm/amdtopology.c index 048c761d97b0..058b2f36b3a6 100644 --- a/arch/x86/mm/amdtopology.c +++ b/arch/x86/mm/amdtopology.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/string.h> | 12 | #include <linux/string.h> |
13 | #include <linux/nodemask.h> | 13 | #include <linux/nodemask.h> |
14 | #include <linux/memblock.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/bootmem.h> | ||
16 | 15 | ||
17 | #include <asm/io.h> | 16 | #include <asm/io.h> |
18 | #include <linux/pci_ids.h> | 17 | #include <linux/pci_ids.h> |
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index b24eb4eb9984..71d4b9d4d43f 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <linux/sched/task_stack.h> /* task_stack_*(), ... */ | 8 | #include <linux/sched/task_stack.h> /* task_stack_*(), ... */ |
9 | #include <linux/kdebug.h> /* oops_begin/end, ... */ | 9 | #include <linux/kdebug.h> /* oops_begin/end, ... */ |
10 | #include <linux/extable.h> /* search_exception_tables */ | 10 | #include <linux/extable.h> /* search_exception_tables */ |
11 | #include <linux/bootmem.h> /* max_low_pfn */ | 11 | #include <linux/memblock.h> /* max_low_pfn */ |
12 | #include <linux/kprobes.h> /* NOKPROBE_SYMBOL, ... */ | 12 | #include <linux/kprobes.h> /* NOKPROBE_SYMBOL, ... */ |
13 | #include <linux/mmiotrace.h> /* kmmio_handler, ... */ | 13 | #include <linux/mmiotrace.h> /* kmmio_handler, ... */ |
14 | #include <linux/perf_event.h> /* perf_sw_event */ | 14 | #include <linux/perf_event.h> /* perf_sw_event */ |
diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c index 6d18b70ed5a9..0d4bdcb84da5 100644 --- a/arch/x86/mm/highmem_32.c +++ b/arch/x86/mm/highmem_32.c | |||
@@ -1,7 +1,7 @@ | |||
1 | #include <linux/highmem.h> | 1 | #include <linux/highmem.h> |
2 | #include <linux/export.h> | 2 | #include <linux/export.h> |
3 | #include <linux/swap.h> /* for totalram_pages */ | 3 | #include <linux/swap.h> /* for totalram_pages */ |
4 | #include <linux/bootmem.h> | 4 | #include <linux/memblock.h> |
5 | 5 | ||
6 | void *kmap(struct page *page) | 6 | void *kmap(struct page *page) |
7 | { | 7 | { |
@@ -111,7 +111,7 @@ void __init set_highmem_pages_init(void) | |||
111 | 111 | ||
112 | /* | 112 | /* |
113 | * Explicitly reset zone->managed_pages because set_highmem_pages_init() | 113 | * Explicitly reset zone->managed_pages because set_highmem_pages_init() |
114 | * is invoked before free_all_bootmem() | 114 | * is invoked before memblock_free_all() |
115 | */ | 115 | */ |
116 | reset_all_zones_managed_pages(); | 116 | reset_all_zones_managed_pages(); |
117 | for_each_zone(zone) { | 117 | for_each_zone(zone) { |
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index faca978ebf9d..ef99f3892e1f 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include <linux/ioport.h> | 3 | #include <linux/ioport.h> |
4 | #include <linux/swap.h> | 4 | #include <linux/swap.h> |
5 | #include <linux/memblock.h> | 5 | #include <linux/memblock.h> |
6 | #include <linux/bootmem.h> /* for max_low_pfn */ | ||
7 | #include <linux/swapfile.h> | 6 | #include <linux/swapfile.h> |
8 | #include <linux/swapops.h> | 7 | #include <linux/swapops.h> |
9 | 8 | ||
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 142c7d9f89cc..49ecf5ecf6d3 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
24 | #include <linux/pfn.h> | 24 | #include <linux/pfn.h> |
25 | #include <linux/poison.h> | 25 | #include <linux/poison.h> |
26 | #include <linux/bootmem.h> | ||
27 | #include <linux/memblock.h> | 26 | #include <linux/memblock.h> |
28 | #include <linux/proc_fs.h> | 27 | #include <linux/proc_fs.h> |
29 | #include <linux/memory_hotplug.h> | 28 | #include <linux/memory_hotplug.h> |
@@ -771,7 +770,7 @@ void __init mem_init(void) | |||
771 | #endif | 770 | #endif |
772 | /* | 771 | /* |
773 | * With CONFIG_DEBUG_PAGEALLOC initialization of highmem pages has to | 772 | * With CONFIG_DEBUG_PAGEALLOC initialization of highmem pages has to |
774 | * be done before free_all_bootmem(). Memblock use free low memory for | 773 | * be done before memblock_free_all(). Memblock use free low memory for |
775 | * temporary data (see find_range_array()) and for this purpose can use | 774 | * temporary data (see find_range_array()) and for this purpose can use |
776 | * pages that was already passed to the buddy allocator, hence marked as | 775 | * pages that was already passed to the buddy allocator, hence marked as |
777 | * not accessible in the page tables when compiled with | 776 | * not accessible in the page tables when compiled with |
@@ -781,7 +780,7 @@ void __init mem_init(void) | |||
781 | set_highmem_pages_init(); | 780 | set_highmem_pages_init(); |
782 | 781 | ||
783 | /* this will put all low memory onto the freelists */ | 782 | /* this will put all low memory onto the freelists */ |
784 | free_all_bootmem(); | 783 | memblock_free_all(); |
785 | 784 | ||
786 | after_bootmem = 1; | 785 | after_bootmem = 1; |
787 | x86_init.hyper.init_after_bootmem(); | 786 | x86_init.hyper.init_after_bootmem(); |
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index dd519f372169..5fab264948c2 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/initrd.h> | 21 | #include <linux/initrd.h> |
22 | #include <linux/pagemap.h> | 22 | #include <linux/pagemap.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
25 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
26 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
@@ -197,7 +196,7 @@ static __ref void *spp_getpage(void) | |||
197 | if (after_bootmem) | 196 | if (after_bootmem) |
198 | ptr = (void *) get_zeroed_page(GFP_ATOMIC); | 197 | ptr = (void *) get_zeroed_page(GFP_ATOMIC); |
199 | else | 198 | else |
200 | ptr = alloc_bootmem_pages(PAGE_SIZE); | 199 | ptr = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
201 | 200 | ||
202 | if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) { | 201 | if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) { |
203 | panic("set_pte_phys: cannot allocate page data %s\n", | 202 | panic("set_pte_phys: cannot allocate page data %s\n", |
@@ -1188,14 +1187,14 @@ void __init mem_init(void) | |||
1188 | /* clear_bss() already clear the empty_zero_page */ | 1187 | /* clear_bss() already clear the empty_zero_page */ |
1189 | 1188 | ||
1190 | /* this will put all memory onto the freelists */ | 1189 | /* this will put all memory onto the freelists */ |
1191 | free_all_bootmem(); | 1190 | memblock_free_all(); |
1192 | after_bootmem = 1; | 1191 | after_bootmem = 1; |
1193 | x86_init.hyper.init_after_bootmem(); | 1192 | x86_init.hyper.init_after_bootmem(); |
1194 | 1193 | ||
1195 | /* | 1194 | /* |
1196 | * Must be done after boot memory is put on freelist, because here we | 1195 | * Must be done after boot memory is put on freelist, because here we |
1197 | * might set fields in deferred struct pages that have not yet been | 1196 | * might set fields in deferred struct pages that have not yet been |
1198 | * initialized, and free_all_bootmem() initializes all the reserved | 1197 | * initialized, and memblock_free_all() initializes all the reserved |
1199 | * deferred pages for us. | 1198 | * deferred pages for us. |
1200 | */ | 1199 | */ |
1201 | register_page_bootmem_info(); | 1200 | register_page_bootmem_info(); |
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 24e0920a9b25..5378d10f1d31 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * (C) Copyright 1995 1996 Linus Torvalds | 6 | * (C) Copyright 1995 1996 Linus Torvalds |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/bootmem.h> | 9 | #include <linux/memblock.h> |
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/io.h> | 11 | #include <linux/io.h> |
12 | #include <linux/ioport.h> | 12 | #include <linux/ioport.h> |
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index e3e77527f8df..04a9cf6b034f 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c | |||
@@ -5,10 +5,9 @@ | |||
5 | /* cpu_feature_enabled() cannot be used this early */ | 5 | /* cpu_feature_enabled() cannot be used this early */ |
6 | #define USE_EARLY_PGTABLE_L5 | 6 | #define USE_EARLY_PGTABLE_L5 |
7 | 7 | ||
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/kasan.h> | 9 | #include <linux/kasan.h> |
10 | #include <linux/kdebug.h> | 10 | #include <linux/kdebug.h> |
11 | #include <linux/memblock.h> | ||
12 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
13 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
14 | #include <linux/sched/task.h> | 13 | #include <linux/sched/task.h> |
@@ -28,11 +27,11 @@ static p4d_t tmp_p4d_table[MAX_PTRS_PER_P4D] __initdata __aligned(PAGE_SIZE); | |||
28 | static __init void *early_alloc(size_t size, int nid, bool panic) | 27 | static __init void *early_alloc(size_t size, int nid, bool panic) |
29 | { | 28 | { |
30 | if (panic) | 29 | if (panic) |
31 | return memblock_virt_alloc_try_nid(size, size, | 30 | return memblock_alloc_try_nid(size, size, |
32 | __pa(MAX_DMA_ADDRESS), BOOTMEM_ALLOC_ACCESSIBLE, nid); | 31 | __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
33 | else | 32 | else |
34 | return memblock_virt_alloc_try_nid_nopanic(size, size, | 33 | return memblock_alloc_try_nid_nopanic(size, size, |
35 | __pa(MAX_DMA_ADDRESS), BOOTMEM_ALLOC_ACCESSIBLE, nid); | 34 | __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
36 | } | 35 | } |
37 | 36 | ||
38 | static void __init kasan_populate_pmd(pmd_t *pmd, unsigned long addr, | 37 | static void __init kasan_populate_pmd(pmd_t *pmd, unsigned long addr, |
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c index 61db77b0eda9..3f452ffed7e9 100644 --- a/arch/x86/mm/kaslr.c +++ b/arch/x86/mm/kaslr.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/random.h> | 25 | #include <linux/random.h> |
26 | #include <linux/memblock.h> | ||
26 | 27 | ||
27 | #include <asm/pgalloc.h> | 28 | #include <asm/pgalloc.h> |
28 | #include <asm/pgtable.h> | 29 | #include <asm/pgtable.h> |
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index fa150855647c..1308f5408bf7 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <linux/mm.h> | 4 | #include <linux/mm.h> |
5 | #include <linux/string.h> | 5 | #include <linux/string.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/bootmem.h> | ||
8 | #include <linux/memblock.h> | 7 | #include <linux/memblock.h> |
9 | #include <linux/mmzone.h> | 8 | #include <linux/mmzone.h> |
10 | #include <linux/ctype.h> | 9 | #include <linux/ctype.h> |
@@ -196,7 +195,7 @@ static void __init alloc_node_data(int nid) | |||
196 | * Allocate node data. Try node-local memory and then any node. | 195 | * Allocate node data. Try node-local memory and then any node. |
197 | * Never allocate in DMA zone. | 196 | * Never allocate in DMA zone. |
198 | */ | 197 | */ |
199 | nd_pa = memblock_alloc_nid(nd_size, SMP_CACHE_BYTES, nid); | 198 | nd_pa = memblock_phys_alloc_nid(nd_size, SMP_CACHE_BYTES, nid); |
200 | if (!nd_pa) { | 199 | if (!nd_pa) { |
201 | nd_pa = __memblock_alloc_base(nd_size, SMP_CACHE_BYTES, | 200 | nd_pa = __memblock_alloc_base(nd_size, SMP_CACHE_BYTES, |
202 | MEMBLOCK_ALLOC_ACCESSIBLE); | 201 | MEMBLOCK_ALLOC_ACCESSIBLE); |
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c index e8a4a09e20f1..f2bd3d61e16b 100644 --- a/arch/x86/mm/numa_32.c +++ b/arch/x86/mm/numa_32.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/bootmem.h> | ||
26 | #include <linux/memblock.h> | 25 | #include <linux/memblock.h> |
27 | #include <linux/init.h> | 26 | #include <linux/init.h> |
28 | 27 | ||
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index 066f3511d5f1..59d80160fa5a 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Generic VM initialization for x86-64 NUMA setups. | 3 | * Generic VM initialization for x86-64 NUMA setups. |
4 | * Copyright 2002,2003 Andi Kleen, SuSE Labs. | 4 | * Copyright 2002,2003 Andi Kleen, SuSE Labs. |
5 | */ | 5 | */ |
6 | #include <linux/bootmem.h> | 6 | #include <linux/memblock.h> |
7 | 7 | ||
8 | #include "numa_internal.h" | 8 | #include "numa_internal.h" |
9 | 9 | ||
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index b54d52a2d00a..a80fdd7fb40f 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c | |||
@@ -6,7 +6,6 @@ | |||
6 | #include <linux/errno.h> | 6 | #include <linux/errno.h> |
7 | #include <linux/topology.h> | 7 | #include <linux/topology.h> |
8 | #include <linux/memblock.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/bootmem.h> | ||
10 | #include <asm/dma.h> | 9 | #include <asm/dma.h> |
11 | 10 | ||
12 | #include "numa_internal.h" | 11 | #include "numa_internal.h" |
diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c index a25588ad75ef..08f8f76a4852 100644 --- a/arch/x86/mm/pageattr-test.c +++ b/arch/x86/mm/pageattr-test.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Clears the a test pte bit on random pages in the direct mapping, | 5 | * Clears the a test pte bit on random pages in the direct mapping, |
6 | * then reverts and compares page tables forwards and afterwards. | 6 | * then reverts and compares page tables forwards and afterwards. |
7 | */ | 7 | */ |
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/kthread.h> | 9 | #include <linux/kthread.h> |
10 | #include <linux/random.h> | 10 | #include <linux/random.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 62bb30b4bd2a..f799076e3d57 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Thanks to Ben LaHaise for precious feedback. | 3 | * Thanks to Ben LaHaise for precious feedback. |
4 | */ | 4 | */ |
5 | #include <linux/highmem.h> | 5 | #include <linux/highmem.h> |
6 | #include <linux/bootmem.h> | 6 | #include <linux/memblock.h> |
7 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
9 | #include <linux/interrupt.h> | 9 | #include <linux/interrupt.h> |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 3d0c83ef6aab..08013524fba1 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/seq_file.h> | 10 | #include <linux/seq_file.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/debugfs.h> | 12 | #include <linux/debugfs.h> |
13 | #include <linux/ioport.h> | 13 | #include <linux/ioport.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c index 7f9acb68324c..bdc98150d4db 100644 --- a/arch/x86/mm/physaddr.c +++ b/arch/x86/mm/physaddr.c | |||
@@ -1,5 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | #include <linux/bootmem.h> | 2 | #include <linux/memblock.h> |
3 | #include <linux/mmdebug.h> | 3 | #include <linux/mmdebug.h> |
4 | #include <linux/export.h> | 4 | #include <linux/export.h> |
5 | #include <linux/mm.h> | 5 | #include <linux/mm.h> |
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index ed4ac215305d..8cd66152cdb0 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/ioport.h> | 33 | #include <linux/ioport.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/bootmem.h> | 35 | #include <linux/memblock.h> |
36 | 36 | ||
37 | #include <asm/pat.h> | 37 | #include <asm/pat.h> |
38 | #include <asm/e820/api.h> | 38 | #include <asm/e820/api.h> |
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 9061babfbc83..7ae939e353cd 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
@@ -36,9 +36,8 @@ | |||
36 | #include <linux/efi.h> | 36 | #include <linux/efi.h> |
37 | #include <linux/efi-bgrt.h> | 37 | #include <linux/efi-bgrt.h> |
38 | #include <linux/export.h> | 38 | #include <linux/export.h> |
39 | #include <linux/bootmem.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/memblock.h> | 39 | #include <linux/memblock.h> |
40 | #include <linux/slab.h> | ||
42 | #include <linux/spinlock.h> | 41 | #include <linux/spinlock.h> |
43 | #include <linux/uaccess.h> | 42 | #include <linux/uaccess.h> |
44 | #include <linux/time.h> | 43 | #include <linux/time.h> |
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index e8da7f492970..cf0347f61b21 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/ioport.h> | 27 | #include <linux/ioport.h> |
28 | #include <linux/mc146818rtc.h> | 28 | #include <linux/mc146818rtc.h> |
29 | #include <linux/efi.h> | 29 | #include <linux/efi.h> |
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 669babcaf245..95e77a667ba5 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <linux/efi.h> | 8 | #include <linux/efi.h> |
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/memblock.h> | 10 | #include <linux/memblock.h> |
11 | #include <linux/bootmem.h> | ||
12 | #include <linux/acpi.h> | 11 | #include <linux/acpi.h> |
13 | #include <linux/dmi.h> | 12 | #include <linux/dmi.h> |
14 | 13 | ||
@@ -333,7 +332,7 @@ void __init efi_reserve_boot_services(void) | |||
333 | 332 | ||
334 | /* | 333 | /* |
335 | * Because the following memblock_reserve() is paired | 334 | * Because the following memblock_reserve() is paired |
336 | * with free_bootmem_late() for this region in | 335 | * with memblock_free_late() for this region in |
337 | * efi_free_boot_services(), we must be extremely | 336 | * efi_free_boot_services(), we must be extremely |
338 | * careful not to reserve, and subsequently free, | 337 | * careful not to reserve, and subsequently free, |
339 | * critical regions of memory (like the kernel image) or | 338 | * critical regions of memory (like the kernel image) or |
@@ -364,7 +363,7 @@ void __init efi_reserve_boot_services(void) | |||
364 | * doesn't make sense as far as the firmware is | 363 | * doesn't make sense as far as the firmware is |
365 | * concerned, but it does provide us with a way to tag | 364 | * concerned, but it does provide us with a way to tag |
366 | * those regions that must not be paired with | 365 | * those regions that must not be paired with |
367 | * free_bootmem_late(). | 366 | * memblock_free_late(). |
368 | */ | 367 | */ |
369 | md->attribute |= EFI_MEMORY_RUNTIME; | 368 | md->attribute |= EFI_MEMORY_RUNTIME; |
370 | } | 369 | } |
@@ -414,7 +413,7 @@ void __init efi_free_boot_services(void) | |||
414 | size -= rm_size; | 413 | size -= rm_size; |
415 | } | 414 | } |
416 | 415 | ||
417 | free_bootmem_late(start, size); | 416 | memblock_free_late(start, size); |
418 | } | 417 | } |
419 | 418 | ||
420 | if (!num_entries) | 419 | if (!num_entries) |
diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c index d6ee92986920..24d2175a9480 100644 --- a/arch/x86/platform/olpc/olpc_dt.c +++ b/arch/x86/platform/olpc/olpc_dt.c | |||
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/bootmem.h> | 20 | #include <linux/memblock.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
23 | #include <linux/of_pdt.h> | 23 | #include <linux/of_pdt.h> |
@@ -141,7 +141,7 @@ void * __init prom_early_alloc(unsigned long size) | |||
141 | * fast enough on the platforms we care about while minimizing | 141 | * fast enough on the platforms we care about while minimizing |
142 | * wasted bootmem) and hand off chunks of it to callers. | 142 | * wasted bootmem) and hand off chunks of it to callers. |
143 | */ | 143 | */ |
144 | res = alloc_bootmem(chunk_size); | 144 | res = memblock_alloc(chunk_size, SMP_CACHE_BYTES); |
145 | BUG_ON(!res); | 145 | BUG_ON(!res); |
146 | prom_early_allocated += chunk_size; | 146 | prom_early_allocated += chunk_size; |
147 | memset(res, 0, chunk_size); | 147 | memset(res, 0, chunk_size); |
diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c index 15695e30f982..be15bdcb20df 100644 --- a/arch/x86/power/hibernate_32.c +++ b/arch/x86/power/hibernate_32.c | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/gfp.h> | 9 | #include <linux/gfp.h> |
10 | #include <linux/suspend.h> | 10 | #include <linux/suspend.h> |
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | 12 | ||
13 | #include <asm/page.h> | 13 | #include <asm/page.h> |
14 | #include <asm/pgtable.h> | 14 | #include <asm/pgtable.h> |
diff --git a/arch/x86/um/asm/processor_32.h b/arch/x86/um/asm/processor_32.h index c112de81c9e1..5fb1b8449adf 100644 --- a/arch/x86/um/asm/processor_32.h +++ b/arch/x86/um/asm/processor_32.h | |||
@@ -47,14 +47,6 @@ static inline void arch_copy_thread(struct arch_thread *from, | |||
47 | memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array)); | 47 | memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array)); |
48 | } | 48 | } |
49 | 49 | ||
50 | /* | ||
51 | * Default implementation of macro that returns current | ||
52 | * instruction pointer ("program counter"). Stolen | ||
53 | * from asm-i386/processor.h | ||
54 | */ | ||
55 | #define current_text_addr() \ | ||
56 | ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; }) | ||
57 | |||
58 | #define current_sp() ({ void *sp; __asm__("movl %%esp, %0" : "=r" (sp) : ); sp; }) | 50 | #define current_sp() ({ void *sp; __asm__("movl %%esp, %0" : "=r" (sp) : ); sp; }) |
59 | #define current_bp() ({ unsigned long bp; __asm__("movl %%ebp, %0" : "=r" (bp) : ); bp; }) | 51 | #define current_bp() ({ unsigned long bp; __asm__("movl %%ebp, %0" : "=r" (bp) : ); bp; }) |
60 | 52 | ||
diff --git a/arch/x86/um/asm/processor_64.h b/arch/x86/um/asm/processor_64.h index c3be85205a65..1ef9c21877bc 100644 --- a/arch/x86/um/asm/processor_64.h +++ b/arch/x86/um/asm/processor_64.h | |||
@@ -31,9 +31,6 @@ static inline void arch_copy_thread(struct arch_thread *from, | |||
31 | to->fs = from->fs; | 31 | to->fs = from->fs; |
32 | } | 32 | } |
33 | 33 | ||
34 | #define current_text_addr() \ | ||
35 | ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; }) | ||
36 | |||
37 | #define current_sp() ({ void *sp; __asm__("movq %%rsp, %0" : "=r" (sp) : ); sp; }) | 34 | #define current_sp() ({ void *sp; __asm__("movq %%rsp, %0" : "=r" (sp) : ); sp; }) |
38 | #define current_bp() ({ unsigned long bp; __asm__("movq %%rbp, %0" : "=r" (bp) : ); bp; }) | 35 | #define current_bp() ({ unsigned long bp; __asm__("movq %%rbp, %0" : "=r" (bp) : ); bp; }) |
39 | 36 | ||
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 67b2f31a1265..e996e8e744cb 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -1,7 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | 2 | ||
3 | #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG | 3 | #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG |
4 | #include <linux/bootmem.h> | 4 | #include <linux/memblock.h> |
5 | #endif | 5 | #endif |
6 | #include <linux/cpu.h> | 6 | #include <linux/cpu.h> |
7 | #include <linux/kexec.h> | 7 | #include <linux/kexec.h> |
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index ec7a4209f310..2f6787fc7106 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/start_kernel.h> | 23 | #include <linux/start_kernel.h> |
24 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
25 | #include <linux/kprobes.h> | 25 | #include <linux/kprobes.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/export.h> | 27 | #include <linux/export.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/page-flags.h> | 29 | #include <linux/page-flags.h> |
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/console.h> | 31 | #include <linux/console.h> |
32 | #include <linux/pci.h> | 32 | #include <linux/pci.h> |
33 | #include <linux/gfp.h> | 33 | #include <linux/gfp.h> |
34 | #include <linux/memblock.h> | ||
35 | #include <linux/edd.h> | 34 | #include <linux/edd.h> |
36 | #include <linux/frame.h> | 35 | #include <linux/frame.h> |
37 | 36 | ||
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 70ea598a37d2..0d7b3ae4960b 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c | |||
@@ -864,7 +864,7 @@ static int __init xen_mark_pinned(struct mm_struct *mm, struct page *page, | |||
864 | * The init_mm pagetable is really pinned as soon as its created, but | 864 | * The init_mm pagetable is really pinned as soon as its created, but |
865 | * that's before we have page structures to store the bits. So do all | 865 | * that's before we have page structures to store the bits. So do all |
866 | * the book-keeping now once struct pages for allocated pages are | 866 | * the book-keeping now once struct pages for allocated pages are |
867 | * initialized. This happens only after free_all_bootmem() is called. | 867 | * initialized. This happens only after memblock_free_all() is called. |
868 | */ | 868 | */ |
869 | static void __init xen_after_bootmem(void) | 869 | static void __init xen_after_bootmem(void) |
870 | { | 870 | { |
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c index d6d74efd8912..b06731705529 100644 --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #include <linux/hash.h> | 67 | #include <linux/hash.h> |
68 | #include <linux/sched.h> | 68 | #include <linux/sched.h> |
69 | #include <linux/seq_file.h> | 69 | #include <linux/seq_file.h> |
70 | #include <linux/bootmem.h> | 70 | #include <linux/memblock.h> |
71 | #include <linux/slab.h> | 71 | #include <linux/slab.h> |
72 | #include <linux/vmalloc.h> | 72 | #include <linux/vmalloc.h> |
73 | 73 | ||
@@ -182,7 +182,7 @@ static void p2m_init_identity(unsigned long *p2m, unsigned long pfn) | |||
182 | static void * __ref alloc_p2m_page(void) | 182 | static void * __ref alloc_p2m_page(void) |
183 | { | 183 | { |
184 | if (unlikely(!slab_is_available())) | 184 | if (unlikely(!slab_is_available())) |
185 | return alloc_bootmem_align(PAGE_SIZE, PAGE_SIZE); | 185 | return memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
186 | 186 | ||
187 | return (void *)__get_free_page(GFP_KERNEL); | 187 | return (void *)__get_free_page(GFP_KERNEL); |
188 | } | 188 | } |
@@ -190,7 +190,7 @@ static void * __ref alloc_p2m_page(void) | |||
190 | static void __ref free_p2m_page(void *p) | 190 | static void __ref free_p2m_page(void *p) |
191 | { | 191 | { |
192 | if (unlikely(!slab_is_available())) { | 192 | if (unlikely(!slab_is_available())) { |
193 | free_bootmem((unsigned long)p, PAGE_SIZE); | 193 | memblock_free((unsigned long)p, PAGE_SIZE); |
194 | return; | 194 | return; |
195 | } | 195 | } |
196 | 196 | ||
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index ea5d8d03e53b..60c141af222b 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
@@ -28,13 +28,11 @@ config XTENSA | |||
28 | select HAVE_FUTEX_CMPXCHG if !MMU | 28 | select HAVE_FUTEX_CMPXCHG if !MMU |
29 | select HAVE_HW_BREAKPOINT if PERF_EVENTS | 29 | select HAVE_HW_BREAKPOINT if PERF_EVENTS |
30 | select HAVE_IRQ_TIME_ACCOUNTING | 30 | select HAVE_IRQ_TIME_ACCOUNTING |
31 | select HAVE_MEMBLOCK | ||
32 | select HAVE_OPROFILE | 31 | select HAVE_OPROFILE |
33 | select HAVE_PERF_EVENTS | 32 | select HAVE_PERF_EVENTS |
34 | select HAVE_STACKPROTECTOR | 33 | select HAVE_STACKPROTECTOR |
35 | select IRQ_DOMAIN | 34 | select IRQ_DOMAIN |
36 | select MODULES_USE_ELF_RELA | 35 | select MODULES_USE_ELF_RELA |
37 | select NO_BOOTMEM | ||
38 | select PERF_USE_VMALLOC | 36 | select PERF_USE_VMALLOC |
39 | select VIRT_TO_BUS | 37 | select VIRT_TO_BUS |
40 | help | 38 | help |
diff --git a/arch/xtensa/include/asm/processor.h b/arch/xtensa/include/asm/processor.h index e4ccb88b7996..be9bfd9aa865 100644 --- a/arch/xtensa/include/asm/processor.h +++ b/arch/xtensa/include/asm/processor.h | |||
@@ -152,14 +152,6 @@ struct thread_struct { | |||
152 | int align[0] __attribute__ ((aligned(16))); | 152 | int align[0] __attribute__ ((aligned(16))); |
153 | }; | 153 | }; |
154 | 154 | ||
155 | |||
156 | /* | ||
157 | * Default implementation of macro that returns current | ||
158 | * instruction pointer ("program counter"). | ||
159 | */ | ||
160 | #define current_text_addr() ({ __label__ _l; _l: &&_l;}) | ||
161 | |||
162 | |||
163 | /* This decides where the kernel will search for a free chunk of vm | 155 | /* This decides where the kernel will search for a free chunk of vm |
164 | * space during mmap's. | 156 | * space during mmap's. |
165 | */ | 157 | */ |
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index 21f13e9aabe1..5ca440a74316 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/bootmem.h> | 27 | #include <linux/memblock.h> |
28 | 28 | ||
29 | #include <asm/pci-bridge.h> | 29 | #include <asm/pci-bridge.h> |
30 | #include <asm/platform.h> | 30 | #include <asm/platform.h> |
diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c index 9220dcde7520..b27359e2a464 100644 --- a/arch/xtensa/mm/cache.c +++ b/arch/xtensa/mm/cache.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <linux/ptrace.h> | 23 | #include <linux/ptrace.h> |
24 | #include <linux/bootmem.h> | 24 | #include <linux/memblock.h> |
25 | #include <linux/swap.h> | 25 | #include <linux/swap.h> |
26 | #include <linux/pagemap.h> | 26 | #include <linux/pagemap.h> |
27 | 27 | ||
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c index 34aead7dcb48..9750a48f491b 100644 --- a/arch/xtensa/mm/init.c +++ b/arch/xtensa/mm/init.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | #include <linux/gfp.h> | 22 | #include <linux/gfp.h> |
23 | #include <linux/highmem.h> | 23 | #include <linux/highmem.h> |
24 | #include <linux/swap.h> | 24 | #include <linux/swap.h> |
@@ -152,7 +152,7 @@ void __init mem_init(void) | |||
152 | max_mapnr = max_pfn - ARCH_PFN_OFFSET; | 152 | max_mapnr = max_pfn - ARCH_PFN_OFFSET; |
153 | high_memory = (void *)__va(max_low_pfn << PAGE_SHIFT); | 153 | high_memory = (void *)__va(max_low_pfn << PAGE_SHIFT); |
154 | 154 | ||
155 | free_all_bootmem(); | 155 | memblock_free_all(); |
156 | 156 | ||
157 | mem_init_print_info(NULL); | 157 | mem_init_print_info(NULL); |
158 | pr_info("virtual kernel memory layout:\n" | 158 | pr_info("virtual kernel memory layout:\n" |
diff --git a/arch/xtensa/mm/kasan_init.c b/arch/xtensa/mm/kasan_init.c index 6b532b6bd785..6b95ca43aec0 100644 --- a/arch/xtensa/mm/kasan_init.c +++ b/arch/xtensa/mm/kasan_init.c | |||
@@ -8,11 +8,10 @@ | |||
8 | * Copyright (C) 2017 Cadence Design Systems Inc. | 8 | * Copyright (C) 2017 Cadence Design Systems Inc. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/init_task.h> | 12 | #include <linux/init_task.h> |
13 | #include <linux/kasan.h> | 13 | #include <linux/kasan.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/memblock.h> | ||
16 | #include <asm/initialize_mmu.h> | 15 | #include <asm/initialize_mmu.h> |
17 | #include <asm/tlbflush.h> | 16 | #include <asm/tlbflush.h> |
18 | #include <asm/traps.h> | 17 | #include <asm/traps.h> |
@@ -43,7 +42,7 @@ static void __init populate(void *start, void *end) | |||
43 | unsigned long vaddr = (unsigned long)start; | 42 | unsigned long vaddr = (unsigned long)start; |
44 | pgd_t *pgd = pgd_offset_k(vaddr); | 43 | pgd_t *pgd = pgd_offset_k(vaddr); |
45 | pmd_t *pmd = pmd_offset(pgd, vaddr); | 44 | pmd_t *pmd = pmd_offset(pgd, vaddr); |
46 | pte_t *pte = memblock_virt_alloc(n_pages * sizeof(pte_t), PAGE_SIZE); | 45 | pte_t *pte = memblock_alloc(n_pages * sizeof(pte_t), PAGE_SIZE); |
47 | 46 | ||
48 | pr_debug("%s: %p - %p\n", __func__, start, end); | 47 | pr_debug("%s: %p - %p\n", __func__, start, end); |
49 | 48 | ||
diff --git a/arch/xtensa/mm/mmu.c b/arch/xtensa/mm/mmu.c index 9d1ecfc53670..a4dcfd39bc5c 100644 --- a/arch/xtensa/mm/mmu.c +++ b/arch/xtensa/mm/mmu.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Extracted from init.c | 5 | * Extracted from init.c |
6 | */ | 6 | */ |
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | #include <linux/percpu.h> | 8 | #include <linux/percpu.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/string.h> | 10 | #include <linux/string.h> |
@@ -31,7 +31,7 @@ static void * __init init_pmd(unsigned long vaddr, unsigned long n_pages) | |||
31 | pr_debug("%s: vaddr: 0x%08lx, n_pages: %ld\n", | 31 | pr_debug("%s: vaddr: 0x%08lx, n_pages: %ld\n", |
32 | __func__, vaddr, n_pages); | 32 | __func__, vaddr, n_pages); |
33 | 33 | ||
34 | pte = alloc_bootmem_low_pages(n_pages * sizeof(pte_t)); | 34 | pte = memblock_alloc_low(n_pages * sizeof(pte_t), PAGE_SIZE); |
35 | 35 | ||
36 | for (i = 0; i < n_pages; ++i) | 36 | for (i = 0; i < n_pages; ++i) |
37 | pte_clear(NULL, 0, pte + i); | 37 | pte_clear(NULL, 0, pte + i); |
diff --git a/arch/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c index d027dddc41ca..d052712373b6 100644 --- a/arch/xtensa/platforms/iss/network.c +++ b/arch/xtensa/platforms/iss/network.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/etherdevice.h> | 30 | #include <linux/etherdevice.h> |
31 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
32 | #include <linux/ioctl.h> | 32 | #include <linux/ioctl.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/memblock.h> |
34 | #include <linux/ethtool.h> | 34 | #include <linux/ethtool.h> |
35 | #include <linux/rtnetlink.h> | 35 | #include <linux/rtnetlink.h> |
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
@@ -646,7 +646,7 @@ static int __init iss_net_setup(char *str) | |||
646 | return 1; | 646 | return 1; |
647 | } | 647 | } |
648 | 648 | ||
649 | new = alloc_bootmem(sizeof(*new)); | 649 | new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES); |
650 | if (new == NULL) { | 650 | if (new == NULL) { |
651 | pr_err("Alloc_bootmem failed\n"); | 651 | pr_err("Alloc_bootmem failed\n"); |
652 | return 1; | 652 | return 1; |
diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c index 58709e89a8ed..c14cc673976c 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * option) any later version. | 16 | * option) any later version. |
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/stddef.h> | 20 | #include <linux/stddef.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
diff --git a/block/blk-settings.c b/block/blk-settings.c index ffd459969689..696c04c1ab6c 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/bio.h> | 7 | #include <linux/bio.h> |
8 | #include <linux/blkdev.h> | 8 | #include <linux/blkdev.h> |
9 | #include <linux/bootmem.h> /* for max_pfn/max_low_pfn */ | 9 | #include <linux/memblock.h> /* for max_pfn/max_low_pfn */ |
10 | #include <linux/gcd.h> | 10 | #include <linux/gcd.h> |
11 | #include <linux/lcm.h> | 11 | #include <linux/lcm.h> |
12 | #include <linux/jiffies.h> | 12 | #include <linux/jiffies.h> |
diff --git a/block/bounce.c b/block/bounce.c index ec0d99995f5f..cf49fe02f65c 100644 --- a/block/bounce.c +++ b/block/bounce.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/hash.h> | 19 | #include <linux/hash.h> |
20 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | #include <linux/printk.h> | 22 | #include <linux/printk.h> |
23 | #include <asm/tlbflush.h> | 23 | #include <asm/tlbflush.h> |
24 | 24 | ||
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 6b0d3ef7309c..8fe0960ea572 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -228,7 +228,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
228 | if (node < 0) | 228 | if (node < 0) |
229 | node = memory_add_physaddr_to_nid(info->start_addr); | 229 | node = memory_add_physaddr_to_nid(info->start_addr); |
230 | 230 | ||
231 | result = add_memory(node, info->start_addr, info->length); | 231 | result = __add_memory(node, info->start_addr, info->length); |
232 | 232 | ||
233 | /* | 233 | /* |
234 | * If the memory block has been used by the kernel, add_memory() | 234 | * If the memory block has been used by the kernel, add_memory() |
@@ -282,7 +282,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | |||
282 | nid = memory_add_physaddr_to_nid(info->start_addr); | 282 | nid = memory_add_physaddr_to_nid(info->start_addr); |
283 | 283 | ||
284 | acpi_unbind_memory_blocks(info); | 284 | acpi_unbind_memory_blocks(info); |
285 | remove_memory(nid, info->start_addr, info->length); | 285 | __remove_memory(nid, info->start_addr, info->length); |
286 | list_del(&info->list); | 286 | list_del(&info->list); |
287 | kfree(info); | 287 | kfree(info); |
288 | } | 288 | } |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 85167603b9c9..274699463b4f 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | #include <linux/bootmem.h> | ||
31 | #include <linux/memblock.h> | 30 | #include <linux/memblock.h> |
32 | #include <linux/numa.h> | 31 | #include <linux/numa.h> |
33 | #include <linux/nodemask.h> | 32 | #include <linux/nodemask.h> |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index a3d012b08fc5..61203eebf3a1 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -31,9 +31,8 @@ | |||
31 | #include <linux/irq.h> | 31 | #include <linux/irq.h> |
32 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
33 | #include <linux/acpi.h> | 33 | #include <linux/acpi.h> |
34 | #include <linux/bootmem.h> | ||
35 | #include <linux/earlycpio.h> | ||
36 | #include <linux/memblock.h> | 34 | #include <linux/memblock.h> |
35 | #include <linux/earlycpio.h> | ||
37 | #include <linux/initrd.h> | 36 | #include <linux/initrd.h> |
38 | #include "internal.h" | 37 | #include "internal.h" |
39 | 38 | ||
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 817320c7c4c1..0e5985682642 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -228,7 +228,6 @@ static bool pages_correctly_probed(unsigned long start_pfn) | |||
228 | /* | 228 | /* |
229 | * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is | 229 | * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is |
230 | * OK to have direct references to sparsemem variables in here. | 230 | * OK to have direct references to sparsemem variables in here. |
231 | * Must already be protected by mem_hotplug_begin(). | ||
232 | */ | 231 | */ |
233 | static int | 232 | static int |
234 | memory_block_action(unsigned long phys_index, unsigned long action, int online_type) | 233 | memory_block_action(unsigned long phys_index, unsigned long action, int online_type) |
@@ -294,7 +293,6 @@ static int memory_subsys_online(struct device *dev) | |||
294 | if (mem->online_type < 0) | 293 | if (mem->online_type < 0) |
295 | mem->online_type = MMOP_ONLINE_KEEP; | 294 | mem->online_type = MMOP_ONLINE_KEEP; |
296 | 295 | ||
297 | /* Already under protection of mem_hotplug_begin() */ | ||
298 | ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); | 296 | ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); |
299 | 297 | ||
300 | /* clear online_type */ | 298 | /* clear online_type */ |
@@ -341,19 +339,11 @@ store_mem_state(struct device *dev, | |||
341 | goto err; | 339 | goto err; |
342 | } | 340 | } |
343 | 341 | ||
344 | /* | ||
345 | * Memory hotplug needs to hold mem_hotplug_begin() for probe to find | ||
346 | * the correct memory block to online before doing device_online(dev), | ||
347 | * which will take dev->mutex. Take the lock early to prevent an | ||
348 | * inversion, memory_subsys_online() callbacks will be implemented by | ||
349 | * assuming it's already protected. | ||
350 | */ | ||
351 | mem_hotplug_begin(); | ||
352 | |||
353 | switch (online_type) { | 342 | switch (online_type) { |
354 | case MMOP_ONLINE_KERNEL: | 343 | case MMOP_ONLINE_KERNEL: |
355 | case MMOP_ONLINE_MOVABLE: | 344 | case MMOP_ONLINE_MOVABLE: |
356 | case MMOP_ONLINE_KEEP: | 345 | case MMOP_ONLINE_KEEP: |
346 | /* mem->online_type is protected by device_hotplug_lock */ | ||
357 | mem->online_type = online_type; | 347 | mem->online_type = online_type; |
358 | ret = device_online(&mem->dev); | 348 | ret = device_online(&mem->dev); |
359 | break; | 349 | break; |
@@ -364,7 +354,6 @@ store_mem_state(struct device *dev, | |||
364 | ret = -EINVAL; /* should never happen */ | 354 | ret = -EINVAL; /* should never happen */ |
365 | } | 355 | } |
366 | 356 | ||
367 | mem_hotplug_done(); | ||
368 | err: | 357 | err: |
369 | unlock_device_hotplug(); | 358 | unlock_device_hotplug(); |
370 | 359 | ||
@@ -519,15 +508,20 @@ memory_probe_store(struct device *dev, struct device_attribute *attr, | |||
519 | if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) | 508 | if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) |
520 | return -EINVAL; | 509 | return -EINVAL; |
521 | 510 | ||
511 | ret = lock_device_hotplug_sysfs(); | ||
512 | if (ret) | ||
513 | goto out; | ||
514 | |||
522 | nid = memory_add_physaddr_to_nid(phys_addr); | 515 | nid = memory_add_physaddr_to_nid(phys_addr); |
523 | ret = add_memory(nid, phys_addr, | 516 | ret = __add_memory(nid, phys_addr, |
524 | MIN_MEMORY_BLOCK_SIZE * sections_per_block); | 517 | MIN_MEMORY_BLOCK_SIZE * sections_per_block); |
525 | 518 | ||
526 | if (ret) | 519 | if (ret) |
527 | goto out; | 520 | goto out; |
528 | 521 | ||
529 | ret = count; | 522 | ret = count; |
530 | out: | 523 | out: |
524 | unlock_device_hotplug(); | ||
531 | return ret; | 525 | return ret; |
532 | } | 526 | } |
533 | 527 | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 23cf4427f425..41b91af95afb 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/dma-mapping.h> | 18 | #include <linux/dma-mapping.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/pm_runtime.h> | 22 | #include <linux/pm_runtime.h> |
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 7d22e1af2247..e205af814582 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/of_address.h> | 23 | #include <linux/of_address.h> |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/regmap.h> | 25 | #include <linux/regmap.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/device.h> | 27 | #include <linux/device.h> |
28 | 28 | ||
29 | #include "clock.h" | 29 | #include "clock.h" |
@@ -342,7 +342,7 @@ void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem) | |||
342 | { | 342 | { |
343 | struct clk_iomap *io; | 343 | struct clk_iomap *io; |
344 | 344 | ||
345 | io = memblock_virt_alloc(sizeof(*io), 0); | 345 | io = memblock_alloc(sizeof(*io), SMP_CACHE_BYTES); |
346 | 346 | ||
347 | io->mem = mem; | 347 | io->mem = mem; |
348 | 348 | ||
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index f2483548cde9..099d83e4e910 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/ctype.h> | 5 | #include <linux/ctype.h> |
6 | #include <linux/dmi.h> | 6 | #include <linux/dmi.h> |
7 | #include <linux/efi.h> | 7 | #include <linux/efi.h> |
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/random.h> | 9 | #include <linux/random.h> |
10 | #include <asm/dmi.h> | 10 | #include <asm/dmi.h> |
11 | #include <asm/unaligned.h> | 11 | #include <asm/unaligned.h> |
diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c index 60a95719ecb8..ac1654f74dc7 100644 --- a/drivers/firmware/efi/apple-properties.c +++ b/drivers/firmware/efi/apple-properties.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #define pr_fmt(fmt) "apple-properties: " fmt | 21 | #define pr_fmt(fmt) "apple-properties: " fmt |
22 | 22 | ||
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/efi.h> | 24 | #include <linux/efi.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/platform_data/x86/apple.h> | 26 | #include <linux/platform_data/x86/apple.h> |
@@ -235,7 +235,7 @@ static int __init map_properties(void) | |||
235 | */ | 235 | */ |
236 | data->len = 0; | 236 | data->len = 0; |
237 | memunmap(data); | 237 | memunmap(data); |
238 | free_bootmem_late(pa_data + sizeof(*data), data_len); | 238 | memblock_free_late(pa_data + sizeof(*data), data_len); |
239 | 239 | ||
240 | return ret; | 240 | return ret; |
241 | } | 241 | } |
diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c index 5fc70520e04c..fa2904fb841f 100644 --- a/drivers/firmware/efi/memmap.c +++ b/drivers/firmware/efi/memmap.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | static phys_addr_t __init __efi_memmap_alloc_early(unsigned long size) | 16 | static phys_addr_t __init __efi_memmap_alloc_early(unsigned long size) |
17 | { | 17 | { |
18 | return memblock_alloc(size, 0); | 18 | return memblock_phys_alloc(size, SMP_CACHE_BYTES); |
19 | } | 19 | } |
20 | 20 | ||
21 | static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size) | 21 | static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size) |
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c index 2224f1dc074b..72d9ea18270b 100644 --- a/drivers/firmware/iscsi_ibft_find.c +++ b/drivers/firmware/iscsi_ibft_find.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/bootmem.h> | 21 | #include <linux/memblock.h> |
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/ctype.h> | 23 | #include <linux/ctype.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c index 5de3ed29282c..d168c87c7d30 100644 --- a/drivers/firmware/memmap.c +++ b/drivers/firmware/memmap.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | 25 | ||
@@ -333,7 +333,8 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type) | |||
333 | { | 333 | { |
334 | struct firmware_map_entry *entry; | 334 | struct firmware_map_entry *entry; |
335 | 335 | ||
336 | entry = memblock_virt_alloc(sizeof(struct firmware_map_entry), 0); | 336 | entry = memblock_alloc(sizeof(struct firmware_map_entry), |
337 | SMP_CACHE_BYTES); | ||
337 | if (WARN_ON(!entry)) | 338 | if (WARN_ON(!entry)) |
338 | return -ENOMEM; | 339 | return -ENOMEM; |
339 | 340 | ||
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index f9f69f7111a9..44bd5b9166bb 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | */ | 13 | */ |
14 | #include <linux/bootmem.h> | 14 | #include <linux/memblock.h> |
15 | #include <linux/bug.h> | 15 | #include <linux/bug.h> |
16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
17 | #include <linux/component.h> | 17 | #include <linux/component.h> |
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 676c029494e4..0e780848f59b 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c | |||
@@ -13,7 +13,7 @@ | |||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | */ | 15 | */ |
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/bug.h> | 17 | #include <linux/bug.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | #include <linux/component.h> | 19 | #include <linux/component.h> |
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index e8ae2e54151c..0a0b8e1f4236 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/dmapool.h> | 25 | #include <linux/dmapool.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
28 | #include <linux/highmem.h> | 28 | #include <linux/highmem.h> |
29 | #include <linux/jiffies.h> | 29 | #include <linux/jiffies.h> |
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/of_irq.h> | 38 | #include <linux/of_irq.h> |
39 | #include <linux/of_platform.h> | 39 | #include <linux/of_platform.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/memblock.h> | ||
42 | #include <linux/sched/signal.h> | 41 | #include <linux/sched/signal.h> |
43 | 42 | ||
44 | #include <asm/byteorder.h> | 43 | #include <asm/byteorder.h> |
@@ -493,7 +492,7 @@ int __init smu_init (void) | |||
493 | goto fail_np; | 492 | goto fail_np; |
494 | } | 493 | } |
495 | 494 | ||
496 | smu = alloc_bootmem(sizeof(struct smu_device)); | 495 | smu = memblock_alloc(sizeof(struct smu_device), SMP_CACHE_BYTES); |
497 | 496 | ||
498 | spin_lock_init(&smu->lock); | 497 | spin_lock_init(&smu->lock); |
499 | INIT_LIST_HEAD(&smu->cmd_list); | 498 | INIT_LIST_HEAD(&smu->cmd_list); |
@@ -569,7 +568,7 @@ fail_msg_node: | |||
569 | fail_db_node: | 568 | fail_db_node: |
570 | of_node_put(smu->db_node); | 569 | of_node_put(smu->db_node); |
571 | fail_bootmem: | 570 | fail_bootmem: |
572 | free_bootmem(__pa(smu), sizeof(struct smu_device)); | 571 | memblock_free(__pa(smu), sizeof(struct smu_device)); |
573 | smu = NULL; | 572 | smu = NULL; |
574 | fail_np: | 573 | fail_np: |
575 | of_node_put(np); | 574 | of_node_put(np); |
diff --git a/drivers/mtd/ar7part.c b/drivers/mtd/ar7part.c index fc15ec58230a..0d33cf0842ad 100644 --- a/drivers/mtd/ar7part.c +++ b/drivers/mtd/ar7part.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/mtd/mtd.h> | 26 | #include <linux/mtd/mtd.h> |
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
28 | #include <linux/bootmem.h> | 28 | #include <linux/memblock.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | 30 | ||
31 | #include <uapi/linux/magic.h> | 31 | #include <uapi/linux/magic.h> |
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c index a07e24970be4..11c5bad95226 100644 --- a/drivers/net/arcnet/arc-rimi.c +++ b/drivers/net/arcnet/arc-rimi.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/ioport.h> | 33 | #include <linux/ioport.h> |
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/netdevice.h> | 35 | #include <linux/netdevice.h> |
36 | #include <linux/bootmem.h> | 36 | #include <linux/memblock.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
39 | #include <linux/io.h> | 39 | #include <linux/io.h> |
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c index 38fa60ddaf2e..28510e33924f 100644 --- a/drivers/net/arcnet/com20020-isa.c +++ b/drivers/net/arcnet/com20020-isa.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/netdevice.h> | 38 | #include <linux/netdevice.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/interrupt.h> | 40 | #include <linux/interrupt.h> |
41 | #include <linux/bootmem.h> | 41 | #include <linux/memblock.h> |
42 | #include <linux/io.h> | 42 | #include <linux/io.h> |
43 | 43 | ||
44 | #include "arcdevice.h" | 44 | #include "arcdevice.h" |
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c index 4e56aaf2b984..2c546013a980 100644 --- a/drivers/net/arcnet/com90io.c +++ b/drivers/net/arcnet/com90io.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/ioport.h> | 34 | #include <linux/ioport.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/netdevice.h> | 36 | #include <linux/netdevice.h> |
37 | #include <linux/bootmem.h> | 37 | #include <linux/memblock.h> |
38 | #include <linux/init.h> | 38 | #include <linux/init.h> |
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/io.h> | 40 | #include <linux/io.h> |
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 76c83c1ffeda..bb532aae0d92 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/crc32.h> | 11 | #include <linux/crc32.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/initrd.h> | 13 | #include <linux/initrd.h> |
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/memblock.h> | 14 | #include <linux/memblock.h> |
16 | #include <linux/mutex.h> | 15 | #include <linux/mutex.h> |
17 | #include <linux/of.h> | 16 | #include <linux/of.h> |
@@ -1115,7 +1114,6 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, | |||
1115 | return 1; | 1114 | return 1; |
1116 | } | 1115 | } |
1117 | 1116 | ||
1118 | #ifdef CONFIG_HAVE_MEMBLOCK | ||
1119 | #ifndef MIN_MEMBLOCK_ADDR | 1117 | #ifndef MIN_MEMBLOCK_ADDR |
1120 | #define MIN_MEMBLOCK_ADDR __pa(PAGE_OFFSET) | 1118 | #define MIN_MEMBLOCK_ADDR __pa(PAGE_OFFSET) |
1121 | #endif | 1119 | #endif |
@@ -1178,29 +1176,9 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, | |||
1178 | return memblock_reserve(base, size); | 1176 | return memblock_reserve(base, size); |
1179 | } | 1177 | } |
1180 | 1178 | ||
1181 | #else | ||
1182 | void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) | ||
1183 | { | ||
1184 | WARN_ON(1); | ||
1185 | } | ||
1186 | |||
1187 | int __init __weak early_init_dt_mark_hotplug_memory_arch(u64 base, u64 size) | ||
1188 | { | ||
1189 | return -ENOSYS; | ||
1190 | } | ||
1191 | |||
1192 | int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, | ||
1193 | phys_addr_t size, bool nomap) | ||
1194 | { | ||
1195 | pr_err("Reserved memory not supported, ignoring range %pa - %pa%s\n", | ||
1196 | &base, &size, nomap ? " (nomap)" : ""); | ||
1197 | return -ENOSYS; | ||
1198 | } | ||
1199 | #endif | ||
1200 | |||
1201 | static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | 1179 | static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) |
1202 | { | 1180 | { |
1203 | return memblock_virt_alloc(size, align); | 1181 | return memblock_alloc(size, align); |
1204 | } | 1182 | } |
1205 | 1183 | ||
1206 | bool __init early_init_dt_verify(void *params) | 1184 | bool __init early_init_dt_verify(void *params) |
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 895c83e0c7b6..1977ee0adcb1 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c | |||
@@ -20,13 +20,12 @@ | |||
20 | #include <linux/of_reserved_mem.h> | 20 | #include <linux/of_reserved_mem.h> |
21 | #include <linux/sort.h> | 21 | #include <linux/sort.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/memblock.h> | ||
23 | 24 | ||
24 | #define MAX_RESERVED_REGIONS 32 | 25 | #define MAX_RESERVED_REGIONS 32 |
25 | static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; | 26 | static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; |
26 | static int reserved_mem_count; | 27 | static int reserved_mem_count; |
27 | 28 | ||
28 | #if defined(CONFIG_HAVE_MEMBLOCK) | ||
29 | #include <linux/memblock.h> | ||
30 | int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | 29 | int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, |
31 | phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap, | 30 | phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap, |
32 | phys_addr_t *res_base) | 31 | phys_addr_t *res_base) |
@@ -37,6 +36,7 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | |||
37 | * panic()s on allocation failure. | 36 | * panic()s on allocation failure. |
38 | */ | 37 | */ |
39 | end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end; | 38 | end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end; |
39 | align = !align ? SMP_CACHE_BYTES : align; | ||
40 | base = __memblock_alloc_base(size, align, end); | 40 | base = __memblock_alloc_base(size, align, end); |
41 | if (!base) | 41 | if (!base) |
42 | return -ENOMEM; | 42 | return -ENOMEM; |
@@ -54,16 +54,6 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | |||
54 | return memblock_remove(base, size); | 54 | return memblock_remove(base, size); |
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | #else | ||
58 | int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | ||
59 | phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap, | ||
60 | phys_addr_t *res_base) | ||
61 | { | ||
62 | pr_err("Reserved memory not supported, ignoring region 0x%llx%s\n", | ||
63 | size, nomap ? " (nomap)" : ""); | ||
64 | return -ENOSYS; | ||
65 | } | ||
66 | #endif | ||
67 | 57 | ||
68 | /** | 58 | /** |
69 | * res_mem_save_node() - save fdt node for second pass initialization | 59 | * res_mem_save_node() - save fdt node for second pass initialization |
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index a3a6866765f2..49ae2aa744d6 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | #define pr_fmt(fmt) "### dt-test ### " fmt | 6 | #define pr_fmt(fmt) "### dt-test ### " fmt |
7 | 7 | ||
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/clk.h> | 9 | #include <linux/clk.h> |
10 | #include <linux/err.h> | 10 | #include <linux/err.h> |
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
@@ -2192,7 +2192,7 @@ static struct device_node *overlay_base_root; | |||
2192 | 2192 | ||
2193 | static void * __init dt_alloc_memory(u64 size, u64 align) | 2193 | static void * __init dt_alloc_memory(u64 size, u64 align) |
2194 | { | 2194 | { |
2195 | return memblock_virt_alloc(size, align); | 2195 | return memblock_alloc(size, align); |
2196 | } | 2196 | } |
2197 | 2197 | ||
2198 | /* | 2198 | /* |
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c index 16a4e8528bbc..8f3a2eeb28dc 100644 --- a/drivers/s390/char/fs3270.c +++ b/drivers/s390/char/fs3270.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Copyright IBM Corp. 2003, 2009 | 8 | * Copyright IBM Corp. 2003, 2009 |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/bootmem.h> | 11 | #include <linux/memblock.h> |
12 | #include <linux/console.h> | 12 | #include <linux/console.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 5b8af2782282..2b0c36c2c568 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/workqueue.h> | 19 | #include <linux/workqueue.h> |
20 | 20 | ||
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/compat.h> | 23 | #include <linux/compat.h> |
24 | 24 | ||
25 | #include <asm/ccwdev.h> | 25 | #include <asm/ccwdev.h> |
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c index 8af4948dae80..72dd2471ec1e 100644 --- a/drivers/s390/cio/cmf.c +++ b/drivers/s390/cio/cmf.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #define KMSG_COMPONENT "cio" | 13 | #define KMSG_COMPONENT "cio" |
14 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 14 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
15 | 15 | ||
16 | #include <linux/bootmem.h> | 16 | #include <linux/memblock.h> |
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/list.h> | 19 | #include <linux/list.h> |
diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c index 8f5c1d7f751a..97b6f197f007 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c | |||
@@ -9,7 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/kernel_stat.h> | 10 | #include <linux/kernel_stat.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/bootmem.h> | 12 | #include <linux/memblock.h> |
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/virtio.h> | 14 | #include <linux/virtio.h> |
15 | #include <linux/virtio_config.h> | 15 | #include <linux/virtio_config.h> |
diff --git a/drivers/sfi/sfi_core.c b/drivers/sfi/sfi_core.c index 153b3f3cc795..a5136901dd8a 100644 --- a/drivers/sfi/sfi_core.c +++ b/drivers/sfi/sfi_core.c | |||
@@ -59,7 +59,7 @@ | |||
59 | #define KMSG_COMPONENT "SFI" | 59 | #define KMSG_COMPONENT "SFI" |
60 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 60 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
61 | 61 | ||
62 | #include <linux/bootmem.h> | 62 | #include <linux/memblock.h> |
63 | #include <linux/kernel.h> | 63 | #include <linux/kernel.h> |
64 | #include <linux/module.h> | 64 | #include <linux/module.h> |
65 | #include <linux/errno.h> | 65 | #include <linux/errno.h> |
diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index c16dd16afe6a..0fdda6f62953 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | menuconfig ION | 1 | menuconfig ION |
2 | bool "Ion Memory Manager" | 2 | bool "Ion Memory Manager" |
3 | depends on HAVE_MEMBLOCK && HAS_DMA && MMU | 3 | depends on HAS_DMA && MMU |
4 | select GENERIC_ALLOCATOR | 4 | select GENERIC_ALLOCATOR |
5 | select DMA_SHARED_BUFFER | 5 | select DMA_SHARED_BUFFER |
6 | help | 6 | help |
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 79ad30d34949..b929c7ae3a27 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/console.h> | 24 | #include <linux/console.h> |
25 | #include <linux/sysrq.h> | 25 | #include <linux/sysrq.h> |
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/bootmem.h> | 27 | #include <linux/memblock.h> |
28 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
29 | #include <linux/fs_uart_pd.h> | 29 | #include <linux/fs_uart_pd.h> |
30 | #include <linux/of_address.h> | 30 | #include <linux/of_address.h> |
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c index 4eba17f3d293..56fc527015cb 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/console.h> | 19 | #include <linux/console.h> |
20 | #include <linux/sysrq.h> | 20 | #include <linux/sysrq.h> |
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/dma-mapping.h> | 23 | #include <linux/dma-mapping.h> |
24 | 24 | ||
25 | #include <asm/io.h> | 25 | #include <asm/io.h> |
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c index e3bff068dc3c..6a1cd03bfe39 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/console.h> | 19 | #include <linux/console.h> |
20 | #include <linux/sysrq.h> | 20 | #include <linux/sysrq.h> |
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/dma-mapping.h> | 23 | #include <linux/dma-mapping.h> |
24 | 24 | ||
25 | #include <asm/io.h> | 25 | #include <asm/io.h> |
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index 165653a5e45d..d2652dccc699 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/console.h> | 12 | #include <linux/console.h> |
13 | #include <linux/pci_regs.h> | 13 | #include <linux/pci_regs.h> |
14 | #include <linux/pci_ids.h> | 14 | #include <linux/pci_ids.h> |
15 | #include <linux/bootmem.h> | 15 | #include <linux/memblock.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <asm/pci-direct.h> | 17 | #include <asm/pci-direct.h> |
18 | #include <asm/fixmap.h> | 18 | #include <asm/fixmap.h> |
@@ -94,7 +94,7 @@ static void * __init xdbc_get_page(dma_addr_t *dma_addr) | |||
94 | { | 94 | { |
95 | void *virt; | 95 | void *virt; |
96 | 96 | ||
97 | virt = alloc_bootmem_pages_nopanic(PAGE_SIZE); | 97 | virt = memblock_alloc_nopanic(PAGE_SIZE, PAGE_SIZE); |
98 | if (!virt) | 98 | if (!virt) |
99 | return NULL; | 99 | return NULL; |
100 | 100 | ||
@@ -191,7 +191,7 @@ static void __init xdbc_free_ring(struct xdbc_ring *ring) | |||
191 | if (!seg) | 191 | if (!seg) |
192 | return; | 192 | return; |
193 | 193 | ||
194 | free_bootmem(seg->dma, PAGE_SIZE); | 194 | memblock_free(seg->dma, PAGE_SIZE); |
195 | ring->segment = NULL; | 195 | ring->segment = NULL; |
196 | } | 196 | } |
197 | 197 | ||
@@ -675,10 +675,10 @@ int __init early_xdbc_setup_hardware(void) | |||
675 | xdbc_free_ring(&xdbc.in_ring); | 675 | xdbc_free_ring(&xdbc.in_ring); |
676 | 676 | ||
677 | if (xdbc.table_dma) | 677 | if (xdbc.table_dma) |
678 | free_bootmem(xdbc.table_dma, PAGE_SIZE); | 678 | memblock_free(xdbc.table_dma, PAGE_SIZE); |
679 | 679 | ||
680 | if (xdbc.out_dma) | 680 | if (xdbc.out_dma) |
681 | free_bootmem(xdbc.out_dma, PAGE_SIZE); | 681 | memblock_free(xdbc.out_dma, PAGE_SIZE); |
682 | 682 | ||
683 | xdbc.table_base = NULL; | 683 | xdbc.table_base = NULL; |
684 | xdbc.out_buf = NULL; | 684 | xdbc.out_buf = NULL; |
@@ -997,8 +997,8 @@ free_and_quit: | |||
997 | xdbc_free_ring(&xdbc.evt_ring); | 997 | xdbc_free_ring(&xdbc.evt_ring); |
998 | xdbc_free_ring(&xdbc.out_ring); | 998 | xdbc_free_ring(&xdbc.out_ring); |
999 | xdbc_free_ring(&xdbc.in_ring); | 999 | xdbc_free_ring(&xdbc.in_ring); |
1000 | free_bootmem(xdbc.table_dma, PAGE_SIZE); | 1000 | memblock_free(xdbc.table_dma, PAGE_SIZE); |
1001 | free_bootmem(xdbc.out_dma, PAGE_SIZE); | 1001 | memblock_free(xdbc.out_dma, PAGE_SIZE); |
1002 | writel(0, &xdbc.xdbc_reg->control); | 1002 | writel(0, &xdbc.xdbc_reg->control); |
1003 | early_iounmap(xdbc.xhci_base, xdbc.xhci_length); | 1003 | early_iounmap(xdbc.xhci_base, xdbc.xhci_length); |
1004 | 1004 | ||
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index e12bb256036f..fdfc64f5acea 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/cred.h> | 44 | #include <linux/cred.h> |
45 | #include <linux/errno.h> | 45 | #include <linux/errno.h> |
46 | #include <linux/mm.h> | 46 | #include <linux/mm.h> |
47 | #include <linux/bootmem.h> | 47 | #include <linux/memblock.h> |
48 | #include <linux/pagemap.h> | 48 | #include <linux/pagemap.h> |
49 | #include <linux/highmem.h> | 49 | #include <linux/highmem.h> |
50 | #include <linux/mutex.h> | 50 | #include <linux/mutex.h> |
@@ -395,7 +395,10 @@ static enum bp_state reserve_additional_memory(void) | |||
395 | * callers drop the mutex before trying again. | 395 | * callers drop the mutex before trying again. |
396 | */ | 396 | */ |
397 | mutex_unlock(&balloon_mutex); | 397 | mutex_unlock(&balloon_mutex); |
398 | /* add_memory_resource() requires the device_hotplug lock */ | ||
399 | lock_device_hotplug(); | ||
398 | rc = add_memory_resource(nid, resource, memhp_auto_online); | 400 | rc = add_memory_resource(nid, resource, memhp_auto_online); |
401 | unlock_device_hotplug(); | ||
399 | mutex_lock(&balloon_mutex); | 402 | mutex_lock(&balloon_mutex); |
400 | 403 | ||
401 | if (rc) { | 404 | if (rc) { |
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index e6c1934734b7..93194f3e7540 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/irq.h> | 28 | #include <linux/irq.h> |
29 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
30 | #include <linux/string.h> | 30 | #include <linux/string.h> |
31 | #include <linux/bootmem.h> | 31 | #include <linux/memblock.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/irqnr.h> | 33 | #include <linux/irqnr.h> |
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 84575baceebc..f15f89df1f36 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt | 34 | #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt |
35 | 35 | ||
36 | #include <linux/bootmem.h> | 36 | #include <linux/memblock.h> |
37 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
38 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index f5c1af4ce9ab..2a7f545bd0b5 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt | 36 | #define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt |
37 | 37 | ||
38 | #include <linux/bootmem.h> | 38 | #include <linux/memblock.h> |
39 | #include <linux/dma-direct.h> | 39 | #include <linux/dma-direct.h> |
40 | #include <linux/export.h> | 40 | #include <linux/export.h> |
41 | #include <xen/swiotlb-xen.h> | 41 | #include <xen/swiotlb-xen.h> |
@@ -217,7 +217,8 @@ retry: | |||
217 | * Get IO TLB memory from any location. | 217 | * Get IO TLB memory from any location. |
218 | */ | 218 | */ |
219 | if (early) | 219 | if (early) |
220 | xen_io_tlb_start = alloc_bootmem_pages(PAGE_ALIGN(bytes)); | 220 | xen_io_tlb_start = memblock_alloc(PAGE_ALIGN(bytes), |
221 | PAGE_SIZE); | ||
221 | else { | 222 | else { |
222 | #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) | 223 | #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) |
223 | #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) | 224 | #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) |
@@ -247,7 +248,8 @@ retry: | |||
247 | xen_io_tlb_nslabs); | 248 | xen_io_tlb_nslabs); |
248 | if (rc) { | 249 | if (rc) { |
249 | if (early) | 250 | if (early) |
250 | free_bootmem(__pa(xen_io_tlb_start), PAGE_ALIGN(bytes)); | 251 | memblock_free(__pa(xen_io_tlb_start), |
252 | PAGE_ALIGN(bytes)); | ||
251 | else { | 253 | else { |
252 | free_pages((unsigned long)xen_io_tlb_start, order); | 254 | free_pages((unsigned long)xen_io_tlb_start, order); |
253 | xen_io_tlb_start = NULL; | 255 | xen_io_tlb_start = NULL; |
diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c index 55988b8418ee..5165aa82bf7d 100644 --- a/drivers/xen/xen-selfballoon.c +++ b/drivers/xen/xen-selfballoon.c | |||
@@ -68,7 +68,7 @@ | |||
68 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 68 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
69 | 69 | ||
70 | #include <linux/kernel.h> | 70 | #include <linux/kernel.h> |
71 | #include <linux/bootmem.h> | 71 | #include <linux/memblock.h> |
72 | #include <linux/swap.h> | 72 | #include <linux/swap.h> |
73 | #include <linux/mm.h> | 73 | #include <linux/mm.h> |
74 | #include <linux/mman.h> | 74 | #include <linux/mman.h> |
diff --git a/fs/dcache.c b/fs/dcache.c index c2e443fb76ae..2593153471cf 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/export.h> | 26 | #include <linux/export.h> |
27 | #include <linux/security.h> | 27 | #include <linux/security.h> |
28 | #include <linux/seqlock.h> | 28 | #include <linux/seqlock.h> |
29 | #include <linux/bootmem.h> | 29 | #include <linux/memblock.h> |
30 | #include <linux/bit_spinlock.h> | 30 | #include <linux/bit_spinlock.h> |
31 | #include <linux/rculist_bl.h> | 31 | #include <linux/rculist_bl.h> |
32 | #include <linux/list_lru.h> | 32 | #include <linux/list_lru.h> |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 7f5f3699fc6c..c8366cb8eccd 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -369,7 +369,9 @@ static int fat_parse_short(struct super_block *sb, | |||
369 | } | 369 | } |
370 | 370 | ||
371 | memcpy(work, de->name, sizeof(work)); | 371 | memcpy(work, de->name, sizeof(work)); |
372 | /* see namei.c, msdos_format_name */ | 372 | /* For an explanation of the special treatment of 0x05 in |
373 | * filenames, see msdos_format_name in namei_msdos.c | ||
374 | */ | ||
373 | if (work[0] == 0x05) | 375 | if (work[0] == 0x05) |
374 | work[0] = 0xE5; | 376 | work[0] = 0xE5; |
375 | 377 | ||
@@ -1071,7 +1073,7 @@ int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo) | |||
1071 | } | 1073 | } |
1072 | } | 1074 | } |
1073 | 1075 | ||
1074 | dir->i_mtime = dir->i_atime = current_time(dir); | 1076 | fat_truncate_time(dir, NULL, S_ATIME|S_MTIME); |
1075 | if (IS_DIRSYNC(dir)) | 1077 | if (IS_DIRSYNC(dir)) |
1076 | (void)fat_sync_inode(dir); | 1078 | (void)fat_sync_inode(dir); |
1077 | else | 1079 | else |
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index 9d7d2d5da28b..4e1b2f6df5e6 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
@@ -416,6 +416,10 @@ extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, | |||
416 | __le16 __time, __le16 __date, u8 time_cs); | 416 | __le16 __time, __le16 __date, u8 time_cs); |
417 | extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts, | 417 | extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts, |
418 | __le16 *time, __le16 *date, u8 *time_cs); | 418 | __le16 *time, __le16 *date, u8 *time_cs); |
419 | extern int fat_truncate_time(struct inode *inode, struct timespec64 *now, | ||
420 | int flags); | ||
421 | extern int fat_update_time(struct inode *inode, struct timespec64 *now, | ||
422 | int flags); | ||
419 | extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs); | 423 | extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs); |
420 | 424 | ||
421 | int fat_cache_init(void); | 425 | int fat_cache_init(void); |
diff --git a/fs/fat/file.c b/fs/fat/file.c index 4f3d72fb1e60..13935ee99e1e 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -227,7 +227,7 @@ static int fat_cont_expand(struct inode *inode, loff_t size) | |||
227 | if (err) | 227 | if (err) |
228 | goto out; | 228 | goto out; |
229 | 229 | ||
230 | inode->i_ctime = inode->i_mtime = current_time(inode); | 230 | fat_truncate_time(inode, NULL, S_CTIME|S_MTIME); |
231 | mark_inode_dirty(inode); | 231 | mark_inode_dirty(inode); |
232 | if (IS_SYNC(inode)) { | 232 | if (IS_SYNC(inode)) { |
233 | int err2; | 233 | int err2; |
@@ -330,7 +330,7 @@ static int fat_free(struct inode *inode, int skip) | |||
330 | MSDOS_I(inode)->i_logstart = 0; | 330 | MSDOS_I(inode)->i_logstart = 0; |
331 | } | 331 | } |
332 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; | 332 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; |
333 | inode->i_ctime = inode->i_mtime = current_time(inode); | 333 | fat_truncate_time(inode, NULL, S_CTIME|S_MTIME); |
334 | if (wait) { | 334 | if (wait) { |
335 | err = fat_sync_inode(inode); | 335 | err = fat_sync_inode(inode); |
336 | if (err) { | 336 | if (err) { |
@@ -542,6 +542,18 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
542 | up_write(&MSDOS_I(inode)->truncate_lock); | 542 | up_write(&MSDOS_I(inode)->truncate_lock); |
543 | } | 543 | } |
544 | 544 | ||
545 | /* | ||
546 | * setattr_copy can't truncate these appropriately, so we'll | ||
547 | * copy them ourselves | ||
548 | */ | ||
549 | if (attr->ia_valid & ATTR_ATIME) | ||
550 | fat_truncate_time(inode, &attr->ia_atime, S_ATIME); | ||
551 | if (attr->ia_valid & ATTR_CTIME) | ||
552 | fat_truncate_time(inode, &attr->ia_ctime, S_CTIME); | ||
553 | if (attr->ia_valid & ATTR_MTIME) | ||
554 | fat_truncate_time(inode, &attr->ia_mtime, S_MTIME); | ||
555 | attr->ia_valid &= ~(ATTR_ATIME|ATTR_CTIME|ATTR_MTIME); | ||
556 | |||
545 | setattr_copy(inode, attr); | 557 | setattr_copy(inode, attr); |
546 | mark_inode_dirty(inode); | 558 | mark_inode_dirty(inode); |
547 | out: | 559 | out: |
@@ -552,4 +564,5 @@ EXPORT_SYMBOL_GPL(fat_setattr); | |||
552 | const struct inode_operations fat_file_inode_operations = { | 564 | const struct inode_operations fat_file_inode_operations = { |
553 | .setattr = fat_setattr, | 565 | .setattr = fat_setattr, |
554 | .getattr = fat_getattr, | 566 | .getattr = fat_getattr, |
567 | .update_time = fat_update_time, | ||
555 | }; | 568 | }; |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index d6b81e31f9f5..c0b5b5c3373b 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -244,7 +244,7 @@ static int fat_write_end(struct file *file, struct address_space *mapping, | |||
244 | if (err < len) | 244 | if (err < len) |
245 | fat_write_failed(mapping, pos + len); | 245 | fat_write_failed(mapping, pos + len); |
246 | if (!(err < 0) && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) { | 246 | if (!(err < 0) && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) { |
247 | inode->i_mtime = inode->i_ctime = current_time(inode); | 247 | fat_truncate_time(inode, NULL, S_CTIME|S_MTIME); |
248 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; | 248 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; |
249 | mark_inode_dirty(inode); | 249 | mark_inode_dirty(inode); |
250 | } | 250 | } |
@@ -564,7 +564,7 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
564 | de->cdate, de->ctime_cs); | 564 | de->cdate, de->ctime_cs); |
565 | fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0); | 565 | fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0); |
566 | } else | 566 | } else |
567 | inode->i_ctime = inode->i_atime = inode->i_mtime; | 567 | fat_truncate_time(inode, &inode->i_mtime, S_ATIME|S_CTIME); |
568 | 568 | ||
569 | return 0; | 569 | return 0; |
570 | } | 570 | } |
@@ -1626,6 +1626,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, | |||
1626 | sb->s_magic = MSDOS_SUPER_MAGIC; | 1626 | sb->s_magic = MSDOS_SUPER_MAGIC; |
1627 | sb->s_op = &fat_sops; | 1627 | sb->s_op = &fat_sops; |
1628 | sb->s_export_op = &fat_export_ops; | 1628 | sb->s_export_op = &fat_export_ops; |
1629 | /* | ||
1630 | * fat timestamps are complex and truncated by fat itself, so | ||
1631 | * we set 1 here to be fast | ||
1632 | */ | ||
1633 | sb->s_time_gran = 1; | ||
1629 | mutex_init(&sbi->nfs_build_inode_lock); | 1634 | mutex_init(&sbi->nfs_build_inode_lock); |
1630 | ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, | 1635 | ratelimit_state_init(&sbi->ratelimit, DEFAULT_RATELIMIT_INTERVAL, |
1631 | DEFAULT_RATELIMIT_BURST); | 1636 | DEFAULT_RATELIMIT_BURST); |
diff --git a/fs/fat/misc.c b/fs/fat/misc.c index 573836dcaefc..fce0a76f3f1e 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "fat.h" | 9 | #include "fat.h" |
10 | #include <linux/iversion.h> | ||
10 | 11 | ||
11 | /* | 12 | /* |
12 | * fat_fs_error reports a file system problem that might indicate fa data | 13 | * fat_fs_error reports a file system problem that might indicate fa data |
@@ -185,6 +186,13 @@ static long days_in_year[] = { | |||
185 | 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, | 186 | 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, |
186 | }; | 187 | }; |
187 | 188 | ||
189 | static inline int fat_tz_offset(struct msdos_sb_info *sbi) | ||
190 | { | ||
191 | return (sbi->options.tz_set ? | ||
192 | -sbi->options.time_offset : | ||
193 | sys_tz.tz_minuteswest) * SECS_PER_MIN; | ||
194 | } | ||
195 | |||
188 | /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ | 196 | /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ |
189 | void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, | 197 | void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, |
190 | __le16 __time, __le16 __date, u8 time_cs) | 198 | __le16 __time, __le16 __date, u8 time_cs) |
@@ -210,10 +218,7 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, | |||
210 | + days_in_year[month] + day | 218 | + days_in_year[month] + day |
211 | + DAYS_DELTA) * SECS_PER_DAY; | 219 | + DAYS_DELTA) * SECS_PER_DAY; |
212 | 220 | ||
213 | if (!sbi->options.tz_set) | 221 | second += fat_tz_offset(sbi); |
214 | second += sys_tz.tz_minuteswest * SECS_PER_MIN; | ||
215 | else | ||
216 | second -= sbi->options.time_offset * SECS_PER_MIN; | ||
217 | 222 | ||
218 | if (time_cs) { | 223 | if (time_cs) { |
219 | ts->tv_sec = second + (time_cs / 100); | 224 | ts->tv_sec = second + (time_cs / 100); |
@@ -229,9 +234,7 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts, | |||
229 | __le16 *time, __le16 *date, u8 *time_cs) | 234 | __le16 *time, __le16 *date, u8 *time_cs) |
230 | { | 235 | { |
231 | struct tm tm; | 236 | struct tm tm; |
232 | time64_to_tm(ts->tv_sec, | 237 | time64_to_tm(ts->tv_sec, -fat_tz_offset(sbi), &tm); |
233 | (sbi->options.tz_set ? sbi->options.time_offset : | ||
234 | -sys_tz.tz_minuteswest) * SECS_PER_MIN, &tm); | ||
235 | 238 | ||
236 | /* FAT can only support year between 1980 to 2107 */ | 239 | /* FAT can only support year between 1980 to 2107 */ |
237 | if (tm.tm_year < 1980 - 1900) { | 240 | if (tm.tm_year < 1980 - 1900) { |
@@ -263,6 +266,80 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts, | |||
263 | } | 266 | } |
264 | EXPORT_SYMBOL_GPL(fat_time_unix2fat); | 267 | EXPORT_SYMBOL_GPL(fat_time_unix2fat); |
265 | 268 | ||
269 | static inline struct timespec64 fat_timespec64_trunc_2secs(struct timespec64 ts) | ||
270 | { | ||
271 | return (struct timespec64){ ts.tv_sec & ~1ULL, 0 }; | ||
272 | } | ||
273 | /* | ||
274 | * truncate the various times with appropriate granularity: | ||
275 | * root inode: | ||
276 | * all times always 0 | ||
277 | * all other inodes: | ||
278 | * mtime - 2 seconds | ||
279 | * ctime | ||
280 | * msdos - 2 seconds | ||
281 | * vfat - 10 milliseconds | ||
282 | * atime - 24 hours (00:00:00 in local timezone) | ||
283 | */ | ||
284 | int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags) | ||
285 | { | ||
286 | struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); | ||
287 | struct timespec64 ts; | ||
288 | |||
289 | if (inode->i_ino == MSDOS_ROOT_INO) | ||
290 | return 0; | ||
291 | |||
292 | if (now == NULL) { | ||
293 | now = &ts; | ||
294 | ts = current_time(inode); | ||
295 | } | ||
296 | |||
297 | if (flags & S_ATIME) { | ||
298 | /* to localtime */ | ||
299 | time64_t seconds = now->tv_sec - fat_tz_offset(sbi); | ||
300 | s32 remainder; | ||
301 | |||
302 | div_s64_rem(seconds, SECS_PER_DAY, &remainder); | ||
303 | /* to day boundary, and back to unix time */ | ||
304 | seconds = seconds + fat_tz_offset(sbi) - remainder; | ||
305 | |||
306 | inode->i_atime = (struct timespec64){ seconds, 0 }; | ||
307 | } | ||
308 | if (flags & S_CTIME) { | ||
309 | if (sbi->options.isvfat) | ||
310 | inode->i_ctime = timespec64_trunc(*now, 10000000); | ||
311 | else | ||
312 | inode->i_ctime = fat_timespec64_trunc_2secs(*now); | ||
313 | } | ||
314 | if (flags & S_MTIME) | ||
315 | inode->i_mtime = fat_timespec64_trunc_2secs(*now); | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | EXPORT_SYMBOL_GPL(fat_truncate_time); | ||
320 | |||
321 | int fat_update_time(struct inode *inode, struct timespec64 *now, int flags) | ||
322 | { | ||
323 | int iflags = I_DIRTY_TIME; | ||
324 | bool dirty = false; | ||
325 | |||
326 | if (inode->i_ino == MSDOS_ROOT_INO) | ||
327 | return 0; | ||
328 | |||
329 | fat_truncate_time(inode, now, flags); | ||
330 | if (flags & S_VERSION) | ||
331 | dirty = inode_maybe_inc_iversion(inode, false); | ||
332 | if ((flags & (S_ATIME | S_CTIME | S_MTIME)) && | ||
333 | !(inode->i_sb->s_flags & SB_LAZYTIME)) | ||
334 | dirty = true; | ||
335 | |||
336 | if (dirty) | ||
337 | iflags |= I_DIRTY_SYNC; | ||
338 | __mark_inode_dirty(inode, iflags); | ||
339 | return 0; | ||
340 | } | ||
341 | EXPORT_SYMBOL_GPL(fat_update_time); | ||
342 | |||
266 | int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs) | 343 | int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs) |
267 | { | 344 | { |
268 | int i, err = 0; | 345 | int i, err = 0; |
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index efb8c40c9d27..f2cd365a4e86 100644 --- a/fs/fat/namei_msdos.c +++ b/fs/fat/namei_msdos.c | |||
@@ -250,7 +250,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name, | |||
250 | if (err) | 250 | if (err) |
251 | return err; | 251 | return err; |
252 | 252 | ||
253 | dir->i_ctime = dir->i_mtime = *ts; | 253 | fat_truncate_time(dir, ts, S_CTIME|S_MTIME); |
254 | if (IS_DIRSYNC(dir)) | 254 | if (IS_DIRSYNC(dir)) |
255 | (void)fat_sync_inode(dir); | 255 | (void)fat_sync_inode(dir); |
256 | else | 256 | else |
@@ -294,7 +294,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode, | |||
294 | err = PTR_ERR(inode); | 294 | err = PTR_ERR(inode); |
295 | goto out; | 295 | goto out; |
296 | } | 296 | } |
297 | inode->i_mtime = inode->i_atime = inode->i_ctime = ts; | 297 | fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME); |
298 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ | 298 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ |
299 | 299 | ||
300 | d_instantiate(dentry, inode); | 300 | d_instantiate(dentry, inode); |
@@ -327,7 +327,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry) | |||
327 | drop_nlink(dir); | 327 | drop_nlink(dir); |
328 | 328 | ||
329 | clear_nlink(inode); | 329 | clear_nlink(inode); |
330 | inode->i_ctime = current_time(inode); | 330 | fat_truncate_time(inode, NULL, S_CTIME); |
331 | fat_detach(inode); | 331 | fat_detach(inode); |
332 | out: | 332 | out: |
333 | mutex_unlock(&MSDOS_SB(sb)->s_lock); | 333 | mutex_unlock(&MSDOS_SB(sb)->s_lock); |
@@ -380,7 +380,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
380 | goto out; | 380 | goto out; |
381 | } | 381 | } |
382 | set_nlink(inode, 2); | 382 | set_nlink(inode, 2); |
383 | inode->i_mtime = inode->i_atime = inode->i_ctime = ts; | 383 | fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME); |
384 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ | 384 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ |
385 | 385 | ||
386 | d_instantiate(dentry, inode); | 386 | d_instantiate(dentry, inode); |
@@ -413,7 +413,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry) | |||
413 | if (err) | 413 | if (err) |
414 | goto out; | 414 | goto out; |
415 | clear_nlink(inode); | 415 | clear_nlink(inode); |
416 | inode->i_ctime = current_time(inode); | 416 | fat_truncate_time(inode, NULL, S_CTIME); |
417 | fat_detach(inode); | 417 | fat_detach(inode); |
418 | out: | 418 | out: |
419 | mutex_unlock(&MSDOS_SB(sb)->s_lock); | 419 | mutex_unlock(&MSDOS_SB(sb)->s_lock); |
@@ -478,7 +478,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, | |||
478 | mark_inode_dirty(old_inode); | 478 | mark_inode_dirty(old_inode); |
479 | 479 | ||
480 | inode_inc_iversion(old_dir); | 480 | inode_inc_iversion(old_dir); |
481 | old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir); | 481 | fat_truncate_time(old_dir, NULL, S_CTIME|S_MTIME); |
482 | if (IS_DIRSYNC(old_dir)) | 482 | if (IS_DIRSYNC(old_dir)) |
483 | (void)fat_sync_inode(old_dir); | 483 | (void)fat_sync_inode(old_dir); |
484 | else | 484 | else |
@@ -538,7 +538,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, | |||
538 | if (err) | 538 | if (err) |
539 | goto error_dotdot; | 539 | goto error_dotdot; |
540 | inode_inc_iversion(old_dir); | 540 | inode_inc_iversion(old_dir); |
541 | old_dir->i_ctime = old_dir->i_mtime = ts; | 541 | fat_truncate_time(old_dir, &ts, S_CTIME|S_MTIME); |
542 | if (IS_DIRSYNC(old_dir)) | 542 | if (IS_DIRSYNC(old_dir)) |
543 | (void)fat_sync_inode(old_dir); | 543 | (void)fat_sync_inode(old_dir); |
544 | else | 544 | else |
@@ -548,7 +548,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, | |||
548 | drop_nlink(new_inode); | 548 | drop_nlink(new_inode); |
549 | if (is_dir) | 549 | if (is_dir) |
550 | drop_nlink(new_inode); | 550 | drop_nlink(new_inode); |
551 | new_inode->i_ctime = ts; | 551 | fat_truncate_time(new_inode, &ts, S_CTIME); |
552 | } | 552 | } |
553 | out: | 553 | out: |
554 | brelse(sinfo.bh); | 554 | brelse(sinfo.bh); |
@@ -637,6 +637,7 @@ static const struct inode_operations msdos_dir_inode_operations = { | |||
637 | .rename = msdos_rename, | 637 | .rename = msdos_rename, |
638 | .setattr = fat_setattr, | 638 | .setattr = fat_setattr, |
639 | .getattr = fat_getattr, | 639 | .getattr = fat_getattr, |
640 | .update_time = fat_update_time, | ||
640 | }; | 641 | }; |
641 | 642 | ||
642 | static void setup(struct super_block *sb) | 643 | static void setup(struct super_block *sb) |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index 82cd1e69cbdf..996c8c25e9c6 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -678,7 +678,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname, | |||
678 | goto cleanup; | 678 | goto cleanup; |
679 | 679 | ||
680 | /* update timestamp */ | 680 | /* update timestamp */ |
681 | dir->i_ctime = dir->i_mtime = dir->i_atime = *ts; | 681 | fat_truncate_time(dir, ts, S_CTIME|S_MTIME); |
682 | if (IS_DIRSYNC(dir)) | 682 | if (IS_DIRSYNC(dir)) |
683 | (void)fat_sync_inode(dir); | 683 | (void)fat_sync_inode(dir); |
684 | else | 684 | else |
@@ -779,7 +779,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, | |||
779 | goto out; | 779 | goto out; |
780 | } | 780 | } |
781 | inode_inc_iversion(inode); | 781 | inode_inc_iversion(inode); |
782 | inode->i_mtime = inode->i_atime = inode->i_ctime = ts; | 782 | fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME); |
783 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ | 783 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ |
784 | 784 | ||
785 | d_instantiate(dentry, inode); | 785 | d_instantiate(dentry, inode); |
@@ -810,7 +810,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry) | |||
810 | drop_nlink(dir); | 810 | drop_nlink(dir); |
811 | 811 | ||
812 | clear_nlink(inode); | 812 | clear_nlink(inode); |
813 | inode->i_mtime = inode->i_atime = current_time(inode); | 813 | fat_truncate_time(inode, NULL, S_ATIME|S_MTIME); |
814 | fat_detach(inode); | 814 | fat_detach(inode); |
815 | vfat_d_version_set(dentry, inode_query_iversion(dir)); | 815 | vfat_d_version_set(dentry, inode_query_iversion(dir)); |
816 | out: | 816 | out: |
@@ -836,7 +836,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry) | |||
836 | if (err) | 836 | if (err) |
837 | goto out; | 837 | goto out; |
838 | clear_nlink(inode); | 838 | clear_nlink(inode); |
839 | inode->i_mtime = inode->i_atime = current_time(inode); | 839 | fat_truncate_time(inode, NULL, S_ATIME|S_MTIME); |
840 | fat_detach(inode); | 840 | fat_detach(inode); |
841 | vfat_d_version_set(dentry, inode_query_iversion(dir)); | 841 | vfat_d_version_set(dentry, inode_query_iversion(dir)); |
842 | out: | 842 | out: |
@@ -876,7 +876,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
876 | } | 876 | } |
877 | inode_inc_iversion(inode); | 877 | inode_inc_iversion(inode); |
878 | set_nlink(inode, 2); | 878 | set_nlink(inode, 2); |
879 | inode->i_mtime = inode->i_atime = inode->i_ctime = ts; | 879 | fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME); |
880 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ | 880 | /* timestamp is already written, so mark_inode_dirty() is unneeded. */ |
881 | 881 | ||
882 | d_instantiate(dentry, inode); | 882 | d_instantiate(dentry, inode); |
@@ -969,7 +969,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
969 | if (err) | 969 | if (err) |
970 | goto error_dotdot; | 970 | goto error_dotdot; |
971 | inode_inc_iversion(old_dir); | 971 | inode_inc_iversion(old_dir); |
972 | old_dir->i_ctime = old_dir->i_mtime = ts; | 972 | fat_truncate_time(old_dir, &ts, S_CTIME|S_MTIME); |
973 | if (IS_DIRSYNC(old_dir)) | 973 | if (IS_DIRSYNC(old_dir)) |
974 | (void)fat_sync_inode(old_dir); | 974 | (void)fat_sync_inode(old_dir); |
975 | else | 975 | else |
@@ -979,7 +979,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
979 | drop_nlink(new_inode); | 979 | drop_nlink(new_inode); |
980 | if (is_dir) | 980 | if (is_dir) |
981 | drop_nlink(new_inode); | 981 | drop_nlink(new_inode); |
982 | new_inode->i_ctime = ts; | 982 | fat_truncate_time(new_inode, &ts, S_CTIME); |
983 | } | 983 | } |
984 | out: | 984 | out: |
985 | brelse(sinfo.bh); | 985 | brelse(sinfo.bh); |
@@ -1032,6 +1032,7 @@ static const struct inode_operations vfat_dir_inode_operations = { | |||
1032 | .rename = vfat_rename, | 1032 | .rename = vfat_rename, |
1033 | .setattr = fat_setattr, | 1033 | .setattr = fat_setattr, |
1034 | .getattr = fat_getattr, | 1034 | .getattr = fat_getattr, |
1035 | .update_time = fat_update_time, | ||
1035 | }; | 1036 | }; |
1036 | 1037 | ||
1037 | static void setup(struct super_block *sb) | 1038 | static void setup(struct super_block *sb) |
diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c index 9a8772465a90..896396554bcc 100644 --- a/fs/hfs/brec.c +++ b/fs/hfs/brec.c | |||
@@ -425,6 +425,10 @@ skip: | |||
425 | if (new_node) { | 425 | if (new_node) { |
426 | __be32 cnid; | 426 | __be32 cnid; |
427 | 427 | ||
428 | if (!new_node->parent) { | ||
429 | hfs_btree_inc_height(tree); | ||
430 | new_node->parent = tree->root; | ||
431 | } | ||
428 | fd->bnode = hfs_bnode_find(tree, new_node->parent); | 432 | fd->bnode = hfs_bnode_find(tree, new_node->parent); |
429 | /* create index key and entry */ | 433 | /* create index key and entry */ |
430 | hfs_bnode_read_key(new_node, fd->search_key, 14); | 434 | hfs_bnode_read_key(new_node, fd->search_key, 14); |
@@ -441,6 +445,7 @@ skip: | |||
441 | /* restore search_key */ | 445 | /* restore search_key */ |
442 | hfs_bnode_read_key(node, fd->search_key, 14); | 446 | hfs_bnode_read_key(node, fd->search_key, 14); |
443 | } | 447 | } |
448 | new_node = NULL; | ||
444 | } | 449 | } |
445 | 450 | ||
446 | if (!rec && node->parent) | 451 | if (!rec && node->parent) |
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c index 374b5688e29e..98b96ffb95ed 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c | |||
@@ -220,25 +220,17 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx) | |||
220 | return node; | 220 | return node; |
221 | } | 221 | } |
222 | 222 | ||
223 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | 223 | /* Make sure @tree has enough space for the @rsvd_nodes */ |
224 | int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes) | ||
224 | { | 225 | { |
225 | struct hfs_bnode *node, *next_node; | 226 | struct inode *inode = tree->inode; |
226 | struct page **pagep; | 227 | u32 count; |
227 | u32 nidx, idx; | 228 | int res; |
228 | unsigned off; | ||
229 | u16 off16; | ||
230 | u16 len; | ||
231 | u8 *data, byte, m; | ||
232 | int i; | ||
233 | |||
234 | while (!tree->free_nodes) { | ||
235 | struct inode *inode = tree->inode; | ||
236 | u32 count; | ||
237 | int res; | ||
238 | 229 | ||
230 | while (tree->free_nodes < rsvd_nodes) { | ||
239 | res = hfs_extend_file(inode); | 231 | res = hfs_extend_file(inode); |
240 | if (res) | 232 | if (res) |
241 | return ERR_PTR(res); | 233 | return res; |
242 | HFS_I(inode)->phys_size = inode->i_size = | 234 | HFS_I(inode)->phys_size = inode->i_size = |
243 | (loff_t)HFS_I(inode)->alloc_blocks * | 235 | (loff_t)HFS_I(inode)->alloc_blocks * |
244 | HFS_SB(tree->sb)->alloc_blksz; | 236 | HFS_SB(tree->sb)->alloc_blksz; |
@@ -246,9 +238,26 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | |||
246 | tree->sb->s_blocksize_bits; | 238 | tree->sb->s_blocksize_bits; |
247 | inode_set_bytes(inode, inode->i_size); | 239 | inode_set_bytes(inode, inode->i_size); |
248 | count = inode->i_size >> tree->node_size_shift; | 240 | count = inode->i_size >> tree->node_size_shift; |
249 | tree->free_nodes = count - tree->node_count; | 241 | tree->free_nodes += count - tree->node_count; |
250 | tree->node_count = count; | 242 | tree->node_count = count; |
251 | } | 243 | } |
244 | return 0; | ||
245 | } | ||
246 | |||
247 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | ||
248 | { | ||
249 | struct hfs_bnode *node, *next_node; | ||
250 | struct page **pagep; | ||
251 | u32 nidx, idx; | ||
252 | unsigned off; | ||
253 | u16 off16; | ||
254 | u16 len; | ||
255 | u8 *data, byte, m; | ||
256 | int i, res; | ||
257 | |||
258 | res = hfs_bmap_reserve(tree, 1); | ||
259 | if (res) | ||
260 | return ERR_PTR(res); | ||
252 | 261 | ||
253 | nidx = 0; | 262 | nidx = 0; |
254 | node = hfs_bnode_find(tree, nidx); | 263 | node = hfs_bnode_find(tree, nidx); |
diff --git a/fs/hfs/btree.h b/fs/hfs/btree.h index c8b252dbb26c..dcc2aab1b2c4 100644 --- a/fs/hfs/btree.h +++ b/fs/hfs/btree.h | |||
@@ -82,6 +82,7 @@ struct hfs_find_data { | |||
82 | extern struct hfs_btree *hfs_btree_open(struct super_block *, u32, btree_keycmp); | 82 | extern struct hfs_btree *hfs_btree_open(struct super_block *, u32, btree_keycmp); |
83 | extern void hfs_btree_close(struct hfs_btree *); | 83 | extern void hfs_btree_close(struct hfs_btree *); |
84 | extern void hfs_btree_write(struct hfs_btree *); | 84 | extern void hfs_btree_write(struct hfs_btree *); |
85 | extern int hfs_bmap_reserve(struct hfs_btree *, int); | ||
85 | extern struct hfs_bnode * hfs_bmap_alloc(struct hfs_btree *); | 86 | extern struct hfs_bnode * hfs_bmap_alloc(struct hfs_btree *); |
86 | extern void hfs_bmap_free(struct hfs_bnode *node); | 87 | extern void hfs_bmap_free(struct hfs_bnode *node); |
87 | 88 | ||
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c index 8a66405b0f8b..d365bf0b8c77 100644 --- a/fs/hfs/catalog.c +++ b/fs/hfs/catalog.c | |||
@@ -97,6 +97,14 @@ int hfs_cat_create(u32 cnid, struct inode *dir, const struct qstr *str, struct i | |||
97 | if (err) | 97 | if (err) |
98 | return err; | 98 | return err; |
99 | 99 | ||
100 | /* | ||
101 | * Fail early and avoid ENOSPC during the btree operations. We may | ||
102 | * have to split the root node at most once. | ||
103 | */ | ||
104 | err = hfs_bmap_reserve(fd.tree, 2 * fd.tree->depth); | ||
105 | if (err) | ||
106 | goto err2; | ||
107 | |||
100 | hfs_cat_build_key(sb, fd.search_key, cnid, NULL); | 108 | hfs_cat_build_key(sb, fd.search_key, cnid, NULL); |
101 | entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ? | 109 | entry_size = hfs_cat_build_thread(sb, &entry, S_ISDIR(inode->i_mode) ? |
102 | HFS_CDR_THD : HFS_CDR_FTH, | 110 | HFS_CDR_THD : HFS_CDR_FTH, |
@@ -295,6 +303,14 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const struct qstr *src_name, | |||
295 | return err; | 303 | return err; |
296 | dst_fd = src_fd; | 304 | dst_fd = src_fd; |
297 | 305 | ||
306 | /* | ||
307 | * Fail early and avoid ENOSPC during the btree operations. We may | ||
308 | * have to split the root node at most once. | ||
309 | */ | ||
310 | err = hfs_bmap_reserve(src_fd.tree, 2 * src_fd.tree->depth); | ||
311 | if (err) | ||
312 | goto out; | ||
313 | |||
298 | /* find the old dir entry and read the data */ | 314 | /* find the old dir entry and read the data */ |
299 | hfs_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name); | 315 | hfs_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name); |
300 | err = hfs_brec_find(&src_fd); | 316 | err = hfs_brec_find(&src_fd); |
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c index 5d0182654580..263d5028d9d1 100644 --- a/fs/hfs/extent.c +++ b/fs/hfs/extent.c | |||
@@ -117,6 +117,10 @@ static int __hfs_ext_write_extent(struct inode *inode, struct hfs_find_data *fd) | |||
117 | if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) { | 117 | if (HFS_I(inode)->flags & HFS_FLG_EXT_NEW) { |
118 | if (res != -ENOENT) | 118 | if (res != -ENOENT) |
119 | return res; | 119 | return res; |
120 | /* Fail early and avoid ENOSPC during the btree operation */ | ||
121 | res = hfs_bmap_reserve(fd->tree, fd->tree->depth + 1); | ||
122 | if (res) | ||
123 | return res; | ||
120 | hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec)); | 124 | hfs_brec_insert(fd, HFS_I(inode)->cached_extents, sizeof(hfs_extent_rec)); |
121 | HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW); | 125 | HFS_I(inode)->flags &= ~(HFS_FLG_EXT_DIRTY|HFS_FLG_EXT_NEW); |
122 | } else { | 126 | } else { |
@@ -300,7 +304,7 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type) | |||
300 | return 0; | 304 | return 0; |
301 | 305 | ||
302 | blocks = 0; | 306 | blocks = 0; |
303 | for (i = 0; i < 3; extent++, i++) | 307 | for (i = 0; i < 3; i++) |
304 | blocks += be16_to_cpu(extent[i].count); | 308 | blocks += be16_to_cpu(extent[i].count); |
305 | 309 | ||
306 | res = hfs_free_extents(sb, extent, blocks, blocks); | 310 | res = hfs_free_extents(sb, extent, blocks, blocks); |
@@ -341,7 +345,9 @@ int hfs_get_block(struct inode *inode, sector_t block, | |||
341 | ablock = (u32)block / HFS_SB(sb)->fs_div; | 345 | ablock = (u32)block / HFS_SB(sb)->fs_div; |
342 | 346 | ||
343 | if (block >= HFS_I(inode)->fs_blocks) { | 347 | if (block >= HFS_I(inode)->fs_blocks) { |
344 | if (block > HFS_I(inode)->fs_blocks || !create) | 348 | if (!create) |
349 | return 0; | ||
350 | if (block > HFS_I(inode)->fs_blocks) | ||
345 | return -EIO; | 351 | return -EIO; |
346 | if (ablock >= HFS_I(inode)->alloc_blocks) { | 352 | if (ablock >= HFS_I(inode)->alloc_blocks) { |
347 | res = hfs_extend_file(inode); | 353 | res = hfs_extend_file(inode); |
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index a2dfa1b2a89c..da243c84e93b 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -642,6 +642,8 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr) | |||
642 | 642 | ||
643 | truncate_setsize(inode, attr->ia_size); | 643 | truncate_setsize(inode, attr->ia_size); |
644 | hfs_file_truncate(inode); | 644 | hfs_file_truncate(inode); |
645 | inode->i_atime = inode->i_mtime = inode->i_ctime = | ||
646 | current_time(inode); | ||
645 | } | 647 | } |
646 | 648 | ||
647 | setattr_copy(inode, attr); | 649 | setattr_copy(inode, attr); |
diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c index 2bab6b3cdba4..e6d554476db4 100644 --- a/fs/hfsplus/attributes.c +++ b/fs/hfsplus/attributes.c | |||
@@ -217,6 +217,11 @@ int hfsplus_create_attr(struct inode *inode, | |||
217 | if (err) | 217 | if (err) |
218 | goto failed_init_create_attr; | 218 | goto failed_init_create_attr; |
219 | 219 | ||
220 | /* Fail early and avoid ENOSPC during the btree operation */ | ||
221 | err = hfs_bmap_reserve(fd.tree, fd.tree->depth + 1); | ||
222 | if (err) | ||
223 | goto failed_create_attr; | ||
224 | |||
220 | if (name) { | 225 | if (name) { |
221 | err = hfsplus_attr_build_key(sb, fd.search_key, | 226 | err = hfsplus_attr_build_key(sb, fd.search_key, |
222 | inode->i_ino, name); | 227 | inode->i_ino, name); |
@@ -313,6 +318,11 @@ int hfsplus_delete_attr(struct inode *inode, const char *name) | |||
313 | if (err) | 318 | if (err) |
314 | return err; | 319 | return err; |
315 | 320 | ||
321 | /* Fail early and avoid ENOSPC during the btree operation */ | ||
322 | err = hfs_bmap_reserve(fd.tree, fd.tree->depth); | ||
323 | if (err) | ||
324 | goto out; | ||
325 | |||
316 | if (name) { | 326 | if (name) { |
317 | err = hfsplus_attr_build_key(sb, fd.search_key, | 327 | err = hfsplus_attr_build_key(sb, fd.search_key, |
318 | inode->i_ino, name); | 328 | inode->i_ino, name); |
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c index ed8eacb34452..1918544a7871 100644 --- a/fs/hfsplus/brec.c +++ b/fs/hfsplus/brec.c | |||
@@ -429,6 +429,10 @@ skip: | |||
429 | if (new_node) { | 429 | if (new_node) { |
430 | __be32 cnid; | 430 | __be32 cnid; |
431 | 431 | ||
432 | if (!new_node->parent) { | ||
433 | hfs_btree_inc_height(tree); | ||
434 | new_node->parent = tree->root; | ||
435 | } | ||
432 | fd->bnode = hfs_bnode_find(tree, new_node->parent); | 436 | fd->bnode = hfs_bnode_find(tree, new_node->parent); |
433 | /* create index key and entry */ | 437 | /* create index key and entry */ |
434 | hfs_bnode_read_key(new_node, fd->search_key, 14); | 438 | hfs_bnode_read_key(new_node, fd->search_key, 14); |
@@ -445,6 +449,7 @@ skip: | |||
445 | /* restore search_key */ | 449 | /* restore search_key */ |
446 | hfs_bnode_read_key(node, fd->search_key, 14); | 450 | hfs_bnode_read_key(node, fd->search_key, 14); |
447 | } | 451 | } |
452 | new_node = NULL; | ||
448 | } | 453 | } |
449 | 454 | ||
450 | if (!rec && node->parent) | 455 | if (!rec && node->parent) |
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index de14b2b6881b..236efe51eca6 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c | |||
@@ -342,26 +342,21 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx) | |||
342 | return node; | 342 | return node; |
343 | } | 343 | } |
344 | 344 | ||
345 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | 345 | /* Make sure @tree has enough space for the @rsvd_nodes */ |
346 | int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes) | ||
346 | { | 347 | { |
347 | struct hfs_bnode *node, *next_node; | 348 | struct inode *inode = tree->inode; |
348 | struct page **pagep; | 349 | struct hfsplus_inode_info *hip = HFSPLUS_I(inode); |
349 | u32 nidx, idx; | 350 | u32 count; |
350 | unsigned off; | 351 | int res; |
351 | u16 off16; | ||
352 | u16 len; | ||
353 | u8 *data, byte, m; | ||
354 | int i; | ||
355 | 352 | ||
356 | while (!tree->free_nodes) { | 353 | if (rsvd_nodes <= 0) |
357 | struct inode *inode = tree->inode; | 354 | return 0; |
358 | struct hfsplus_inode_info *hip = HFSPLUS_I(inode); | ||
359 | u32 count; | ||
360 | int res; | ||
361 | 355 | ||
356 | while (tree->free_nodes < rsvd_nodes) { | ||
362 | res = hfsplus_file_extend(inode, hfs_bnode_need_zeroout(tree)); | 357 | res = hfsplus_file_extend(inode, hfs_bnode_need_zeroout(tree)); |
363 | if (res) | 358 | if (res) |
364 | return ERR_PTR(res); | 359 | return res; |
365 | hip->phys_size = inode->i_size = | 360 | hip->phys_size = inode->i_size = |
366 | (loff_t)hip->alloc_blocks << | 361 | (loff_t)hip->alloc_blocks << |
367 | HFSPLUS_SB(tree->sb)->alloc_blksz_shift; | 362 | HFSPLUS_SB(tree->sb)->alloc_blksz_shift; |
@@ -369,9 +364,26 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | |||
369 | hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift; | 364 | hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift; |
370 | inode_set_bytes(inode, inode->i_size); | 365 | inode_set_bytes(inode, inode->i_size); |
371 | count = inode->i_size >> tree->node_size_shift; | 366 | count = inode->i_size >> tree->node_size_shift; |
372 | tree->free_nodes = count - tree->node_count; | 367 | tree->free_nodes += count - tree->node_count; |
373 | tree->node_count = count; | 368 | tree->node_count = count; |
374 | } | 369 | } |
370 | return 0; | ||
371 | } | ||
372 | |||
373 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree) | ||
374 | { | ||
375 | struct hfs_bnode *node, *next_node; | ||
376 | struct page **pagep; | ||
377 | u32 nidx, idx; | ||
378 | unsigned off; | ||
379 | u16 off16; | ||
380 | u16 len; | ||
381 | u8 *data, byte, m; | ||
382 | int i, res; | ||
383 | |||
384 | res = hfs_bmap_reserve(tree, 1); | ||
385 | if (res) | ||
386 | return ERR_PTR(res); | ||
375 | 387 | ||
376 | nidx = 0; | 388 | nidx = 0; |
377 | node = hfs_bnode_find(tree, nidx); | 389 | node = hfs_bnode_find(tree, nidx); |
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c index a196369ba779..35472cba750e 100644 --- a/fs/hfsplus/catalog.c +++ b/fs/hfsplus/catalog.c | |||
@@ -265,6 +265,14 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, | |||
265 | if (err) | 265 | if (err) |
266 | return err; | 266 | return err; |
267 | 267 | ||
268 | /* | ||
269 | * Fail early and avoid ENOSPC during the btree operations. We may | ||
270 | * have to split the root node at most once. | ||
271 | */ | ||
272 | err = hfs_bmap_reserve(fd.tree, 2 * fd.tree->depth); | ||
273 | if (err) | ||
274 | goto err2; | ||
275 | |||
268 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid); | 276 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid); |
269 | entry_size = hfsplus_fill_cat_thread(sb, &entry, | 277 | entry_size = hfsplus_fill_cat_thread(sb, &entry, |
270 | S_ISDIR(inode->i_mode) ? | 278 | S_ISDIR(inode->i_mode) ? |
@@ -333,6 +341,14 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str) | |||
333 | if (err) | 341 | if (err) |
334 | return err; | 342 | return err; |
335 | 343 | ||
344 | /* | ||
345 | * Fail early and avoid ENOSPC during the btree operations. We may | ||
346 | * have to split the root node at most once. | ||
347 | */ | ||
348 | err = hfs_bmap_reserve(fd.tree, 2 * (int)fd.tree->depth - 2); | ||
349 | if (err) | ||
350 | goto out; | ||
351 | |||
336 | if (!str) { | 352 | if (!str) { |
337 | int len; | 353 | int len; |
338 | 354 | ||
@@ -433,6 +449,14 @@ int hfsplus_rename_cat(u32 cnid, | |||
433 | return err; | 449 | return err; |
434 | dst_fd = src_fd; | 450 | dst_fd = src_fd; |
435 | 451 | ||
452 | /* | ||
453 | * Fail early and avoid ENOSPC during the btree operations. We may | ||
454 | * have to split the root node at most twice. | ||
455 | */ | ||
456 | err = hfs_bmap_reserve(src_fd.tree, 4 * (int)src_fd.tree->depth - 1); | ||
457 | if (err) | ||
458 | goto out; | ||
459 | |||
436 | /* find the old dir entry and read the data */ | 460 | /* find the old dir entry and read the data */ |
437 | err = hfsplus_cat_build_key(sb, src_fd.search_key, | 461 | err = hfsplus_cat_build_key(sb, src_fd.search_key, |
438 | src_dir->i_ino, src_name); | 462 | src_dir->i_ino, src_name); |
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index 8e0f59767694..a930ddd15681 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
@@ -100,6 +100,10 @@ static int __hfsplus_ext_write_extent(struct inode *inode, | |||
100 | if (hip->extent_state & HFSPLUS_EXT_NEW) { | 100 | if (hip->extent_state & HFSPLUS_EXT_NEW) { |
101 | if (res != -ENOENT) | 101 | if (res != -ENOENT) |
102 | return res; | 102 | return res; |
103 | /* Fail early and avoid ENOSPC during the btree operation */ | ||
104 | res = hfs_bmap_reserve(fd->tree, fd->tree->depth + 1); | ||
105 | if (res) | ||
106 | return res; | ||
103 | hfs_brec_insert(fd, hip->cached_extents, | 107 | hfs_brec_insert(fd, hip->cached_extents, |
104 | sizeof(hfsplus_extent_rec)); | 108 | sizeof(hfsplus_extent_rec)); |
105 | hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW); | 109 | hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW); |
@@ -233,7 +237,9 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, | |||
233 | ablock = iblock >> sbi->fs_shift; | 237 | ablock = iblock >> sbi->fs_shift; |
234 | 238 | ||
235 | if (iblock >= hip->fs_blocks) { | 239 | if (iblock >= hip->fs_blocks) { |
236 | if (iblock > hip->fs_blocks || !create) | 240 | if (!create) |
241 | return 0; | ||
242 | if (iblock > hip->fs_blocks) | ||
237 | return -EIO; | 243 | return -EIO; |
238 | if (ablock >= hip->alloc_blocks) { | 244 | if (ablock >= hip->alloc_blocks) { |
239 | res = hfsplus_file_extend(inode, false); | 245 | res = hfsplus_file_extend(inode, false); |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 8e039435958a..dd7ad9f13e3a 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -311,6 +311,7 @@ static inline unsigned short hfsplus_min_io_size(struct super_block *sb) | |||
311 | #define hfs_btree_open hfsplus_btree_open | 311 | #define hfs_btree_open hfsplus_btree_open |
312 | #define hfs_btree_close hfsplus_btree_close | 312 | #define hfs_btree_close hfsplus_btree_close |
313 | #define hfs_btree_write hfsplus_btree_write | 313 | #define hfs_btree_write hfsplus_btree_write |
314 | #define hfs_bmap_reserve hfsplus_bmap_reserve | ||
314 | #define hfs_bmap_alloc hfsplus_bmap_alloc | 315 | #define hfs_bmap_alloc hfsplus_bmap_alloc |
315 | #define hfs_bmap_free hfsplus_bmap_free | 316 | #define hfs_bmap_free hfsplus_bmap_free |
316 | #define hfs_bnode_read hfsplus_bnode_read | 317 | #define hfs_bnode_read hfsplus_bnode_read |
@@ -395,6 +396,7 @@ u32 hfsplus_calc_btree_clump_size(u32 block_size, u32 node_size, u64 sectors, | |||
395 | struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id); | 396 | struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id); |
396 | void hfs_btree_close(struct hfs_btree *tree); | 397 | void hfs_btree_close(struct hfs_btree *tree); |
397 | int hfs_btree_write(struct hfs_btree *tree); | 398 | int hfs_btree_write(struct hfs_btree *tree); |
399 | int hfs_bmap_reserve(struct hfs_btree *tree, int rsvd_nodes); | ||
398 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree); | 400 | struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree); |
399 | void hfs_bmap_free(struct hfs_bnode *node); | 401 | void hfs_bmap_free(struct hfs_bnode *node); |
400 | 402 | ||
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index 8e9427a42b81..d7ab9d8c4b67 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -261,6 +261,7 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr) | |||
261 | } | 261 | } |
262 | truncate_setsize(inode, attr->ia_size); | 262 | truncate_setsize(inode, attr->ia_size); |
263 | hfsplus_file_truncate(inode); | 263 | hfsplus_file_truncate(inode); |
264 | inode->i_mtime = inode->i_ctime = current_time(inode); | ||
264 | } | 265 | } |
265 | 266 | ||
266 | setattr_copy(inode, attr); | 267 | setattr_copy(inode, attr); |
diff --git a/fs/inode.c b/fs/inode.c index 9b808986d440..9e198f00b64c 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/swap.h> | 10 | #include <linux/swap.h> |
11 | #include <linux/security.h> | 11 | #include <linux/security.h> |
12 | #include <linux/cdev.h> | 12 | #include <linux/cdev.h> |
13 | #include <linux/bootmem.h> | 13 | #include <linux/memblock.h> |
14 | #include <linux/fsnotify.h> | 14 | #include <linux/fsnotify.h> |
15 | #include <linux/mount.h> | 15 | #include <linux/mount.h> |
16 | #include <linux/posix_acl.h> | 16 | #include <linux/posix_acl.h> |
diff --git a/fs/namespace.c b/fs/namespace.c index d86830c86ce8..98d27da43304 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/uaccess.h> | 23 | #include <linux/uaccess.h> |
24 | #include <linux/proc_ns.h> | 24 | #include <linux/proc_ns.h> |
25 | #include <linux/magic.h> | 25 | #include <linux/magic.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/task_work.h> | 27 | #include <linux/task_work.h> |
28 | #include <linux/sched/task.h> | 28 | #include <linux/sched/task.h> |
29 | 29 | ||
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index d297fe4472a9..bbcc185062bb 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/vmalloc.h> | 22 | #include <linux/vmalloc.h> |
23 | #include <linux/highmem.h> | 23 | #include <linux/highmem.h> |
24 | #include <linux/printk.h> | 24 | #include <linux/printk.h> |
25 | #include <linux/bootmem.h> | 25 | #include <linux/memblock.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/uaccess.h> | 28 | #include <linux/uaccess.h> |
diff --git a/fs/proc/page.c b/fs/proc/page.c index 792c78a49174..6c517b11acf8 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c | |||
@@ -1,5 +1,5 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | #include <linux/bootmem.h> | 2 | #include <linux/memblock.h> |
3 | #include <linux/compiler.h> | 3 | #include <linux/compiler.h> |
4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 91ae16fbd7d5..3fe90443c1bb 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/highmem.h> | 17 | #include <linux/highmem.h> |
18 | #include <linux/printk.h> | 18 | #include <linux/printk.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/crash_dump.h> | 21 | #include <linux/crash_dump.h> |
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
@@ -423,7 +423,7 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf) | |||
423 | if (rc < 0) { | 423 | if (rc < 0) { |
424 | unlock_page(page); | 424 | unlock_page(page); |
425 | put_page(page); | 425 | put_page(page); |
426 | return (rc == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS; | 426 | return vmf_error(rc); |
427 | } | 427 | } |
428 | SetPageUptodate(page); | 428 | SetPageUptodate(page); |
429 | } | 429 | } |
diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 503086f7f7c1..0d19d191ae70 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig | |||
@@ -141,7 +141,6 @@ config PSTORE_RAM | |||
141 | tristate "Log panic/oops to a RAM buffer" | 141 | tristate "Log panic/oops to a RAM buffer" |
142 | depends on PSTORE | 142 | depends on PSTORE |
143 | depends on HAS_IOMEM | 143 | depends on HAS_IOMEM |
144 | depends on HAVE_MEMBLOCK | ||
145 | select REED_SOLOMON | 144 | select REED_SOLOMON |
146 | select REED_SOLOMON_ENC8 | 145 | select REED_SOLOMON_ENC8 |
147 | select REED_SOLOMON_DEC8 | 146 | select REED_SOLOMON_DEC8 |
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile index a39a562c1c10..bd29c58ccbd8 100644 --- a/fs/reiserfs/Makefile +++ b/fs/reiserfs/Makefile | |||
@@ -26,14 +26,5 @@ ifeq ($(CONFIG_REISERFS_FS_POSIX_ACL),y) | |||
26 | reiserfs-objs += xattr_acl.o | 26 | reiserfs-objs += xattr_acl.o |
27 | endif | 27 | endif |
28 | 28 | ||
29 | # gcc -O2 (the kernel default) is overaggressive on ppc32 when many inline | ||
30 | # functions are used. This causes the compiler to advance the stack | ||
31 | # pointer out of the available stack space, corrupting kernel space, | ||
32 | # and causing a panic. Since this behavior only affects ppc32, this ifeq | ||
33 | # will work around it. If any other architecture displays this behavior, | ||
34 | # add it here. | ||
35 | ccflags-$(CONFIG_PPC32) := $(call cc-ifversion, -lt, 0400, -O1) | ||
36 | |||
37 | TAGS: | 29 | TAGS: |
38 | etags *.c | 30 | etags *.c |
39 | |||
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 48cdfc81fe10..32d8986c26fb 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -185,6 +185,7 @@ struct reiserfs_dentry_buf { | |||
185 | struct dir_context ctx; | 185 | struct dir_context ctx; |
186 | struct dentry *xadir; | 186 | struct dentry *xadir; |
187 | int count; | 187 | int count; |
188 | int err; | ||
188 | struct dentry *dentries[8]; | 189 | struct dentry *dentries[8]; |
189 | }; | 190 | }; |
190 | 191 | ||
@@ -207,6 +208,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen, | |||
207 | 208 | ||
208 | dentry = lookup_one_len(name, dbuf->xadir, namelen); | 209 | dentry = lookup_one_len(name, dbuf->xadir, namelen); |
209 | if (IS_ERR(dentry)) { | 210 | if (IS_ERR(dentry)) { |
211 | dbuf->err = PTR_ERR(dentry); | ||
210 | return PTR_ERR(dentry); | 212 | return PTR_ERR(dentry); |
211 | } else if (d_really_is_negative(dentry)) { | 213 | } else if (d_really_is_negative(dentry)) { |
212 | /* A directory entry exists, but no file? */ | 214 | /* A directory entry exists, but no file? */ |
@@ -215,6 +217,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen, | |||
215 | "not found for file %pd.\n", | 217 | "not found for file %pd.\n", |
216 | dentry, dbuf->xadir); | 218 | dentry, dbuf->xadir); |
217 | dput(dentry); | 219 | dput(dentry); |
220 | dbuf->err = -EIO; | ||
218 | return -EIO; | 221 | return -EIO; |
219 | } | 222 | } |
220 | 223 | ||
@@ -262,6 +265,10 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
262 | err = reiserfs_readdir_inode(d_inode(dir), &buf.ctx); | 265 | err = reiserfs_readdir_inode(d_inode(dir), &buf.ctx); |
263 | if (err) | 266 | if (err) |
264 | break; | 267 | break; |
268 | if (buf.err) { | ||
269 | err = buf.err; | ||
270 | break; | ||
271 | } | ||
265 | if (!buf.count) | 272 | if (!buf.count) |
266 | break; | 273 | break; |
267 | for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) { | 274 | for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) { |
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 1817a8415a5e..c2de013b2cf4 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h | |||
@@ -62,10 +62,6 @@ extern void setup_per_cpu_areas(void); | |||
62 | #define PER_CPU_ATTRIBUTES | 62 | #define PER_CPU_ATTRIBUTES |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | #ifndef PER_CPU_DEF_ATTRIBUTES | ||
66 | #define PER_CPU_DEF_ATTRIBUTES | ||
67 | #endif | ||
68 | |||
69 | #define raw_cpu_generic_read(pcp) \ | 65 | #define raw_cpu_generic_read(pcp) \ |
70 | ({ \ | 66 | ({ \ |
71 | *raw_cpu_ptr(&(pcp)); \ | 67 | *raw_cpu_ptr(&(pcp)); \ |
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index acf5e8df3504..f58e97446abc 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -28,8 +28,8 @@ | |||
28 | * The available bitmap operations and their rough meaning in the | 28 | * The available bitmap operations and their rough meaning in the |
29 | * case that the bitmap is a single unsigned long are thus: | 29 | * case that the bitmap is a single unsigned long are thus: |
30 | * | 30 | * |
31 | * Note that nbits should be always a compile time evaluable constant. | 31 | * The generated code is more efficient when nbits is known at |
32 | * Otherwise many inlines will generate horrible code. | 32 | * compile-time and at most BITS_PER_LONG. |
33 | * | 33 | * |
34 | * :: | 34 | * :: |
35 | * | 35 | * |
@@ -204,38 +204,31 @@ extern int bitmap_print_to_pagebuf(bool list, char *buf, | |||
204 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) | 204 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) |
205 | #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) | 205 | #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) |
206 | 206 | ||
207 | /* | ||
208 | * The static inlines below do not handle constant nbits==0 correctly, | ||
209 | * so make such users (should any ever turn up) call the out-of-line | ||
210 | * versions. | ||
211 | */ | ||
207 | #define small_const_nbits(nbits) \ | 212 | #define small_const_nbits(nbits) \ |
208 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) | 213 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && (nbits) > 0) |
209 | 214 | ||
210 | static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) | 215 | static inline void bitmap_zero(unsigned long *dst, unsigned int nbits) |
211 | { | 216 | { |
212 | if (small_const_nbits(nbits)) | 217 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
213 | *dst = 0UL; | 218 | memset(dst, 0, len); |
214 | else { | ||
215 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | ||
216 | memset(dst, 0, len); | ||
217 | } | ||
218 | } | 219 | } |
219 | 220 | ||
220 | static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) | 221 | static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) |
221 | { | 222 | { |
222 | if (small_const_nbits(nbits)) | 223 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
223 | *dst = ~0UL; | 224 | memset(dst, 0xff, len); |
224 | else { | ||
225 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | ||
226 | memset(dst, 0xff, len); | ||
227 | } | ||
228 | } | 225 | } |
229 | 226 | ||
230 | static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, | 227 | static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, |
231 | unsigned int nbits) | 228 | unsigned int nbits) |
232 | { | 229 | { |
233 | if (small_const_nbits(nbits)) | 230 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
234 | *dst = *src; | 231 | memcpy(dst, src, len); |
235 | else { | ||
236 | unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | ||
237 | memcpy(dst, src, len); | ||
238 | } | ||
239 | } | 232 | } |
240 | 233 | ||
241 | /* | 234 | /* |
@@ -398,7 +391,7 @@ static __always_inline void bitmap_clear(unsigned long *map, unsigned int start, | |||
398 | } | 391 | } |
399 | 392 | ||
400 | static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src, | 393 | static inline void bitmap_shift_right(unsigned long *dst, const unsigned long *src, |
401 | unsigned int shift, int nbits) | 394 | unsigned int shift, unsigned int nbits) |
402 | { | 395 | { |
403 | if (small_const_nbits(nbits)) | 396 | if (small_const_nbits(nbits)) |
404 | *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> shift; | 397 | *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> shift; |
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h deleted file mode 100644 index 42515195d7d8..000000000000 --- a/include/linux/bootmem.h +++ /dev/null | |||
@@ -1,404 +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 | #ifndef CONFIG_NO_BOOTMEM | ||
30 | /** | ||
31 | * struct bootmem_data - per-node information used by the bootmem allocator | ||
32 | * @node_min_pfn: the starting physical address of the node's memory | ||
33 | * @node_low_pfn: the end physical address of the directly addressable memory | ||
34 | * @node_bootmem_map: is a bitmap pointer - the bits represent all physical | ||
35 | * memory pages (including holes) on the node. | ||
36 | * @last_end_off: the offset within the page of the end of the last allocation; | ||
37 | * if 0, the page used is full | ||
38 | * @hint_idx: the PFN of the page used with the last allocation; | ||
39 | * together with using this with the @last_end_offset field, | ||
40 | * a test can be made to see if allocations can be merged | ||
41 | * with the page used for the last allocation rather than | ||
42 | * using up a full new page. | ||
43 | * @list: list entry in the linked list ordered by the memory addresses | ||
44 | */ | ||
45 | typedef struct bootmem_data { | ||
46 | unsigned long node_min_pfn; | ||
47 | unsigned long node_low_pfn; | ||
48 | void *node_bootmem_map; | ||
49 | unsigned long last_end_off; | ||
50 | unsigned long hint_idx; | ||
51 | struct list_head list; | ||
52 | } bootmem_data_t; | ||
53 | |||
54 | extern bootmem_data_t bootmem_node_data[]; | ||
55 | #endif | ||
56 | |||
57 | extern unsigned long bootmem_bootmap_pages(unsigned long); | ||
58 | |||
59 | extern unsigned long init_bootmem_node(pg_data_t *pgdat, | ||
60 | unsigned long freepfn, | ||
61 | unsigned long startpfn, | ||
62 | unsigned long endpfn); | ||
63 | extern unsigned long init_bootmem(unsigned long addr, unsigned long memend); | ||
64 | |||
65 | extern unsigned long free_all_bootmem(void); | ||
66 | extern void reset_node_managed_pages(pg_data_t *pgdat); | ||
67 | extern void reset_all_zones_managed_pages(void); | ||
68 | |||
69 | extern void free_bootmem_node(pg_data_t *pgdat, | ||
70 | unsigned long addr, | ||
71 | unsigned long size); | ||
72 | extern void free_bootmem(unsigned long physaddr, unsigned long size); | ||
73 | extern void free_bootmem_late(unsigned long physaddr, unsigned long size); | ||
74 | |||
75 | /* | ||
76 | * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE, | ||
77 | * the architecture-specific code should honor this). | ||
78 | * | ||
79 | * If flags is BOOTMEM_DEFAULT, then the return value is always 0 (success). | ||
80 | * If flags contains BOOTMEM_EXCLUSIVE, then -EBUSY is returned if the memory | ||
81 | * already was reserved. | ||
82 | */ | ||
83 | #define BOOTMEM_DEFAULT 0 | ||
84 | #define BOOTMEM_EXCLUSIVE (1<<0) | ||
85 | |||
86 | extern int reserve_bootmem(unsigned long addr, | ||
87 | unsigned long size, | ||
88 | int flags); | ||
89 | extern int reserve_bootmem_node(pg_data_t *pgdat, | ||
90 | unsigned long physaddr, | ||
91 | unsigned long size, | ||
92 | int flags); | ||
93 | |||
94 | extern void *__alloc_bootmem(unsigned long size, | ||
95 | unsigned long align, | ||
96 | unsigned long goal); | ||
97 | extern void *__alloc_bootmem_nopanic(unsigned long size, | ||
98 | unsigned long align, | ||
99 | unsigned long goal) __malloc; | ||
100 | extern void *__alloc_bootmem_node(pg_data_t *pgdat, | ||
101 | unsigned long size, | ||
102 | unsigned long align, | ||
103 | unsigned long goal) __malloc; | ||
104 | void *__alloc_bootmem_node_high(pg_data_t *pgdat, | ||
105 | unsigned long size, | ||
106 | unsigned long align, | ||
107 | unsigned long goal) __malloc; | ||
108 | extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat, | ||
109 | unsigned long size, | ||
110 | unsigned long align, | ||
111 | unsigned long goal) __malloc; | ||
112 | void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat, | ||
113 | unsigned long size, | ||
114 | unsigned long align, | ||
115 | unsigned long goal, | ||
116 | unsigned long limit) __malloc; | ||
117 | extern void *__alloc_bootmem_low(unsigned long size, | ||
118 | unsigned long align, | ||
119 | unsigned long goal) __malloc; | ||
120 | void *__alloc_bootmem_low_nopanic(unsigned long size, | ||
121 | unsigned long align, | ||
122 | unsigned long goal) __malloc; | ||
123 | extern void *__alloc_bootmem_low_node(pg_data_t *pgdat, | ||
124 | unsigned long size, | ||
125 | unsigned long align, | ||
126 | unsigned long goal) __malloc; | ||
127 | |||
128 | #ifdef CONFIG_NO_BOOTMEM | ||
129 | /* We are using top down, so it is safe to use 0 here */ | ||
130 | #define BOOTMEM_LOW_LIMIT 0 | ||
131 | #else | ||
132 | #define BOOTMEM_LOW_LIMIT __pa(MAX_DMA_ADDRESS) | ||
133 | #endif | ||
134 | |||
135 | #ifndef ARCH_LOW_ADDRESS_LIMIT | ||
136 | #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL | ||
137 | #endif | ||
138 | |||
139 | #define alloc_bootmem(x) \ | ||
140 | __alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT) | ||
141 | #define alloc_bootmem_align(x, align) \ | ||
142 | __alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT) | ||
143 | #define alloc_bootmem_nopanic(x) \ | ||
144 | __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT) | ||
145 | #define alloc_bootmem_pages(x) \ | ||
146 | __alloc_bootmem(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT) | ||
147 | #define alloc_bootmem_pages_nopanic(x) \ | ||
148 | __alloc_bootmem_nopanic(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT) | ||
149 | #define alloc_bootmem_node(pgdat, x) \ | ||
150 | __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT) | ||
151 | #define alloc_bootmem_node_nopanic(pgdat, x) \ | ||
152 | __alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT) | ||
153 | #define alloc_bootmem_pages_node(pgdat, x) \ | ||
154 | __alloc_bootmem_node(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT) | ||
155 | #define alloc_bootmem_pages_node_nopanic(pgdat, x) \ | ||
156 | __alloc_bootmem_node_nopanic(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT) | ||
157 | |||
158 | #define alloc_bootmem_low(x) \ | ||
159 | __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0) | ||
160 | #define alloc_bootmem_low_pages_nopanic(x) \ | ||
161 | __alloc_bootmem_low_nopanic(x, PAGE_SIZE, 0) | ||
162 | #define alloc_bootmem_low_pages(x) \ | ||
163 | __alloc_bootmem_low(x, PAGE_SIZE, 0) | ||
164 | #define alloc_bootmem_low_pages_node(pgdat, x) \ | ||
165 | __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) | ||
166 | |||
167 | |||
168 | #if defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) | ||
169 | |||
170 | /* FIXME: use MEMBLOCK_ALLOC_* variants here */ | ||
171 | #define BOOTMEM_ALLOC_ACCESSIBLE 0 | ||
172 | #define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0) | ||
173 | |||
174 | /* FIXME: Move to memblock.h at a point where we remove nobootmem.c */ | ||
175 | void *memblock_virt_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align, | ||
176 | phys_addr_t min_addr, | ||
177 | phys_addr_t max_addr, int nid); | ||
178 | void *memblock_virt_alloc_try_nid_nopanic(phys_addr_t size, | ||
179 | phys_addr_t align, phys_addr_t min_addr, | ||
180 | phys_addr_t max_addr, int nid); | ||
181 | void *memblock_virt_alloc_try_nid(phys_addr_t size, phys_addr_t align, | ||
182 | phys_addr_t min_addr, phys_addr_t max_addr, int nid); | ||
183 | void __memblock_free_early(phys_addr_t base, phys_addr_t size); | ||
184 | void __memblock_free_late(phys_addr_t base, phys_addr_t size); | ||
185 | |||
186 | static inline void * __init memblock_virt_alloc( | ||
187 | phys_addr_t size, phys_addr_t align) | ||
188 | { | ||
189 | return memblock_virt_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT, | ||
190 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
191 | NUMA_NO_NODE); | ||
192 | } | ||
193 | |||
194 | static inline void * __init memblock_virt_alloc_raw( | ||
195 | phys_addr_t size, phys_addr_t align) | ||
196 | { | ||
197 | return memblock_virt_alloc_try_nid_raw(size, align, BOOTMEM_LOW_LIMIT, | ||
198 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
199 | NUMA_NO_NODE); | ||
200 | } | ||
201 | |||
202 | static inline void * __init memblock_virt_alloc_nopanic( | ||
203 | phys_addr_t size, phys_addr_t align) | ||
204 | { | ||
205 | return memblock_virt_alloc_try_nid_nopanic(size, align, | ||
206 | BOOTMEM_LOW_LIMIT, | ||
207 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
208 | NUMA_NO_NODE); | ||
209 | } | ||
210 | |||
211 | static inline void * __init memblock_virt_alloc_low( | ||
212 | phys_addr_t size, phys_addr_t align) | ||
213 | { | ||
214 | return memblock_virt_alloc_try_nid(size, align, | ||
215 | BOOTMEM_LOW_LIMIT, | ||
216 | ARCH_LOW_ADDRESS_LIMIT, | ||
217 | NUMA_NO_NODE); | ||
218 | } | ||
219 | static inline void * __init memblock_virt_alloc_low_nopanic( | ||
220 | phys_addr_t size, phys_addr_t align) | ||
221 | { | ||
222 | return memblock_virt_alloc_try_nid_nopanic(size, align, | ||
223 | BOOTMEM_LOW_LIMIT, | ||
224 | ARCH_LOW_ADDRESS_LIMIT, | ||
225 | NUMA_NO_NODE); | ||
226 | } | ||
227 | |||
228 | static inline void * __init memblock_virt_alloc_from_nopanic( | ||
229 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | ||
230 | { | ||
231 | return memblock_virt_alloc_try_nid_nopanic(size, align, min_addr, | ||
232 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
233 | NUMA_NO_NODE); | ||
234 | } | ||
235 | |||
236 | static inline void * __init memblock_virt_alloc_node( | ||
237 | phys_addr_t size, int nid) | ||
238 | { | ||
239 | return memblock_virt_alloc_try_nid(size, 0, BOOTMEM_LOW_LIMIT, | ||
240 | BOOTMEM_ALLOC_ACCESSIBLE, nid); | ||
241 | } | ||
242 | |||
243 | static inline void * __init memblock_virt_alloc_node_nopanic( | ||
244 | phys_addr_t size, int nid) | ||
245 | { | ||
246 | return memblock_virt_alloc_try_nid_nopanic(size, 0, BOOTMEM_LOW_LIMIT, | ||
247 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
248 | nid); | ||
249 | } | ||
250 | |||
251 | static inline void __init memblock_free_early( | ||
252 | phys_addr_t base, phys_addr_t size) | ||
253 | { | ||
254 | __memblock_free_early(base, size); | ||
255 | } | ||
256 | |||
257 | static inline void __init memblock_free_early_nid( | ||
258 | phys_addr_t base, phys_addr_t size, int nid) | ||
259 | { | ||
260 | __memblock_free_early(base, size); | ||
261 | } | ||
262 | |||
263 | static inline void __init memblock_free_late( | ||
264 | phys_addr_t base, phys_addr_t size) | ||
265 | { | ||
266 | __memblock_free_late(base, size); | ||
267 | } | ||
268 | |||
269 | #else | ||
270 | |||
271 | #define BOOTMEM_ALLOC_ACCESSIBLE 0 | ||
272 | |||
273 | |||
274 | /* Fall back to all the existing bootmem APIs */ | ||
275 | static inline void * __init memblock_virt_alloc( | ||
276 | phys_addr_t size, phys_addr_t align) | ||
277 | { | ||
278 | if (!align) | ||
279 | align = SMP_CACHE_BYTES; | ||
280 | return __alloc_bootmem(size, align, BOOTMEM_LOW_LIMIT); | ||
281 | } | ||
282 | |||
283 | static inline void * __init memblock_virt_alloc_raw( | ||
284 | phys_addr_t size, phys_addr_t align) | ||
285 | { | ||
286 | if (!align) | ||
287 | align = SMP_CACHE_BYTES; | ||
288 | return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT); | ||
289 | } | ||
290 | |||
291 | static inline void * __init memblock_virt_alloc_nopanic( | ||
292 | phys_addr_t size, phys_addr_t align) | ||
293 | { | ||
294 | if (!align) | ||
295 | align = SMP_CACHE_BYTES; | ||
296 | return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT); | ||
297 | } | ||
298 | |||
299 | static inline void * __init memblock_virt_alloc_low( | ||
300 | phys_addr_t size, phys_addr_t align) | ||
301 | { | ||
302 | if (!align) | ||
303 | align = SMP_CACHE_BYTES; | ||
304 | return __alloc_bootmem_low(size, align, 0); | ||
305 | } | ||
306 | |||
307 | static inline void * __init memblock_virt_alloc_low_nopanic( | ||
308 | phys_addr_t size, phys_addr_t align) | ||
309 | { | ||
310 | if (!align) | ||
311 | align = SMP_CACHE_BYTES; | ||
312 | return __alloc_bootmem_low_nopanic(size, align, 0); | ||
313 | } | ||
314 | |||
315 | static inline void * __init memblock_virt_alloc_from_nopanic( | ||
316 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | ||
317 | { | ||
318 | return __alloc_bootmem_nopanic(size, align, min_addr); | ||
319 | } | ||
320 | |||
321 | static inline void * __init memblock_virt_alloc_node( | ||
322 | phys_addr_t size, int nid) | ||
323 | { | ||
324 | return __alloc_bootmem_node(NODE_DATA(nid), size, SMP_CACHE_BYTES, | ||
325 | BOOTMEM_LOW_LIMIT); | ||
326 | } | ||
327 | |||
328 | static inline void * __init memblock_virt_alloc_node_nopanic( | ||
329 | phys_addr_t size, int nid) | ||
330 | { | ||
331 | return __alloc_bootmem_node_nopanic(NODE_DATA(nid), size, | ||
332 | SMP_CACHE_BYTES, | ||
333 | BOOTMEM_LOW_LIMIT); | ||
334 | } | ||
335 | |||
336 | static inline void * __init memblock_virt_alloc_try_nid(phys_addr_t size, | ||
337 | phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid) | ||
338 | { | ||
339 | return __alloc_bootmem_node_high(NODE_DATA(nid), size, align, | ||
340 | min_addr); | ||
341 | } | ||
342 | |||
343 | static inline void * __init memblock_virt_alloc_try_nid_raw( | ||
344 | phys_addr_t size, phys_addr_t align, | ||
345 | phys_addr_t min_addr, phys_addr_t max_addr, int nid) | ||
346 | { | ||
347 | return ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align, | ||
348 | min_addr, max_addr); | ||
349 | } | ||
350 | |||
351 | static inline void * __init memblock_virt_alloc_try_nid_nopanic( | ||
352 | phys_addr_t size, phys_addr_t align, | ||
353 | phys_addr_t min_addr, phys_addr_t max_addr, int nid) | ||
354 | { | ||
355 | return ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align, | ||
356 | min_addr, max_addr); | ||
357 | } | ||
358 | |||
359 | static inline void __init memblock_free_early( | ||
360 | phys_addr_t base, phys_addr_t size) | ||
361 | { | ||
362 | free_bootmem(base, size); | ||
363 | } | ||
364 | |||
365 | static inline void __init memblock_free_early_nid( | ||
366 | phys_addr_t base, phys_addr_t size, int nid) | ||
367 | { | ||
368 | free_bootmem_node(NODE_DATA(nid), base, size); | ||
369 | } | ||
370 | |||
371 | static inline void __init memblock_free_late( | ||
372 | phys_addr_t base, phys_addr_t size) | ||
373 | { | ||
374 | free_bootmem_late(base, size); | ||
375 | } | ||
376 | #endif /* defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) */ | ||
377 | |||
378 | extern void *alloc_large_system_hash(const char *tablename, | ||
379 | unsigned long bucketsize, | ||
380 | unsigned long numentries, | ||
381 | int scale, | ||
382 | int flags, | ||
383 | unsigned int *_hash_shift, | ||
384 | unsigned int *_hash_mask, | ||
385 | unsigned long low_limit, | ||
386 | unsigned long high_limit); | ||
387 | |||
388 | #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ | ||
389 | #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min | ||
390 | * shift passed via *_hash_shift */ | ||
391 | #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ | ||
392 | |||
393 | /* Only NUMA needs hash distribution. 64bit NUMA architectures have | ||
394 | * sufficient vmalloc space. | ||
395 | */ | ||
396 | #ifdef CONFIG_NUMA | ||
397 | #define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) | ||
398 | extern int hashdist; /* Distribute hashes across NUMA nodes? */ | ||
399 | #else | ||
400 | #define hashdist (0) | ||
401 | #endif | ||
402 | |||
403 | |||
404 | #endif /* _LINUX_BOOTMEM_H */ | ||
diff --git a/include/linux/compat.h b/include/linux/compat.h index d30e4dbd4be2..06e77473f175 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h | |||
@@ -488,8 +488,11 @@ put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set, | |||
488 | compat_sigset_t v; | 488 | compat_sigset_t v; |
489 | switch (_NSIG_WORDS) { | 489 | switch (_NSIG_WORDS) { |
490 | case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3]; | 490 | case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3]; |
491 | /* fall through */ | ||
491 | case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2]; | 492 | case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2]; |
493 | /* fall through */ | ||
492 | case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1]; | 494 | case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1]; |
495 | /* fall through */ | ||
493 | case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0]; | 496 | case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0]; |
494 | } | 497 | } |
495 | return copy_to_user(compat, &v, size) ? -EFAULT : 0; | 498 | return copy_to_user(compat, &v, size) ? -EFAULT : 0; |
diff --git a/include/linux/hmm.h b/include/linux/hmm.h index dde947083d4e..c6fb869a81c0 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h | |||
@@ -11,7 +11,7 @@ | |||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | * | 13 | * |
14 | * Authors: Jérôme Glisse <jglisse@redhat.com> | 14 | * Authors: Jérôme Glisse <jglisse@redhat.com> |
15 | */ | 15 | */ |
16 | /* | 16 | /* |
17 | * Heterogeneous Memory Management (HMM) | 17 | * Heterogeneous Memory Management (HMM) |
@@ -274,14 +274,29 @@ static inline uint64_t hmm_pfn_from_pfn(const struct hmm_range *range, | |||
274 | struct hmm_mirror; | 274 | struct hmm_mirror; |
275 | 275 | ||
276 | /* | 276 | /* |
277 | * enum hmm_update_type - type of update | 277 | * enum hmm_update_event - type of update |
278 | * @HMM_UPDATE_INVALIDATE: invalidate range (no indication as to why) | 278 | * @HMM_UPDATE_INVALIDATE: invalidate range (no indication as to why) |
279 | */ | 279 | */ |
280 | enum hmm_update_type { | 280 | enum hmm_update_event { |
281 | HMM_UPDATE_INVALIDATE, | 281 | HMM_UPDATE_INVALIDATE, |
282 | }; | 282 | }; |
283 | 283 | ||
284 | /* | 284 | /* |
285 | * struct hmm_update - HMM update informations for callback | ||
286 | * | ||
287 | * @start: virtual start address of the range to update | ||
288 | * @end: virtual end address of the range to update | ||
289 | * @event: event triggering the update (what is happening) | ||
290 | * @blockable: can the callback block/sleep ? | ||
291 | */ | ||
292 | struct hmm_update { | ||
293 | unsigned long start; | ||
294 | unsigned long end; | ||
295 | enum hmm_update_event event; | ||
296 | bool blockable; | ||
297 | }; | ||
298 | |||
299 | /* | ||
285 | * struct hmm_mirror_ops - HMM mirror device operations callback | 300 | * struct hmm_mirror_ops - HMM mirror device operations callback |
286 | * | 301 | * |
287 | * @update: callback to update range on a device | 302 | * @update: callback to update range on a device |
@@ -300,9 +315,9 @@ struct hmm_mirror_ops { | |||
300 | /* sync_cpu_device_pagetables() - synchronize page tables | 315 | /* sync_cpu_device_pagetables() - synchronize page tables |
301 | * | 316 | * |
302 | * @mirror: pointer to struct hmm_mirror | 317 | * @mirror: pointer to struct hmm_mirror |
303 | * @update_type: type of update that occurred to the CPU page table | 318 | * @update: update informations (see struct hmm_update) |
304 | * @start: virtual start address of the range to update | 319 | * Returns: -EAGAIN if update.blockable false and callback need to |
305 | * @end: virtual end address of the range to update | 320 | * block, 0 otherwise. |
306 | * | 321 | * |
307 | * This callback ultimately originates from mmu_notifiers when the CPU | 322 | * This callback ultimately originates from mmu_notifiers when the CPU |
308 | * page table is updated. The device driver must update its page table | 323 | * page table is updated. The device driver must update its page table |
@@ -313,10 +328,8 @@ struct hmm_mirror_ops { | |||
313 | * page tables are completely updated (TLBs flushed, etc); this is a | 328 | * page tables are completely updated (TLBs flushed, etc); this is a |
314 | * synchronous call. | 329 | * synchronous call. |
315 | */ | 330 | */ |
316 | void (*sync_cpu_device_pagetables)(struct hmm_mirror *mirror, | 331 | int (*sync_cpu_device_pagetables)(struct hmm_mirror *mirror, |
317 | enum hmm_update_type update_type, | 332 | const struct hmm_update *update); |
318 | unsigned long start, | ||
319 | unsigned long end); | ||
320 | }; | 333 | }; |
321 | 334 | ||
322 | /* | 335 | /* |
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 2acdd046df2d..aee299a6aa76 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define _LINUX_MEMBLOCK_H | 2 | #define _LINUX_MEMBLOCK_H |
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | #ifdef CONFIG_HAVE_MEMBLOCK | ||
6 | /* | 5 | /* |
7 | * Logical memory blocks. | 6 | * Logical memory blocks. |
8 | * | 7 | * |
@@ -16,6 +15,19 @@ | |||
16 | 15 | ||
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
18 | #include <linux/mm.h> | 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; | ||
19 | 31 | ||
20 | #define INIT_MEMBLOCK_REGIONS 128 | 32 | #define INIT_MEMBLOCK_REGIONS 128 |
21 | #define INIT_PHYSMEM_REGIONS 4 | 33 | #define INIT_PHYSMEM_REGIONS 4 |
@@ -120,6 +132,10 @@ int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); | |||
120 | int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); | 132 | int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); |
121 | enum memblock_flags choose_memblock_flags(void); | 133 | enum memblock_flags choose_memblock_flags(void); |
122 | 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 | |||
123 | /* Low level functions */ | 139 | /* Low level functions */ |
124 | int memblock_add_range(struct memblock_type *type, | 140 | int memblock_add_range(struct memblock_type *type, |
125 | phys_addr_t base, phys_addr_t size, | 141 | phys_addr_t base, phys_addr_t size, |
@@ -301,10 +317,116 @@ static inline int memblock_get_region_node(const struct memblock_region *r) | |||
301 | } | 317 | } |
302 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ | 318 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ |
303 | 319 | ||
304 | phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); | 320 | /* Flags for memblock allocation APIs */ |
305 | phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); | 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 | |||
331 | phys_addr_t memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); | ||
332 | phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); | ||
333 | |||
334 | phys_addr_t memblock_phys_alloc(phys_addr_t size, phys_addr_t align); | ||
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, SMP_CACHE_BYTES, | ||
410 | MEMBLOCK_LOW_LIMIT, | ||
411 | MEMBLOCK_ALLOC_ACCESSIBLE, nid); | ||
412 | } | ||
413 | |||
414 | static inline void __init memblock_free_early(phys_addr_t base, | ||
415 | phys_addr_t size) | ||
416 | { | ||
417 | __memblock_free_early(base, size); | ||
418 | } | ||
419 | |||
420 | static inline void __init memblock_free_early_nid(phys_addr_t base, | ||
421 | phys_addr_t size, int nid) | ||
422 | { | ||
423 | __memblock_free_early(base, size); | ||
424 | } | ||
306 | 425 | ||
307 | phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align); | 426 | static inline void __init memblock_free_late(phys_addr_t base, phys_addr_t size) |
427 | { | ||
428 | __memblock_free_late(base, size); | ||
429 | } | ||
308 | 430 | ||
309 | /* | 431 | /* |
310 | * Set the allocation direction to bottom-up or top-down. | 432 | * Set the allocation direction to bottom-up or top-down. |
@@ -324,10 +446,6 @@ static inline bool memblock_bottom_up(void) | |||
324 | return memblock.bottom_up; | 446 | return memblock.bottom_up; |
325 | } | 447 | } |
326 | 448 | ||
327 | /* Flags for memblock_alloc_base() amd __memblock_alloc_base() */ | ||
328 | #define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0) | ||
329 | #define MEMBLOCK_ALLOC_ACCESSIBLE 0 | ||
330 | |||
331 | phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, | 449 | phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, |
332 | phys_addr_t start, phys_addr_t end, | 450 | phys_addr_t start, phys_addr_t end, |
333 | enum memblock_flags flags); | 451 | enum memblock_flags flags); |
@@ -433,6 +551,31 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo | |||
433 | i < memblock_type->cnt; \ | 551 | i < memblock_type->cnt; \ |
434 | i++, rgn = &memblock_type->regions[i]) | 552 | i++, rgn = &memblock_type->regions[i]) |
435 | 553 | ||
554 | extern void *alloc_large_system_hash(const char *tablename, | ||
555 | unsigned long bucketsize, | ||
556 | unsigned long numentries, | ||
557 | int scale, | ||
558 | int flags, | ||
559 | unsigned int *_hash_shift, | ||
560 | unsigned int *_hash_mask, | ||
561 | unsigned long low_limit, | ||
562 | unsigned long high_limit); | ||
563 | |||
564 | #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ | ||
565 | #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min | ||
566 | * shift passed via *_hash_shift */ | ||
567 | #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ | ||
568 | |||
569 | /* Only NUMA needs hash distribution. 64bit NUMA architectures have | ||
570 | * sufficient vmalloc space. | ||
571 | */ | ||
572 | #ifdef CONFIG_NUMA | ||
573 | #define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) | ||
574 | extern int hashdist; /* Distribute hashes across NUMA nodes? */ | ||
575 | #else | ||
576 | #define hashdist (0) | ||
577 | #endif | ||
578 | |||
436 | #ifdef CONFIG_MEMTEST | 579 | #ifdef CONFIG_MEMTEST |
437 | extern void early_memtest(phys_addr_t start, phys_addr_t end); | 580 | extern void early_memtest(phys_addr_t start, phys_addr_t end); |
438 | #else | 581 | #else |
@@ -440,12 +583,6 @@ static inline void early_memtest(phys_addr_t start, phys_addr_t end) | |||
440 | { | 583 | { |
441 | } | 584 | } |
442 | #endif | 585 | #endif |
443 | #else | ||
444 | static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align) | ||
445 | { | ||
446 | return 0; | ||
447 | } | ||
448 | #endif /* CONFIG_HAVE_MEMBLOCK */ | ||
449 | 586 | ||
450 | #endif /* __KERNEL__ */ | 587 | #endif /* __KERNEL__ */ |
451 | 588 | ||
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 34a28227068d..ffd9cd10fcf3 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h | |||
@@ -301,6 +301,7 @@ extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages); | |||
301 | extern void try_offline_node(int nid); | 301 | extern void try_offline_node(int nid); |
302 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); | 302 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); |
303 | extern void remove_memory(int nid, u64 start, u64 size); | 303 | extern void remove_memory(int nid, u64 start, u64 size); |
304 | extern void __remove_memory(int nid, u64 start, u64 size); | ||
304 | 305 | ||
305 | #else | 306 | #else |
306 | static inline bool is_mem_section_removable(unsigned long pfn, | 307 | static inline bool is_mem_section_removable(unsigned long pfn, |
@@ -317,11 +318,13 @@ static inline int offline_pages(unsigned long start_pfn, unsigned long nr_pages) | |||
317 | } | 318 | } |
318 | 319 | ||
319 | static inline void remove_memory(int nid, u64 start, u64 size) {} | 320 | static inline void remove_memory(int nid, u64 start, u64 size) {} |
321 | static inline void __remove_memory(int nid, u64 start, u64 size) {} | ||
320 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | 322 | #endif /* CONFIG_MEMORY_HOTREMOVE */ |
321 | 323 | ||
322 | extern void __ref free_area_init_core_hotplug(int nid); | 324 | extern void __ref free_area_init_core_hotplug(int nid); |
323 | extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, | 325 | extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, |
324 | void *arg, int (*func)(struct memory_block *, void *)); | 326 | void *arg, int (*func)(struct memory_block *, void *)); |
327 | extern int __add_memory(int nid, u64 start, u64 size); | ||
325 | extern int add_memory(int nid, u64 start, u64 size); | 328 | extern int add_memory(int nid, u64 start, u64 size); |
326 | extern int add_memory_resource(int nid, struct resource *resource, bool online); | 329 | extern int add_memory_resource(int nid, struct resource *resource, bool online); |
327 | extern int arch_add_memory(int nid, u64 start, u64 size, | 330 | extern int arch_add_memory(int nid, u64 start, u64 size, |
@@ -330,7 +333,6 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, | |||
330 | unsigned long nr_pages, struct vmem_altmap *altmap); | 333 | unsigned long nr_pages, struct vmem_altmap *altmap); |
331 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); | 334 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); |
332 | extern bool is_memblock_offlined(struct memory_block *mem); | 335 | extern bool is_memblock_offlined(struct memory_block *mem); |
333 | extern void remove_memory(int nid, u64 start, u64 size); | ||
334 | extern int sparse_add_one_section(struct pglist_data *pgdat, | 336 | extern int sparse_add_one_section(struct pglist_data *pgdat, |
335 | unsigned long start_pfn, struct vmem_altmap *altmap); | 337 | unsigned long start_pfn, struct vmem_altmap *altmap); |
336 | extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, | 338 | extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 1e52b8fd1685..fcf9cc9d535f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -2163,7 +2163,7 @@ extern int __meminit __early_pfn_to_nid(unsigned long pfn, | |||
2163 | struct mminit_pfnnid_cache *state); | 2163 | struct mminit_pfnnid_cache *state); |
2164 | #endif | 2164 | #endif |
2165 | 2165 | ||
2166 | #if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP) | 2166 | #if !defined(CONFIG_FLAT_NODE_MEM_MAP) |
2167 | void zero_resv_unavail(void); | 2167 | void zero_resv_unavail(void); |
2168 | #else | 2168 | #else |
2169 | static inline void zero_resv_unavail(void) {} | 2169 | static inline void zero_resv_unavail(void) {} |
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 9f0caccd5833..847705a6d0ec 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -633,9 +633,6 @@ typedef struct pglist_data { | |||
633 | struct page_ext *node_page_ext; | 633 | struct page_ext *node_page_ext; |
634 | #endif | 634 | #endif |
635 | #endif | 635 | #endif |
636 | #ifndef CONFIG_NO_BOOTMEM | ||
637 | struct bootmem_data *bdata; | ||
638 | #endif | ||
639 | #if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) | 636 | #if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) |
640 | /* | 637 | /* |
641 | * Must be held any time you expect node_start_pfn, node_present_pages | 638 | * Must be held any time you expect node_start_pfn, node_present_pages |
@@ -869,7 +866,7 @@ static inline int is_highmem_idx(enum zone_type idx) | |||
869 | } | 866 | } |
870 | 867 | ||
871 | /** | 868 | /** |
872 | * is_highmem - helper function to quickly check if a struct zone is a | 869 | * is_highmem - helper function to quickly check if a struct zone is a |
873 | * highmem zone or not. This is an attempt to keep references | 870 | * highmem zone or not. This is an attempt to keep references |
874 | * to ZONE_{DMA/NORMAL/HIGHMEM/etc} in general code to a minimum. | 871 | * to ZONE_{DMA/NORMAL/HIGHMEM/etc} in general code to a minimum. |
875 | * @zone - pointer to struct zone variable | 872 | * @zone - pointer to struct zone variable |
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 2d2096ba1cfe..1ce8e264a269 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
@@ -91,8 +91,7 @@ | |||
91 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 91 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
92 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 92 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
93 | extern __PCPU_ATTRS(sec) __typeof__(type) name; \ | 93 | extern __PCPU_ATTRS(sec) __typeof__(type) name; \ |
94 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ | 94 | __PCPU_ATTRS(sec) __weak __typeof__(type) name |
95 | __typeof__(type) name | ||
96 | #else | 95 | #else |
97 | /* | 96 | /* |
98 | * Normal declaration and definition macros. | 97 | * Normal declaration and definition macros. |
@@ -101,8 +100,7 @@ | |||
101 | extern __PCPU_ATTRS(sec) __typeof__(type) name | 100 | extern __PCPU_ATTRS(sec) __typeof__(type) name |
102 | 101 | ||
103 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | 102 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ |
104 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \ | 103 | __PCPU_ATTRS(sec) __typeof__(type) name |
105 | __typeof__(type) name | ||
106 | #endif | 104 | #endif |
107 | 105 | ||
108 | /* | 106 | /* |
diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h index af8a61be2d8d..9510c677ac70 100644 --- a/include/linux/rbtree_augmented.h +++ b/include/linux/rbtree_augmented.h | |||
@@ -51,8 +51,8 @@ extern void __rb_insert_augmented(struct rb_node *node, | |||
51 | * | 51 | * |
52 | * On insertion, the user must update the augmented information on the path | 52 | * On insertion, the user must update the augmented information on the path |
53 | * leading to the inserted node, then call rb_link_node() as usual and | 53 | * leading to the inserted node, then call rb_link_node() as usual and |
54 | * rb_augment_inserted() instead of the usual rb_insert_color() call. | 54 | * rb_insert_augmented() instead of the usual rb_insert_color() call. |
55 | * If rb_augment_inserted() rebalances the rbtree, it will callback into | 55 | * If rb_insert_augmented() rebalances the rbtree, it will callback into |
56 | * a user provided function to update the augmented information on the | 56 | * a user provided function to update the augmented information on the |
57 | * affected subtrees. | 57 | * affected subtrees. |
58 | */ | 58 | */ |
diff --git a/include/linux/signal.h b/include/linux/signal.h index 200ed96a05af..f428e86f4800 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h | |||
@@ -129,9 +129,11 @@ static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ | |||
129 | b3 = b->sig[3]; b2 = b->sig[2]; \ | 129 | b3 = b->sig[3]; b2 = b->sig[2]; \ |
130 | r->sig[3] = op(a3, b3); \ | 130 | r->sig[3] = op(a3, b3); \ |
131 | r->sig[2] = op(a2, b2); \ | 131 | r->sig[2] = op(a2, b2); \ |
132 | /* fall through */ \ | ||
132 | case 2: \ | 133 | case 2: \ |
133 | a1 = a->sig[1]; b1 = b->sig[1]; \ | 134 | a1 = a->sig[1]; b1 = b->sig[1]; \ |
134 | r->sig[1] = op(a1, b1); \ | 135 | r->sig[1] = op(a1, b1); \ |
136 | /* fall through */ \ | ||
135 | case 1: \ | 137 | case 1: \ |
136 | a0 = a->sig[0]; b0 = b->sig[0]; \ | 138 | a0 = a->sig[0]; b0 = b->sig[0]; \ |
137 | r->sig[0] = op(a0, b0); \ | 139 | r->sig[0] = op(a0, b0); \ |
@@ -161,7 +163,9 @@ static inline void name(sigset_t *set) \ | |||
161 | switch (_NSIG_WORDS) { \ | 163 | switch (_NSIG_WORDS) { \ |
162 | case 4: set->sig[3] = op(set->sig[3]); \ | 164 | case 4: set->sig[3] = op(set->sig[3]); \ |
163 | set->sig[2] = op(set->sig[2]); \ | 165 | set->sig[2] = op(set->sig[2]); \ |
166 | /* fall through */ \ | ||
164 | case 2: set->sig[1] = op(set->sig[1]); \ | 167 | case 2: set->sig[1] = op(set->sig[1]); \ |
168 | /* fall through */ \ | ||
165 | case 1: set->sig[0] = op(set->sig[0]); \ | 169 | case 1: set->sig[0] = op(set->sig[0]); \ |
166 | break; \ | 170 | break; \ |
167 | default: \ | 171 | default: \ |
@@ -182,6 +186,7 @@ static inline void sigemptyset(sigset_t *set) | |||
182 | memset(set, 0, sizeof(sigset_t)); | 186 | memset(set, 0, sizeof(sigset_t)); |
183 | break; | 187 | break; |
184 | case 2: set->sig[1] = 0; | 188 | case 2: set->sig[1] = 0; |
189 | /* fall through */ | ||
185 | case 1: set->sig[0] = 0; | 190 | case 1: set->sig[0] = 0; |
186 | break; | 191 | break; |
187 | } | 192 | } |
@@ -194,6 +199,7 @@ static inline void sigfillset(sigset_t *set) | |||
194 | memset(set, -1, sizeof(sigset_t)); | 199 | memset(set, -1, sizeof(sigset_t)); |
195 | break; | 200 | break; |
196 | case 2: set->sig[1] = -1; | 201 | case 2: set->sig[1] = -1; |
202 | /* fall through */ | ||
197 | case 1: set->sig[0] = -1; | 203 | case 1: set->sig[0] = -1; |
198 | break; | 204 | break; |
199 | } | 205 | } |
diff --git a/init/do_mounts.c b/init/do_mounts.c index e1c9afa9d8c9..a754e3ba9831 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c | |||
@@ -167,6 +167,24 @@ done: | |||
167 | } | 167 | } |
168 | return res; | 168 | return res; |
169 | } | 169 | } |
170 | |||
171 | /** | ||
172 | * match_dev_by_label - callback for finding a partition using its label | ||
173 | * @dev: device passed in by the caller | ||
174 | * @data: opaque pointer to the label to match | ||
175 | * | ||
176 | * Returns 1 if the device matches, and 0 otherwise. | ||
177 | */ | ||
178 | static int match_dev_by_label(struct device *dev, const void *data) | ||
179 | { | ||
180 | const char *label = data; | ||
181 | struct hd_struct *part = dev_to_part(dev); | ||
182 | |||
183 | if (part->info && !strcmp(label, part->info->volname)) | ||
184 | return 1; | ||
185 | |||
186 | return 0; | ||
187 | } | ||
170 | #endif | 188 | #endif |
171 | 189 | ||
172 | /* | 190 | /* |
@@ -190,6 +208,8 @@ done: | |||
190 | * a partition with a known unique id. | 208 | * a partition with a known unique id. |
191 | * 8) <major>:<minor> major and minor number of the device separated by | 209 | * 8) <major>:<minor> major and minor number of the device separated by |
192 | * a colon. | 210 | * a colon. |
211 | * 9) PARTLABEL=<name> with name being the GPT partition label. | ||
212 | * MSDOS partitions do not support labels! | ||
193 | * | 213 | * |
194 | * If name doesn't have fall into the categories above, we return (0,0). | 214 | * If name doesn't have fall into the categories above, we return (0,0). |
195 | * block_class is used to check if something is a disk name. If the disk | 215 | * block_class is used to check if something is a disk name. If the disk |
@@ -211,6 +231,17 @@ dev_t name_to_dev_t(const char *name) | |||
211 | if (!res) | 231 | if (!res) |
212 | goto fail; | 232 | goto fail; |
213 | goto done; | 233 | goto done; |
234 | } else if (strncmp(name, "PARTLABEL=", 10) == 0) { | ||
235 | struct device *dev; | ||
236 | |||
237 | dev = class_find_device(&block_class, NULL, name + 10, | ||
238 | &match_dev_by_label); | ||
239 | if (!dev) | ||
240 | goto fail; | ||
241 | |||
242 | res = dev->devt; | ||
243 | put_device(dev); | ||
244 | goto done; | ||
214 | } | 245 | } |
215 | #endif | 246 | #endif |
216 | 247 | ||
diff --git a/init/main.c b/init/main.c index 1c3f90264280..ee147103ba1b 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/initrd.h> | 27 | #include <linux/initrd.h> |
28 | #include <linux/bootmem.h> | 28 | #include <linux/memblock.h> |
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | #include <linux/console.h> | 30 | #include <linux/console.h> |
31 | #include <linux/nmi.h> | 31 | #include <linux/nmi.h> |
@@ -375,10 +375,11 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { } | |||
375 | static void __init setup_command_line(char *command_line) | 375 | static void __init setup_command_line(char *command_line) |
376 | { | 376 | { |
377 | saved_command_line = | 377 | saved_command_line = |
378 | memblock_virt_alloc(strlen(boot_command_line) + 1, 0); | 378 | memblock_alloc(strlen(boot_command_line) + 1, SMP_CACHE_BYTES); |
379 | initcall_command_line = | 379 | initcall_command_line = |
380 | memblock_virt_alloc(strlen(boot_command_line) + 1, 0); | 380 | memblock_alloc(strlen(boot_command_line) + 1, SMP_CACHE_BYTES); |
381 | static_command_line = memblock_virt_alloc(strlen(command_line) + 1, 0); | 381 | static_command_line = memblock_alloc(strlen(command_line) + 1, |
382 | SMP_CACHE_BYTES); | ||
382 | strcpy(saved_command_line, boot_command_line); | 383 | strcpy(saved_command_line, boot_command_line); |
383 | strcpy(static_command_line, command_line); | 384 | strcpy(static_command_line, command_line); |
384 | } | 385 | } |
@@ -773,8 +774,10 @@ static int __init initcall_blacklist(char *str) | |||
773 | str_entry = strsep(&str, ","); | 774 | str_entry = strsep(&str, ","); |
774 | if (str_entry) { | 775 | if (str_entry) { |
775 | pr_debug("blacklisting initcall %s\n", str_entry); | 776 | pr_debug("blacklisting initcall %s\n", str_entry); |
776 | entry = alloc_bootmem(sizeof(*entry)); | 777 | entry = memblock_alloc(sizeof(*entry), |
777 | entry->buf = alloc_bootmem(strlen(str_entry) + 1); | 778 | SMP_CACHE_BYTES); |
779 | entry->buf = memblock_alloc(strlen(str_entry) + 1, | ||
780 | SMP_CACHE_BYTES); | ||
778 | strcpy(entry->buf, str_entry); | 781 | strcpy(entry->buf, str_entry); |
779 | list_add(&entry->next, &blacklisted_initcalls); | 782 | list_add(&entry->next, &blacklisted_initcalls); |
780 | } | 783 | } |
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c index 8ad93c29f511..49f9bf4ffc7f 100644 --- a/ipc/ipc_sysctl.c +++ b/ipc/ipc_sysctl.c | |||
@@ -88,17 +88,39 @@ static int proc_ipc_auto_msgmni(struct ctl_table *table, int write, | |||
88 | return proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos); | 88 | return proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos); |
89 | } | 89 | } |
90 | 90 | ||
91 | static int proc_ipc_sem_dointvec(struct ctl_table *table, int write, | ||
92 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
93 | { | ||
94 | int ret, semmni; | ||
95 | struct ipc_namespace *ns = current->nsproxy->ipc_ns; | ||
96 | |||
97 | semmni = ns->sem_ctls[3]; | ||
98 | ret = proc_ipc_dointvec(table, write, buffer, lenp, ppos); | ||
99 | |||
100 | if (!ret) | ||
101 | ret = sem_check_semmni(current->nsproxy->ipc_ns); | ||
102 | |||
103 | /* | ||
104 | * Reset the semmni value if an error happens. | ||
105 | */ | ||
106 | if (ret) | ||
107 | ns->sem_ctls[3] = semmni; | ||
108 | return ret; | ||
109 | } | ||
110 | |||
91 | #else | 111 | #else |
92 | #define proc_ipc_doulongvec_minmax NULL | 112 | #define proc_ipc_doulongvec_minmax NULL |
93 | #define proc_ipc_dointvec NULL | 113 | #define proc_ipc_dointvec NULL |
94 | #define proc_ipc_dointvec_minmax NULL | 114 | #define proc_ipc_dointvec_minmax NULL |
95 | #define proc_ipc_dointvec_minmax_orphans NULL | 115 | #define proc_ipc_dointvec_minmax_orphans NULL |
96 | #define proc_ipc_auto_msgmni NULL | 116 | #define proc_ipc_auto_msgmni NULL |
117 | #define proc_ipc_sem_dointvec NULL | ||
97 | #endif | 118 | #endif |
98 | 119 | ||
99 | static int zero; | 120 | static int zero; |
100 | static int one = 1; | 121 | static int one = 1; |
101 | static int int_max = INT_MAX; | 122 | static int int_max = INT_MAX; |
123 | static int ipc_mni = IPCMNI; | ||
102 | 124 | ||
103 | static struct ctl_table ipc_kern_table[] = { | 125 | static struct ctl_table ipc_kern_table[] = { |
104 | { | 126 | { |
@@ -120,7 +142,9 @@ static struct ctl_table ipc_kern_table[] = { | |||
120 | .data = &init_ipc_ns.shm_ctlmni, | 142 | .data = &init_ipc_ns.shm_ctlmni, |
121 | .maxlen = sizeof(init_ipc_ns.shm_ctlmni), | 143 | .maxlen = sizeof(init_ipc_ns.shm_ctlmni), |
122 | .mode = 0644, | 144 | .mode = 0644, |
123 | .proc_handler = proc_ipc_dointvec, | 145 | .proc_handler = proc_ipc_dointvec_minmax, |
146 | .extra1 = &zero, | ||
147 | .extra2 = &ipc_mni, | ||
124 | }, | 148 | }, |
125 | { | 149 | { |
126 | .procname = "shm_rmid_forced", | 150 | .procname = "shm_rmid_forced", |
@@ -147,7 +171,7 @@ static struct ctl_table ipc_kern_table[] = { | |||
147 | .mode = 0644, | 171 | .mode = 0644, |
148 | .proc_handler = proc_ipc_dointvec_minmax, | 172 | .proc_handler = proc_ipc_dointvec_minmax, |
149 | .extra1 = &zero, | 173 | .extra1 = &zero, |
150 | .extra2 = &int_max, | 174 | .extra2 = &ipc_mni, |
151 | }, | 175 | }, |
152 | { | 176 | { |
153 | .procname = "auto_msgmni", | 177 | .procname = "auto_msgmni", |
@@ -172,7 +196,7 @@ static struct ctl_table ipc_kern_table[] = { | |||
172 | .data = &init_ipc_ns.sem_ctls, | 196 | .data = &init_ipc_ns.sem_ctls, |
173 | .maxlen = 4*sizeof(int), | 197 | .maxlen = 4*sizeof(int), |
174 | .mode = 0644, | 198 | .mode = 0644, |
175 | .proc_handler = proc_ipc_dointvec, | 199 | .proc_handler = proc_ipc_sem_dointvec, |
176 | }, | 200 | }, |
177 | #ifdef CONFIG_CHECKPOINT_RESTORE | 201 | #ifdef CONFIG_CHECKPOINT_RESTORE |
178 | { | 202 | { |
diff --git a/ipc/util.h b/ipc/util.h index 1ee81bce25e9..d768fdbed515 100644 --- a/ipc/util.h +++ b/ipc/util.h | |||
@@ -217,6 +217,15 @@ int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, | |||
217 | void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, | 217 | void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, |
218 | void (*free)(struct ipc_namespace *, struct kern_ipc_perm *)); | 218 | void (*free)(struct ipc_namespace *, struct kern_ipc_perm *)); |
219 | 219 | ||
220 | static inline int sem_check_semmni(struct ipc_namespace *ns) { | ||
221 | /* | ||
222 | * Check semmni range [0, IPCMNI] | ||
223 | * semmni is the last element of sem_ctls[4] array | ||
224 | */ | ||
225 | return ((ns->sem_ctls[3] < 0) || (ns->sem_ctls[3] > IPCMNI)) | ||
226 | ? -ERANGE : 0; | ||
227 | } | ||
228 | |||
220 | #ifdef CONFIG_COMPAT | 229 | #ifdef CONFIG_COMPAT |
221 | #include <linux/compat.h> | 230 | #include <linux/compat.h> |
222 | struct compat_ipc_perm { | 231 | struct compat_ipc_perm { |
diff --git a/kernel/bounds.c b/kernel/bounds.c index c373e887c066..9795d75b09b2 100644 --- a/kernel/bounds.c +++ b/kernel/bounds.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/log2.h> | 13 | #include <linux/log2.h> |
14 | #include <linux/spinlock_types.h> | 14 | #include <linux/spinlock_types.h> |
15 | 15 | ||
16 | void foo(void) | 16 | int main(void) |
17 | { | 17 | { |
18 | /* The enum constants to put into include/generated/bounds.h */ | 18 | /* The enum constants to put into include/generated/bounds.h */ |
19 | DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS); | 19 | DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS); |
@@ -23,4 +23,6 @@ void foo(void) | |||
23 | #endif | 23 | #endif |
24 | DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); | 24 | DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); |
25 | /* End of constants */ | 25 | /* End of constants */ |
26 | |||
27 | return 0; | ||
26 | } | 28 | } |
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index f14c376937e5..22a12ab5a5e9 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * DMA operations that map physical memory directly without using an IOMMU. | 5 | * DMA operations that map physical memory directly without using an IOMMU. |
6 | */ | 6 | */ |
7 | #include <linux/bootmem.h> /* for max_pfn */ | 7 | #include <linux/memblock.h> /* for max_pfn */ |
8 | #include <linux/export.h> | 8 | #include <linux/export.h> |
9 | #include <linux/mm.h> | 9 | #include <linux/mm.h> |
10 | #include <linux/dma-direct.h> | 10 | #include <linux/dma-direct.h> |
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index ebecaf255ea2..5731daa09a32 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/dma.h> | 40 | #include <asm/dma.h> |
41 | 41 | ||
42 | #include <linux/init.h> | 42 | #include <linux/init.h> |
43 | #include <linux/bootmem.h> | 43 | #include <linux/memblock.h> |
44 | #include <linux/iommu-helper.h> | 44 | #include <linux/iommu-helper.h> |
45 | 45 | ||
46 | #define CREATE_TRACE_POINTS | 46 | #define CREATE_TRACE_POINTS |
@@ -204,10 +204,10 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) | |||
204 | * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE | 204 | * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE |
205 | * between io_tlb_start and io_tlb_end. | 205 | * between io_tlb_start and io_tlb_end. |
206 | */ | 206 | */ |
207 | io_tlb_list = memblock_virt_alloc( | 207 | io_tlb_list = memblock_alloc( |
208 | PAGE_ALIGN(io_tlb_nslabs * sizeof(int)), | 208 | PAGE_ALIGN(io_tlb_nslabs * sizeof(int)), |
209 | PAGE_SIZE); | 209 | PAGE_SIZE); |
210 | io_tlb_orig_addr = memblock_virt_alloc( | 210 | io_tlb_orig_addr = memblock_alloc( |
211 | PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)), | 211 | PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)), |
212 | PAGE_SIZE); | 212 | PAGE_SIZE); |
213 | for (i = 0; i < io_tlb_nslabs; i++) { | 213 | for (i = 0; i < io_tlb_nslabs; i++) { |
@@ -242,7 +242,7 @@ swiotlb_init(int verbose) | |||
242 | bytes = io_tlb_nslabs << IO_TLB_SHIFT; | 242 | bytes = io_tlb_nslabs << IO_TLB_SHIFT; |
243 | 243 | ||
244 | /* Get IO TLB memory from the low pages */ | 244 | /* Get IO TLB memory from the low pages */ |
245 | vstart = memblock_virt_alloc_low_nopanic(PAGE_ALIGN(bytes), PAGE_SIZE); | 245 | vstart = memblock_alloc_low_nopanic(PAGE_ALIGN(bytes), PAGE_SIZE); |
246 | if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) | 246 | if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) |
247 | return; | 247 | return; |
248 | 248 | ||
diff --git a/kernel/fail_function.c b/kernel/fail_function.c index bc80a4e268c0..17f75b545f66 100644 --- a/kernel/fail_function.c +++ b/kernel/fail_function.c | |||
@@ -173,8 +173,7 @@ static void fei_debugfs_remove_attr(struct fei_attr *attr) | |||
173 | struct dentry *dir; | 173 | struct dentry *dir; |
174 | 174 | ||
175 | dir = debugfs_lookup(attr->kp.symbol_name, fei_debugfs_dir); | 175 | dir = debugfs_lookup(attr->kp.symbol_name, fei_debugfs_dir); |
176 | if (dir) | 176 | debugfs_remove_recursive(dir); |
177 | debugfs_remove_recursive(dir); | ||
178 | } | 177 | } |
179 | 178 | ||
180 | static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs) | 179 | static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs) |
diff --git a/kernel/futex.c b/kernel/futex.c index 3e2de8fc1891..f423f9b6577e 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -65,7 +65,7 @@ | |||
65 | #include <linux/sched/mm.h> | 65 | #include <linux/sched/mm.h> |
66 | #include <linux/hugetlb.h> | 66 | #include <linux/hugetlb.h> |
67 | #include <linux/freezer.h> | 67 | #include <linux/freezer.h> |
68 | #include <linux/bootmem.h> | 68 | #include <linux/memblock.h> |
69 | #include <linux/fault-inject.h> | 69 | #include <linux/fault-inject.h> |
70 | 70 | ||
71 | #include <asm/futex.h> | 71 | #include <asm/futex.h> |
diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h index 0130e488ebfe..8f36c27c1794 100644 --- a/kernel/locking/qspinlock_paravirt.h +++ b/kernel/locking/qspinlock_paravirt.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #endif | 4 | #endif |
5 | 5 | ||
6 | #include <linux/hash.h> | 6 | #include <linux/hash.h> |
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | #include <linux/debug_locks.h> | 8 | #include <linux/debug_locks.h> |
9 | 9 | ||
10 | /* | 10 | /* |
diff --git a/kernel/panic.c b/kernel/panic.c index 8b2e002d52eb..f6d549a29a5c 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -136,7 +136,7 @@ void panic(const char *fmt, ...) | |||
136 | { | 136 | { |
137 | static char buf[1024]; | 137 | static char buf[1024]; |
138 | va_list args; | 138 | va_list args; |
139 | long i, i_next = 0; | 139 | long i, i_next = 0, len; |
140 | int state = 0; | 140 | int state = 0; |
141 | int old_cpu, this_cpu; | 141 | int old_cpu, this_cpu; |
142 | bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; | 142 | bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; |
@@ -173,8 +173,12 @@ void panic(const char *fmt, ...) | |||
173 | console_verbose(); | 173 | console_verbose(); |
174 | bust_spinlocks(1); | 174 | bust_spinlocks(1); |
175 | va_start(args, fmt); | 175 | va_start(args, fmt); |
176 | vsnprintf(buf, sizeof(buf), fmt, args); | 176 | len = vscnprintf(buf, sizeof(buf), fmt, args); |
177 | va_end(args); | 177 | va_end(args); |
178 | |||
179 | if (len && buf[len - 1] == '\n') | ||
180 | buf[len - 1] = '\0'; | ||
181 | |||
178 | pr_emerg("Kernel panic - not syncing: %s\n", buf); | 182 | pr_emerg("Kernel panic - not syncing: %s\n", buf); |
179 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 183 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
180 | /* | 184 | /* |
@@ -631,7 +635,7 @@ device_initcall(register_warn_debugfs); | |||
631 | */ | 635 | */ |
632 | __visible void __stack_chk_fail(void) | 636 | __visible void __stack_chk_fail(void) |
633 | { | 637 | { |
634 | panic("stack-protector: Kernel stack is corrupted in: %pB\n", | 638 | panic("stack-protector: Kernel stack is corrupted in: %pB", |
635 | __builtin_return_address(0)); | 639 | __builtin_return_address(0)); |
636 | } | 640 | } |
637 | EXPORT_SYMBOL(__stack_chk_fail); | 641 | EXPORT_SYMBOL(__stack_chk_fail); |
diff --git a/kernel/pid.c b/kernel/pid.c index cdf63e53a014..b2f6c506035d 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/rculist.h> | 33 | #include <linux/rculist.h> |
34 | #include <linux/bootmem.h> | 34 | #include <linux/memblock.h> |
35 | #include <linux/hash.h> | 35 | #include <linux/hash.h> |
36 | #include <linux/pid_namespace.h> | 36 | #include <linux/pid_namespace.h> |
37 | #include <linux/init_task.h> | 37 | #include <linux/init_task.h> |
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 3d37c279c090..b0308a2c6000 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/pm.h> | 23 | #include <linux/pm.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/bootmem.h> | 26 | #include <linux/memblock.h> |
27 | #include <linux/nmi.h> | 27 | #include <linux/nmi.h> |
28 | #include <linux/syscalls.h> | 28 | #include <linux/syscalls.h> |
29 | #include <linux/console.h> | 29 | #include <linux/console.h> |
@@ -963,7 +963,8 @@ void __init __register_nosave_region(unsigned long start_pfn, | |||
963 | BUG_ON(!region); | 963 | BUG_ON(!region); |
964 | } else { | 964 | } else { |
965 | /* This allocation cannot fail */ | 965 | /* This allocation cannot fail */ |
966 | region = memblock_virt_alloc(sizeof(struct nosave_region), 0); | 966 | region = memblock_alloc(sizeof(struct nosave_region), |
967 | SMP_CACHE_BYTES); | ||
967 | } | 968 | } |
968 | region->start_pfn = start_pfn; | 969 | region->start_pfn = start_pfn; |
969 | region->end_pfn = end_pfn; | 970 | region->end_pfn = end_pfn; |
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index b77150ad1965..1b2a029360b7 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/smp.h> | 32 | #include <linux/smp.h> |
33 | #include <linux/security.h> | 33 | #include <linux/security.h> |
34 | #include <linux/bootmem.h> | ||
35 | #include <linux/memblock.h> | 34 | #include <linux/memblock.h> |
36 | #include <linux/syscalls.h> | 35 | #include <linux/syscalls.h> |
37 | #include <linux/crash_core.h> | 36 | #include <linux/crash_core.h> |
@@ -1111,9 +1110,9 @@ void __init setup_log_buf(int early) | |||
1111 | 1110 | ||
1112 | if (early) { | 1111 | if (early) { |
1113 | new_log_buf = | 1112 | new_log_buf = |
1114 | memblock_virt_alloc(new_log_buf_len, LOG_ALIGN); | 1113 | memblock_alloc(new_log_buf_len, LOG_ALIGN); |
1115 | } else { | 1114 | } else { |
1116 | new_log_buf = memblock_virt_alloc_nopanic(new_log_buf_len, | 1115 | new_log_buf = memblock_alloc_nopanic(new_log_buf_len, |
1117 | LOG_ALIGN); | 1116 | LOG_ALIGN); |
1118 | } | 1117 | } |
1119 | 1118 | ||
diff --git a/kernel/profile.c b/kernel/profile.c index 9aa2a4445b0d..9c08a2c7cb1d 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/export.h> | 17 | #include <linux/export.h> |
18 | #include <linux/profile.h> | 18 | #include <linux/profile.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/memblock.h> |
20 | #include <linux/notifier.h> | 20 | #include <linux/notifier.h> |
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/cpumask.h> | 22 | #include <linux/cpumask.h> |
diff --git a/kernel/signal.c b/kernel/signal.c index 17565240b1c6..9a32bc2088c9 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -892,7 +892,7 @@ static bool prepare_signal(int sig, struct task_struct *p, bool force) | |||
892 | /* | 892 | /* |
893 | * The first thread which returns from do_signal_stop() | 893 | * The first thread which returns from do_signal_stop() |
894 | * will take ->siglock, notice SIGNAL_CLD_MASK, and | 894 | * will take ->siglock, notice SIGNAL_CLD_MASK, and |
895 | * notify its parent. See get_signal_to_deliver(). | 895 | * notify its parent. See get_signal(). |
896 | */ | 896 | */ |
897 | signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED); | 897 | signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED); |
898 | signal->group_stop_count = 0; | 898 | signal->group_stop_count = 0; |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index e0ba05e6f6bd..1af29b8224fd 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -1292,7 +1292,7 @@ config DEBUG_KOBJECT | |||
1292 | depends on DEBUG_KERNEL | 1292 | depends on DEBUG_KERNEL |
1293 | help | 1293 | help |
1294 | If you say Y here, some extra kobject debugging messages will be sent | 1294 | If you say Y here, some extra kobject debugging messages will be sent |
1295 | to the syslog. | 1295 | to the syslog. |
1296 | 1296 | ||
1297 | config DEBUG_KOBJECT_RELEASE | 1297 | config DEBUG_KOBJECT_RELEASE |
1298 | bool "kobject release debugging" | 1298 | bool "kobject release debugging" |
@@ -1980,7 +1980,6 @@ endif # RUNTIME_TESTING_MENU | |||
1980 | 1980 | ||
1981 | config MEMTEST | 1981 | config MEMTEST |
1982 | bool "Memtest" | 1982 | bool "Memtest" |
1983 | depends on HAVE_MEMBLOCK | ||
1984 | ---help--- | 1983 | ---help--- |
1985 | This option adds a kernel parameter 'memtest', which allows memtest | 1984 | This option adds a kernel parameter 'memtest', which allows memtest |
1986 | to be set. | 1985 | to be set. |
diff --git a/lib/bitmap.c b/lib/bitmap.c index 2fd07f6df0b8..eead55aa7170 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/mm.h> | ||
16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
17 | #include <linux/string.h> | 18 | #include <linux/string.h> |
18 | #include <linux/uaccess.h> | 19 | #include <linux/uaccess.h> |
@@ -36,11 +37,6 @@ | |||
36 | * carefully filter out these unused bits from impacting their | 37 | * carefully filter out these unused bits from impacting their |
37 | * results. | 38 | * results. |
38 | * | 39 | * |
39 | * These operations actually hold to a slightly stronger rule: | ||
40 | * if you don't input any bitmaps to these ops that have some | ||
41 | * unused bits set, then they won't output any set unused bits | ||
42 | * in output bitmaps. | ||
43 | * | ||
44 | * The byte ordering of bitmaps is more natural on little | 40 | * The byte ordering of bitmaps is more natural on little |
45 | * endian architectures. See the big-endian headers | 41 | * endian architectures. See the big-endian headers |
46 | * include/asm-ppc64/bitops.h and include/asm-s390/bitops.h | 42 | * include/asm-ppc64/bitops.h and include/asm-s390/bitops.h |
@@ -466,20 +462,18 @@ EXPORT_SYMBOL(bitmap_parse_user); | |||
466 | * ranges if list is specified or hex digits grouped into comma-separated | 462 | * ranges if list is specified or hex digits grouped into comma-separated |
467 | * sets of 8 digits/set. Returns the number of characters written to buf. | 463 | * sets of 8 digits/set. Returns the number of characters written to buf. |
468 | * | 464 | * |
469 | * It is assumed that @buf is a pointer into a PAGE_SIZE area and that | 465 | * It is assumed that @buf is a pointer into a PAGE_SIZE, page-aligned |
470 | * sufficient storage remains at @buf to accommodate the | 466 | * area and that sufficient storage remains at @buf to accommodate the |
471 | * bitmap_print_to_pagebuf() output. | 467 | * bitmap_print_to_pagebuf() output. Returns the number of characters |
468 | * actually printed to @buf, excluding terminating '\0'. | ||
472 | */ | 469 | */ |
473 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, | 470 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, |
474 | int nmaskbits) | 471 | int nmaskbits) |
475 | { | 472 | { |
476 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; | 473 | ptrdiff_t len = PAGE_SIZE - offset_in_page(buf); |
477 | int n = 0; | ||
478 | 474 | ||
479 | if (len > 1) | 475 | return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) : |
480 | n = list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) : | 476 | scnprintf(buf, len, "%*pb\n", nmaskbits, maskp); |
481 | scnprintf(buf, len, "%*pb\n", nmaskbits, maskp); | ||
482 | return n; | ||
483 | } | 477 | } |
484 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); | 478 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); |
485 | 479 | ||
diff --git a/lib/cpumask.c b/lib/cpumask.c index beca6244671a..8d666ab84b5c 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <linux/bitops.h> | 4 | #include <linux/bitops.h> |
5 | #include <linux/cpumask.h> | 5 | #include <linux/cpumask.h> |
6 | #include <linux/export.h> | 6 | #include <linux/export.h> |
7 | #include <linux/bootmem.h> | 7 | #include <linux/memblock.h> |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * cpumask_next - get the next cpu in a cpumask | 10 | * cpumask_next - get the next cpu in a cpumask |
@@ -163,7 +163,7 @@ EXPORT_SYMBOL(zalloc_cpumask_var); | |||
163 | */ | 163 | */ |
164 | void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask) | 164 | void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask) |
165 | { | 165 | { |
166 | *mask = memblock_virt_alloc(cpumask_size(), 0); | 166 | *mask = memblock_alloc(cpumask_size(), SMP_CACHE_BYTES); |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index 661a1e807bd1..1006bf70bf74 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
@@ -175,7 +175,7 @@ int _kstrtoul(const char *s, unsigned int base, unsigned long *res) | |||
175 | rv = kstrtoull(s, base, &tmp); | 175 | rv = kstrtoull(s, base, &tmp); |
176 | if (rv < 0) | 176 | if (rv < 0) |
177 | return rv; | 177 | return rv; |
178 | if (tmp != (unsigned long long)(unsigned long)tmp) | 178 | if (tmp != (unsigned long)tmp) |
179 | return -ERANGE; | 179 | return -ERANGE; |
180 | *res = tmp; | 180 | *res = tmp; |
181 | return 0; | 181 | return 0; |
@@ -191,7 +191,7 @@ int _kstrtol(const char *s, unsigned int base, long *res) | |||
191 | rv = kstrtoll(s, base, &tmp); | 191 | rv = kstrtoll(s, base, &tmp); |
192 | if (rv < 0) | 192 | if (rv < 0) |
193 | return rv; | 193 | return rv; |
194 | if (tmp != (long long)(long)tmp) | 194 | if (tmp != (long)tmp) |
195 | return -ERANGE; | 195 | return -ERANGE; |
196 | *res = tmp; | 196 | *res = tmp; |
197 | return 0; | 197 | return 0; |
@@ -222,7 +222,7 @@ int kstrtouint(const char *s, unsigned int base, unsigned int *res) | |||
222 | rv = kstrtoull(s, base, &tmp); | 222 | rv = kstrtoull(s, base, &tmp); |
223 | if (rv < 0) | 223 | if (rv < 0) |
224 | return rv; | 224 | return rv; |
225 | if (tmp != (unsigned long long)(unsigned int)tmp) | 225 | if (tmp != (unsigned int)tmp) |
226 | return -ERANGE; | 226 | return -ERANGE; |
227 | *res = tmp; | 227 | *res = tmp; |
228 | return 0; | 228 | return 0; |
@@ -253,7 +253,7 @@ int kstrtoint(const char *s, unsigned int base, int *res) | |||
253 | rv = kstrtoll(s, base, &tmp); | 253 | rv = kstrtoll(s, base, &tmp); |
254 | if (rv < 0) | 254 | if (rv < 0) |
255 | return rv; | 255 | return rv; |
256 | if (tmp != (long long)(int)tmp) | 256 | if (tmp != (int)tmp) |
257 | return -ERANGE; | 257 | return -ERANGE; |
258 | *res = tmp; | 258 | *res = tmp; |
259 | return 0; | 259 | return 0; |
@@ -268,7 +268,7 @@ int kstrtou16(const char *s, unsigned int base, u16 *res) | |||
268 | rv = kstrtoull(s, base, &tmp); | 268 | rv = kstrtoull(s, base, &tmp); |
269 | if (rv < 0) | 269 | if (rv < 0) |
270 | return rv; | 270 | return rv; |
271 | if (tmp != (unsigned long long)(u16)tmp) | 271 | if (tmp != (u16)tmp) |
272 | return -ERANGE; | 272 | return -ERANGE; |
273 | *res = tmp; | 273 | *res = tmp; |
274 | return 0; | 274 | return 0; |
@@ -283,7 +283,7 @@ int kstrtos16(const char *s, unsigned int base, s16 *res) | |||
283 | rv = kstrtoll(s, base, &tmp); | 283 | rv = kstrtoll(s, base, &tmp); |
284 | if (rv < 0) | 284 | if (rv < 0) |
285 | return rv; | 285 | return rv; |
286 | if (tmp != (long long)(s16)tmp) | 286 | if (tmp != (s16)tmp) |
287 | return -ERANGE; | 287 | return -ERANGE; |
288 | *res = tmp; | 288 | *res = tmp; |
289 | return 0; | 289 | return 0; |
@@ -298,7 +298,7 @@ int kstrtou8(const char *s, unsigned int base, u8 *res) | |||
298 | rv = kstrtoull(s, base, &tmp); | 298 | rv = kstrtoull(s, base, &tmp); |
299 | if (rv < 0) | 299 | if (rv < 0) |
300 | return rv; | 300 | return rv; |
301 | if (tmp != (unsigned long long)(u8)tmp) | 301 | if (tmp != (u8)tmp) |
302 | return -ERANGE; | 302 | return -ERANGE; |
303 | *res = tmp; | 303 | *res = tmp; |
304 | return 0; | 304 | return 0; |
@@ -313,7 +313,7 @@ int kstrtos8(const char *s, unsigned int base, s8 *res) | |||
313 | rv = kstrtoll(s, base, &tmp); | 313 | rv = kstrtoll(s, base, &tmp); |
314 | if (rv < 0) | 314 | if (rv < 0) |
315 | return rv; | 315 | return rv; |
316 | if (tmp != (long long)(s8)tmp) | 316 | if (tmp != (s8)tmp) |
317 | return -ERANGE; | 317 | return -ERANGE; |
318 | *res = tmp; | 318 | *res = tmp; |
319 | return 0; | 319 | return 0; |
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index 141734d255e4..0c9d3ad17e0f 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c | |||
@@ -43,30 +43,36 @@ | |||
43 | /*-***************************** | 43 | /*-***************************** |
44 | * Decompression functions | 44 | * Decompression functions |
45 | *******************************/ | 45 | *******************************/ |
46 | /* LZ4_decompress_generic() : | 46 | |
47 | * This generic decompression function cover all use cases. | 47 | #define DEBUGLOG(l, ...) {} /* disabled */ |
48 | * It shall be instantiated several times, using different sets of directives | 48 | |
49 | * Note that it is important this generic function is really inlined, | 49 | #ifndef assert |
50 | #define assert(condition) ((void)0) | ||
51 | #endif | ||
52 | |||
53 | /* | ||
54 | * LZ4_decompress_generic() : | ||
55 | * This generic decompression function covers all use cases. | ||
56 | * It shall be instantiated several times, using different sets of directives. | ||
57 | * Note that it is important for performance that this function really get inlined, | ||
50 | * in order to remove useless branches during compilation optimization. | 58 | * in order to remove useless branches during compilation optimization. |
51 | */ | 59 | */ |
52 | static FORCE_INLINE int LZ4_decompress_generic( | 60 | static FORCE_INLINE int LZ4_decompress_generic( |
53 | const char * const source, | 61 | const char * const src, |
54 | char * const dest, | 62 | char * const dst, |
55 | int inputSize, | 63 | int srcSize, |
56 | /* | 64 | /* |
57 | * If endOnInput == endOnInputSize, | 65 | * If endOnInput == endOnInputSize, |
58 | * this value is the max size of Output Buffer. | 66 | * this value is `dstCapacity` |
59 | */ | 67 | */ |
60 | int outputSize, | 68 | int outputSize, |
61 | /* endOnOutputSize, endOnInputSize */ | 69 | /* endOnOutputSize, endOnInputSize */ |
62 | int endOnInput, | 70 | endCondition_directive endOnInput, |
63 | /* full, partial */ | 71 | /* full, partial */ |
64 | int partialDecoding, | 72 | earlyEnd_directive partialDecoding, |
65 | /* only used if partialDecoding == partial */ | ||
66 | int targetOutputSize, | ||
67 | /* noDict, withPrefix64k, usingExtDict */ | 73 | /* noDict, withPrefix64k, usingExtDict */ |
68 | int dict, | 74 | dict_directive dict, |
69 | /* == dest when no prefix */ | 75 | /* always <= dst, == dst when no prefix */ |
70 | const BYTE * const lowPrefix, | 76 | const BYTE * const lowPrefix, |
71 | /* only if dict == usingExtDict */ | 77 | /* only if dict == usingExtDict */ |
72 | const BYTE * const dictStart, | 78 | const BYTE * const dictStart, |
@@ -74,35 +80,43 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
74 | const size_t dictSize | 80 | const size_t dictSize |
75 | ) | 81 | ) |
76 | { | 82 | { |
77 | /* Local Variables */ | 83 | const BYTE *ip = (const BYTE *) src; |
78 | const BYTE *ip = (const BYTE *) source; | 84 | const BYTE * const iend = ip + srcSize; |
79 | const BYTE * const iend = ip + inputSize; | ||
80 | 85 | ||
81 | BYTE *op = (BYTE *) dest; | 86 | BYTE *op = (BYTE *) dst; |
82 | BYTE * const oend = op + outputSize; | 87 | BYTE * const oend = op + outputSize; |
83 | BYTE *cpy; | 88 | BYTE *cpy; |
84 | BYTE *oexit = op + targetOutputSize; | ||
85 | const BYTE * const lowLimit = lowPrefix - dictSize; | ||
86 | 89 | ||
87 | const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize; | 90 | const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize; |
88 | static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; | 91 | static const unsigned int inc32table[8] = {0, 1, 2, 1, 0, 4, 4, 4}; |
89 | static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; | 92 | static const int dec64table[8] = {0, 0, 0, -1, -4, 1, 2, 3}; |
90 | 93 | ||
91 | const int safeDecode = (endOnInput == endOnInputSize); | 94 | const int safeDecode = (endOnInput == endOnInputSize); |
92 | const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB))); | 95 | const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB))); |
93 | 96 | ||
97 | /* Set up the "end" pointers for the shortcut. */ | ||
98 | const BYTE *const shortiend = iend - | ||
99 | (endOnInput ? 14 : 8) /*maxLL*/ - 2 /*offset*/; | ||
100 | const BYTE *const shortoend = oend - | ||
101 | (endOnInput ? 14 : 8) /*maxLL*/ - 18 /*maxML*/; | ||
102 | |||
103 | DEBUGLOG(5, "%s (srcSize:%i, dstSize:%i)", __func__, | ||
104 | srcSize, outputSize); | ||
105 | |||
94 | /* Special cases */ | 106 | /* Special cases */ |
95 | /* targetOutputSize too high => decode everything */ | 107 | assert(lowPrefix <= op); |
96 | if ((partialDecoding) && (oexit > oend - MFLIMIT)) | 108 | assert(src != NULL); |
97 | oexit = oend - MFLIMIT; | ||
98 | 109 | ||
99 | /* Empty output buffer */ | 110 | /* Empty output buffer */ |
100 | if ((endOnInput) && (unlikely(outputSize == 0))) | 111 | if ((endOnInput) && (unlikely(outputSize == 0))) |
101 | return ((inputSize == 1) && (*ip == 0)) ? 0 : -1; | 112 | return ((srcSize == 1) && (*ip == 0)) ? 0 : -1; |
102 | 113 | ||
103 | if ((!endOnInput) && (unlikely(outputSize == 0))) | 114 | if ((!endOnInput) && (unlikely(outputSize == 0))) |
104 | return (*ip == 0 ? 1 : -1); | 115 | return (*ip == 0 ? 1 : -1); |
105 | 116 | ||
117 | if ((endOnInput) && unlikely(srcSize == 0)) | ||
118 | return -1; | ||
119 | |||
106 | /* Main Loop : decode sequences */ | 120 | /* Main Loop : decode sequences */ |
107 | while (1) { | 121 | while (1) { |
108 | size_t length; | 122 | size_t length; |
@@ -111,12 +125,74 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
111 | 125 | ||
112 | /* get literal length */ | 126 | /* get literal length */ |
113 | unsigned int const token = *ip++; | 127 | unsigned int const token = *ip++; |
114 | |||
115 | length = token>>ML_BITS; | 128 | length = token>>ML_BITS; |
116 | 129 | ||
130 | /* ip < iend before the increment */ | ||
131 | assert(!endOnInput || ip <= iend); | ||
132 | |||
133 | /* | ||
134 | * A two-stage shortcut for the most common case: | ||
135 | * 1) If the literal length is 0..14, and there is enough | ||
136 | * space, enter the shortcut and copy 16 bytes on behalf | ||
137 | * of the literals (in the fast mode, only 8 bytes can be | ||
138 | * safely copied this way). | ||
139 | * 2) Further if the match length is 4..18, copy 18 bytes | ||
140 | * in a similar manner; but we ensure that there's enough | ||
141 | * space in the output for those 18 bytes earlier, upon | ||
142 | * entering the shortcut (in other words, there is a | ||
143 | * combined check for both stages). | ||
144 | */ | ||
145 | if ((endOnInput ? length != RUN_MASK : length <= 8) | ||
146 | /* | ||
147 | * strictly "less than" on input, to re-enter | ||
148 | * the loop with at least one byte | ||
149 | */ | ||
150 | && likely((endOnInput ? ip < shortiend : 1) & | ||
151 | (op <= shortoend))) { | ||
152 | /* Copy the literals */ | ||
153 | memcpy(op, ip, endOnInput ? 16 : 8); | ||
154 | op += length; ip += length; | ||
155 | |||
156 | /* | ||
157 | * The second stage: | ||
158 | * prepare for match copying, decode full info. | ||
159 | * If it doesn't work out, the info won't be wasted. | ||
160 | */ | ||
161 | length = token & ML_MASK; /* match length */ | ||
162 | offset = LZ4_readLE16(ip); | ||
163 | ip += 2; | ||
164 | match = op - offset; | ||
165 | assert(match <= op); /* check overflow */ | ||
166 | |||
167 | /* Do not deal with overlapping matches. */ | ||
168 | if ((length != ML_MASK) && | ||
169 | (offset >= 8) && | ||
170 | (dict == withPrefix64k || match >= lowPrefix)) { | ||
171 | /* Copy the match. */ | ||
172 | memcpy(op + 0, match + 0, 8); | ||
173 | memcpy(op + 8, match + 8, 8); | ||
174 | memcpy(op + 16, match + 16, 2); | ||
175 | op += length + MINMATCH; | ||
176 | /* Both stages worked, load the next token. */ | ||
177 | continue; | ||
178 | } | ||
179 | |||
180 | /* | ||
181 | * The second stage didn't work out, but the info | ||
182 | * is ready. Propel it right to the point of match | ||
183 | * copying. | ||
184 | */ | ||
185 | goto _copy_match; | ||
186 | } | ||
187 | |||
188 | /* decode literal length */ | ||
117 | if (length == RUN_MASK) { | 189 | if (length == RUN_MASK) { |
118 | unsigned int s; | 190 | unsigned int s; |
119 | 191 | ||
192 | if (unlikely(endOnInput ? ip >= iend - RUN_MASK : 0)) { | ||
193 | /* overflow detection */ | ||
194 | goto _output_error; | ||
195 | } | ||
120 | do { | 196 | do { |
121 | s = *ip++; | 197 | s = *ip++; |
122 | length += s; | 198 | length += s; |
@@ -125,14 +201,14 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
125 | : 1) & (s == 255)); | 201 | : 1) & (s == 255)); |
126 | 202 | ||
127 | if ((safeDecode) | 203 | if ((safeDecode) |
128 | && unlikely( | 204 | && unlikely((uptrval)(op) + |
129 | (size_t)(op + length) < (size_t)(op))) { | 205 | length < (uptrval)(op))) { |
130 | /* overflow detection */ | 206 | /* overflow detection */ |
131 | goto _output_error; | 207 | goto _output_error; |
132 | } | 208 | } |
133 | if ((safeDecode) | 209 | if ((safeDecode) |
134 | && unlikely( | 210 | && unlikely((uptrval)(ip) + |
135 | (size_t)(ip + length) < (size_t)(ip))) { | 211 | length < (uptrval)(ip))) { |
136 | /* overflow detection */ | 212 | /* overflow detection */ |
137 | goto _output_error; | 213 | goto _output_error; |
138 | } | 214 | } |
@@ -140,16 +216,19 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
140 | 216 | ||
141 | /* copy literals */ | 217 | /* copy literals */ |
142 | cpy = op + length; | 218 | cpy = op + length; |
143 | if (((endOnInput) && ((cpy > (partialDecoding ? oexit : oend - MFLIMIT)) | 219 | LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH); |
220 | |||
221 | if (((endOnInput) && ((cpy > oend - MFLIMIT) | ||
144 | || (ip + length > iend - (2 + 1 + LASTLITERALS)))) | 222 | || (ip + length > iend - (2 + 1 + LASTLITERALS)))) |
145 | || ((!endOnInput) && (cpy > oend - WILDCOPYLENGTH))) { | 223 | || ((!endOnInput) && (cpy > oend - WILDCOPYLENGTH))) { |
146 | if (partialDecoding) { | 224 | if (partialDecoding) { |
147 | if (cpy > oend) { | 225 | if (cpy > oend) { |
148 | /* | 226 | /* |
149 | * Error : | 227 | * Partial decoding : |
150 | * write attempt beyond end of output buffer | 228 | * stop in the middle of literal segment |
151 | */ | 229 | */ |
152 | goto _output_error; | 230 | cpy = oend; |
231 | length = oend - op; | ||
153 | } | 232 | } |
154 | if ((endOnInput) | 233 | if ((endOnInput) |
155 | && (ip + length > iend)) { | 234 | && (ip + length > iend)) { |
@@ -184,29 +263,43 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
184 | memcpy(op, ip, length); | 263 | memcpy(op, ip, length); |
185 | ip += length; | 264 | ip += length; |
186 | op += length; | 265 | op += length; |
266 | |||
187 | /* Necessarily EOF, due to parsing restrictions */ | 267 | /* Necessarily EOF, due to parsing restrictions */ |
188 | break; | 268 | if (!partialDecoding || (cpy == oend)) |
269 | break; | ||
270 | } else { | ||
271 | /* may overwrite up to WILDCOPYLENGTH beyond cpy */ | ||
272 | LZ4_wildCopy(op, ip, cpy); | ||
273 | ip += length; | ||
274 | op = cpy; | ||
189 | } | 275 | } |
190 | 276 | ||
191 | LZ4_wildCopy(op, ip, cpy); | ||
192 | ip += length; | ||
193 | op = cpy; | ||
194 | |||
195 | /* get offset */ | 277 | /* get offset */ |
196 | offset = LZ4_readLE16(ip); | 278 | offset = LZ4_readLE16(ip); |
197 | ip += 2; | 279 | ip += 2; |
198 | match = op - offset; | 280 | match = op - offset; |
199 | 281 | ||
200 | if ((checkOffset) && (unlikely(match < lowLimit))) { | 282 | /* get matchlength */ |
283 | length = token & ML_MASK; | ||
284 | |||
285 | _copy_match: | ||
286 | if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) { | ||
201 | /* Error : offset outside buffers */ | 287 | /* Error : offset outside buffers */ |
202 | goto _output_error; | 288 | goto _output_error; |
203 | } | 289 | } |
204 | 290 | ||
205 | /* costs ~1%; silence an msan warning when offset == 0 */ | 291 | /* costs ~1%; silence an msan warning when offset == 0 */ |
206 | LZ4_write32(op, (U32)offset); | 292 | /* |
293 | * note : when partialDecoding, there is no guarantee that | ||
294 | * at least 4 bytes remain available in output buffer | ||
295 | */ | ||
296 | if (!partialDecoding) { | ||
297 | assert(oend > op); | ||
298 | assert(oend - op >= 4); | ||
299 | |||
300 | LZ4_write32(op, (U32)offset); | ||
301 | } | ||
207 | 302 | ||
208 | /* get matchlength */ | ||
209 | length = token & ML_MASK; | ||
210 | if (length == ML_MASK) { | 303 | if (length == ML_MASK) { |
211 | unsigned int s; | 304 | unsigned int s; |
212 | 305 | ||
@@ -221,7 +314,7 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
221 | 314 | ||
222 | if ((safeDecode) | 315 | if ((safeDecode) |
223 | && unlikely( | 316 | && unlikely( |
224 | (size_t)(op + length) < (size_t)op)) { | 317 | (uptrval)(op) + length < (uptrval)op)) { |
225 | /* overflow detection */ | 318 | /* overflow detection */ |
226 | goto _output_error; | 319 | goto _output_error; |
227 | } | 320 | } |
@@ -229,24 +322,26 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
229 | 322 | ||
230 | length += MINMATCH; | 323 | length += MINMATCH; |
231 | 324 | ||
232 | /* check external dictionary */ | 325 | /* match starting within external dictionary */ |
233 | if ((dict == usingExtDict) && (match < lowPrefix)) { | 326 | if ((dict == usingExtDict) && (match < lowPrefix)) { |
234 | if (unlikely(op + length > oend - LASTLITERALS)) { | 327 | if (unlikely(op + length > oend - LASTLITERALS)) { |
235 | /* doesn't respect parsing restriction */ | 328 | /* doesn't respect parsing restriction */ |
236 | goto _output_error; | 329 | if (!partialDecoding) |
330 | goto _output_error; | ||
331 | length = min(length, (size_t)(oend - op)); | ||
237 | } | 332 | } |
238 | 333 | ||
239 | if (length <= (size_t)(lowPrefix - match)) { | 334 | if (length <= (size_t)(lowPrefix - match)) { |
240 | /* | 335 | /* |
241 | * match can be copied as a single segment | 336 | * match fits entirely within external |
242 | * from external dictionary | 337 | * dictionary : just copy |
243 | */ | 338 | */ |
244 | memmove(op, dictEnd - (lowPrefix - match), | 339 | memmove(op, dictEnd - (lowPrefix - match), |
245 | length); | 340 | length); |
246 | op += length; | 341 | op += length; |
247 | } else { | 342 | } else { |
248 | /* | 343 | /* |
249 | * match encompass external | 344 | * match stretches into both external |
250 | * dictionary and current block | 345 | * dictionary and current block |
251 | */ | 346 | */ |
252 | size_t const copySize = (size_t)(lowPrefix - match); | 347 | size_t const copySize = (size_t)(lowPrefix - match); |
@@ -254,7 +349,6 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
254 | 349 | ||
255 | memcpy(op, dictEnd - copySize, copySize); | 350 | memcpy(op, dictEnd - copySize, copySize); |
256 | op += copySize; | 351 | op += copySize; |
257 | |||
258 | if (restSize > (size_t)(op - lowPrefix)) { | 352 | if (restSize > (size_t)(op - lowPrefix)) { |
259 | /* overlap copy */ | 353 | /* overlap copy */ |
260 | BYTE * const endOfMatch = op + restSize; | 354 | BYTE * const endOfMatch = op + restSize; |
@@ -267,23 +361,44 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
267 | op += restSize; | 361 | op += restSize; |
268 | } | 362 | } |
269 | } | 363 | } |
270 | |||
271 | continue; | 364 | continue; |
272 | } | 365 | } |
273 | 366 | ||
274 | /* copy match within block */ | 367 | /* copy match within block */ |
275 | cpy = op + length; | 368 | cpy = op + length; |
276 | 369 | ||
277 | if (unlikely(offset < 8)) { | 370 | /* |
278 | const int dec64 = dec64table[offset]; | 371 | * partialDecoding : |
372 | * may not respect endBlock parsing restrictions | ||
373 | */ | ||
374 | assert(op <= oend); | ||
375 | if (partialDecoding && | ||
376 | (cpy > oend - MATCH_SAFEGUARD_DISTANCE)) { | ||
377 | size_t const mlen = min(length, (size_t)(oend - op)); | ||
378 | const BYTE * const matchEnd = match + mlen; | ||
379 | BYTE * const copyEnd = op + mlen; | ||
380 | |||
381 | if (matchEnd > op) { | ||
382 | /* overlap copy */ | ||
383 | while (op < copyEnd) | ||
384 | *op++ = *match++; | ||
385 | } else { | ||
386 | memcpy(op, match, mlen); | ||
387 | } | ||
388 | op = copyEnd; | ||
389 | if (op == oend) | ||
390 | break; | ||
391 | continue; | ||
392 | } | ||
279 | 393 | ||
394 | if (unlikely(offset < 8)) { | ||
280 | op[0] = match[0]; | 395 | op[0] = match[0]; |
281 | op[1] = match[1]; | 396 | op[1] = match[1]; |
282 | op[2] = match[2]; | 397 | op[2] = match[2]; |
283 | op[3] = match[3]; | 398 | op[3] = match[3]; |
284 | match += dec32table[offset]; | 399 | match += inc32table[offset]; |
285 | memcpy(op + 4, match, 4); | 400 | memcpy(op + 4, match, 4); |
286 | match -= dec64; | 401 | match -= dec64table[offset]; |
287 | } else { | 402 | } else { |
288 | LZ4_copy8(op, match); | 403 | LZ4_copy8(op, match); |
289 | match += 8; | 404 | match += 8; |
@@ -291,7 +406,7 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
291 | 406 | ||
292 | op += 8; | 407 | op += 8; |
293 | 408 | ||
294 | if (unlikely(cpy > oend - 12)) { | 409 | if (unlikely(cpy > oend - MATCH_SAFEGUARD_DISTANCE)) { |
295 | BYTE * const oCopyLimit = oend - (WILDCOPYLENGTH - 1); | 410 | BYTE * const oCopyLimit = oend - (WILDCOPYLENGTH - 1); |
296 | 411 | ||
297 | if (cpy > oend - LASTLITERALS) { | 412 | if (cpy > oend - LASTLITERALS) { |
@@ -307,60 +422,139 @@ static FORCE_INLINE int LZ4_decompress_generic( | |||
307 | match += oCopyLimit - op; | 422 | match += oCopyLimit - op; |
308 | op = oCopyLimit; | 423 | op = oCopyLimit; |
309 | } | 424 | } |
310 | |||
311 | while (op < cpy) | 425 | while (op < cpy) |
312 | *op++ = *match++; | 426 | *op++ = *match++; |
313 | } else { | 427 | } else { |
314 | LZ4_copy8(op, match); | 428 | LZ4_copy8(op, match); |
315 | |||
316 | if (length > 16) | 429 | if (length > 16) |
317 | LZ4_wildCopy(op + 8, match + 8, cpy); | 430 | LZ4_wildCopy(op + 8, match + 8, cpy); |
318 | } | 431 | } |
319 | 432 | op = cpy; /* wildcopy correction */ | |
320 | op = cpy; /* correction */ | ||
321 | } | 433 | } |
322 | 434 | ||
323 | /* end of decoding */ | 435 | /* end of decoding */ |
324 | if (endOnInput) { | 436 | if (endOnInput) { |
325 | /* Nb of output bytes decoded */ | 437 | /* Nb of output bytes decoded */ |
326 | return (int) (((char *)op) - dest); | 438 | return (int) (((char *)op) - dst); |
327 | } else { | 439 | } else { |
328 | /* Nb of input bytes read */ | 440 | /* Nb of input bytes read */ |
329 | return (int) (((const char *)ip) - source); | 441 | return (int) (((const char *)ip) - src); |
330 | } | 442 | } |
331 | 443 | ||
332 | /* Overflow error detected */ | 444 | /* Overflow error detected */ |
333 | _output_error: | 445 | _output_error: |
334 | return -1; | 446 | return (int) (-(((const char *)ip) - src)) - 1; |
335 | } | 447 | } |
336 | 448 | ||
337 | int LZ4_decompress_safe(const char *source, char *dest, | 449 | int LZ4_decompress_safe(const char *source, char *dest, |
338 | int compressedSize, int maxDecompressedSize) | 450 | int compressedSize, int maxDecompressedSize) |
339 | { | 451 | { |
340 | return LZ4_decompress_generic(source, dest, compressedSize, | 452 | return LZ4_decompress_generic(source, dest, |
341 | maxDecompressedSize, endOnInputSize, full, 0, | 453 | compressedSize, maxDecompressedSize, |
342 | noDict, (BYTE *)dest, NULL, 0); | 454 | endOnInputSize, decode_full_block, |
455 | noDict, (BYTE *)dest, NULL, 0); | ||
343 | } | 456 | } |
344 | 457 | ||
345 | int LZ4_decompress_safe_partial(const char *source, char *dest, | 458 | int LZ4_decompress_safe_partial(const char *src, char *dst, |
346 | int compressedSize, int targetOutputSize, int maxDecompressedSize) | 459 | int compressedSize, int targetOutputSize, int dstCapacity) |
347 | { | 460 | { |
348 | return LZ4_decompress_generic(source, dest, compressedSize, | 461 | dstCapacity = min(targetOutputSize, dstCapacity); |
349 | maxDecompressedSize, endOnInputSize, partial, | 462 | return LZ4_decompress_generic(src, dst, compressedSize, dstCapacity, |
350 | targetOutputSize, noDict, (BYTE *)dest, NULL, 0); | 463 | endOnInputSize, partial_decode, |
464 | noDict, (BYTE *)dst, NULL, 0); | ||
351 | } | 465 | } |
352 | 466 | ||
353 | int LZ4_decompress_fast(const char *source, char *dest, int originalSize) | 467 | int LZ4_decompress_fast(const char *source, char *dest, int originalSize) |
354 | { | 468 | { |
355 | return LZ4_decompress_generic(source, dest, 0, originalSize, | 469 | return LZ4_decompress_generic(source, dest, 0, originalSize, |
356 | endOnOutputSize, full, 0, withPrefix64k, | 470 | endOnOutputSize, decode_full_block, |
357 | (BYTE *)(dest - 64 * KB), NULL, 64 * KB); | 471 | withPrefix64k, |
472 | (BYTE *)dest - 64 * KB, NULL, 0); | ||
473 | } | ||
474 | |||
475 | /* ===== Instantiate a few more decoding cases, used more than once. ===== */ | ||
476 | |||
477 | int LZ4_decompress_safe_withPrefix64k(const char *source, char *dest, | ||
478 | int compressedSize, int maxOutputSize) | ||
479 | { | ||
480 | return LZ4_decompress_generic(source, dest, | ||
481 | compressedSize, maxOutputSize, | ||
482 | endOnInputSize, decode_full_block, | ||
483 | withPrefix64k, | ||
484 | (BYTE *)dest - 64 * KB, NULL, 0); | ||
485 | } | ||
486 | |||
487 | static int LZ4_decompress_safe_withSmallPrefix(const char *source, char *dest, | ||
488 | int compressedSize, | ||
489 | int maxOutputSize, | ||
490 | size_t prefixSize) | ||
491 | { | ||
492 | return LZ4_decompress_generic(source, dest, | ||
493 | compressedSize, maxOutputSize, | ||
494 | endOnInputSize, decode_full_block, | ||
495 | noDict, | ||
496 | (BYTE *)dest - prefixSize, NULL, 0); | ||
497 | } | ||
498 | |||
499 | int LZ4_decompress_safe_forceExtDict(const char *source, char *dest, | ||
500 | int compressedSize, int maxOutputSize, | ||
501 | const void *dictStart, size_t dictSize) | ||
502 | { | ||
503 | return LZ4_decompress_generic(source, dest, | ||
504 | compressedSize, maxOutputSize, | ||
505 | endOnInputSize, decode_full_block, | ||
506 | usingExtDict, (BYTE *)dest, | ||
507 | (const BYTE *)dictStart, dictSize); | ||
358 | } | 508 | } |
359 | 509 | ||
510 | static int LZ4_decompress_fast_extDict(const char *source, char *dest, | ||
511 | int originalSize, | ||
512 | const void *dictStart, size_t dictSize) | ||
513 | { | ||
514 | return LZ4_decompress_generic(source, dest, | ||
515 | 0, originalSize, | ||
516 | endOnOutputSize, decode_full_block, | ||
517 | usingExtDict, (BYTE *)dest, | ||
518 | (const BYTE *)dictStart, dictSize); | ||
519 | } | ||
520 | |||
521 | /* | ||
522 | * The "double dictionary" mode, for use with e.g. ring buffers: the first part | ||
523 | * of the dictionary is passed as prefix, and the second via dictStart + dictSize. | ||
524 | * These routines are used only once, in LZ4_decompress_*_continue(). | ||
525 | */ | ||
526 | static FORCE_INLINE | ||
527 | int LZ4_decompress_safe_doubleDict(const char *source, char *dest, | ||
528 | int compressedSize, int maxOutputSize, | ||
529 | size_t prefixSize, | ||
530 | const void *dictStart, size_t dictSize) | ||
531 | { | ||
532 | return LZ4_decompress_generic(source, dest, | ||
533 | compressedSize, maxOutputSize, | ||
534 | endOnInputSize, decode_full_block, | ||
535 | usingExtDict, (BYTE *)dest - prefixSize, | ||
536 | (const BYTE *)dictStart, dictSize); | ||
537 | } | ||
538 | |||
539 | static FORCE_INLINE | ||
540 | int LZ4_decompress_fast_doubleDict(const char *source, char *dest, | ||
541 | int originalSize, size_t prefixSize, | ||
542 | const void *dictStart, size_t dictSize) | ||
543 | { | ||
544 | return LZ4_decompress_generic(source, dest, | ||
545 | 0, originalSize, | ||
546 | endOnOutputSize, decode_full_block, | ||
547 | usingExtDict, (BYTE *)dest - prefixSize, | ||
548 | (const BYTE *)dictStart, dictSize); | ||
549 | } | ||
550 | |||
551 | /* ===== streaming decompression functions ===== */ | ||
552 | |||
360 | int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, | 553 | int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, |
361 | const char *dictionary, int dictSize) | 554 | const char *dictionary, int dictSize) |
362 | { | 555 | { |
363 | LZ4_streamDecode_t_internal *lz4sd = (LZ4_streamDecode_t_internal *) LZ4_streamDecode; | 556 | LZ4_streamDecode_t_internal *lz4sd = |
557 | &LZ4_streamDecode->internal_donotuse; | ||
364 | 558 | ||
365 | lz4sd->prefixSize = (size_t) dictSize; | 559 | lz4sd->prefixSize = (size_t) dictSize; |
366 | lz4sd->prefixEnd = (const BYTE *) dictionary + dictSize; | 560 | lz4sd->prefixEnd = (const BYTE *) dictionary + dictSize; |
@@ -382,35 +576,51 @@ int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, | |||
382 | int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, | 576 | int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, |
383 | const char *source, char *dest, int compressedSize, int maxOutputSize) | 577 | const char *source, char *dest, int compressedSize, int maxOutputSize) |
384 | { | 578 | { |
385 | LZ4_streamDecode_t_internal *lz4sd = &LZ4_streamDecode->internal_donotuse; | 579 | LZ4_streamDecode_t_internal *lz4sd = |
580 | &LZ4_streamDecode->internal_donotuse; | ||
386 | int result; | 581 | int result; |
387 | 582 | ||
388 | if (lz4sd->prefixEnd == (BYTE *)dest) { | 583 | if (lz4sd->prefixSize == 0) { |
389 | result = LZ4_decompress_generic(source, dest, | 584 | /* The first call, no dictionary yet. */ |
390 | compressedSize, | 585 | assert(lz4sd->extDictSize == 0); |
391 | maxOutputSize, | 586 | result = LZ4_decompress_safe(source, dest, |
392 | endOnInputSize, full, 0, | 587 | compressedSize, maxOutputSize); |
393 | usingExtDict, lz4sd->prefixEnd - lz4sd->prefixSize, | 588 | if (result <= 0) |
394 | lz4sd->externalDict, | 589 | return result; |
395 | lz4sd->extDictSize); | 590 | lz4sd->prefixSize = result; |
396 | 591 | lz4sd->prefixEnd = (BYTE *)dest + result; | |
592 | } else if (lz4sd->prefixEnd == (BYTE *)dest) { | ||
593 | /* They're rolling the current segment. */ | ||
594 | if (lz4sd->prefixSize >= 64 * KB - 1) | ||
595 | result = LZ4_decompress_safe_withPrefix64k(source, dest, | ||
596 | compressedSize, maxOutputSize); | ||
597 | else if (lz4sd->extDictSize == 0) | ||
598 | result = LZ4_decompress_safe_withSmallPrefix(source, | ||
599 | dest, compressedSize, maxOutputSize, | ||
600 | lz4sd->prefixSize); | ||
601 | else | ||
602 | result = LZ4_decompress_safe_doubleDict(source, dest, | ||
603 | compressedSize, maxOutputSize, | ||
604 | lz4sd->prefixSize, | ||
605 | lz4sd->externalDict, lz4sd->extDictSize); | ||
397 | if (result <= 0) | 606 | if (result <= 0) |
398 | return result; | 607 | return result; |
399 | |||
400 | lz4sd->prefixSize += result; | 608 | lz4sd->prefixSize += result; |
401 | lz4sd->prefixEnd += result; | 609 | lz4sd->prefixEnd += result; |
402 | } else { | 610 | } else { |
611 | /* | ||
612 | * The buffer wraps around, or they're | ||
613 | * switching to another buffer. | ||
614 | */ | ||
403 | lz4sd->extDictSize = lz4sd->prefixSize; | 615 | lz4sd->extDictSize = lz4sd->prefixSize; |
404 | lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; | 616 | lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; |
405 | result = LZ4_decompress_generic(source, dest, | 617 | result = LZ4_decompress_safe_forceExtDict(source, dest, |
406 | compressedSize, maxOutputSize, | 618 | compressedSize, maxOutputSize, |
407 | endOnInputSize, full, 0, | ||
408 | usingExtDict, (BYTE *)dest, | ||
409 | lz4sd->externalDict, lz4sd->extDictSize); | 619 | lz4sd->externalDict, lz4sd->extDictSize); |
410 | if (result <= 0) | 620 | if (result <= 0) |
411 | return result; | 621 | return result; |
412 | lz4sd->prefixSize = result; | 622 | lz4sd->prefixSize = result; |
413 | lz4sd->prefixEnd = (BYTE *)dest + result; | 623 | lz4sd->prefixEnd = (BYTE *)dest + result; |
414 | } | 624 | } |
415 | 625 | ||
416 | return result; | 626 | return result; |
@@ -422,75 +632,66 @@ int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, | |||
422 | LZ4_streamDecode_t_internal *lz4sd = &LZ4_streamDecode->internal_donotuse; | 632 | LZ4_streamDecode_t_internal *lz4sd = &LZ4_streamDecode->internal_donotuse; |
423 | int result; | 633 | int result; |
424 | 634 | ||
425 | if (lz4sd->prefixEnd == (BYTE *)dest) { | 635 | if (lz4sd->prefixSize == 0) { |
426 | result = LZ4_decompress_generic(source, dest, 0, originalSize, | 636 | assert(lz4sd->extDictSize == 0); |
427 | endOnOutputSize, full, 0, | 637 | result = LZ4_decompress_fast(source, dest, originalSize); |
428 | usingExtDict, | 638 | if (result <= 0) |
429 | lz4sd->prefixEnd - lz4sd->prefixSize, | 639 | return result; |
430 | lz4sd->externalDict, lz4sd->extDictSize); | 640 | lz4sd->prefixSize = originalSize; |
431 | 641 | lz4sd->prefixEnd = (BYTE *)dest + originalSize; | |
642 | } else if (lz4sd->prefixEnd == (BYTE *)dest) { | ||
643 | if (lz4sd->prefixSize >= 64 * KB - 1 || | ||
644 | lz4sd->extDictSize == 0) | ||
645 | result = LZ4_decompress_fast(source, dest, | ||
646 | originalSize); | ||
647 | else | ||
648 | result = LZ4_decompress_fast_doubleDict(source, dest, | ||
649 | originalSize, lz4sd->prefixSize, | ||
650 | lz4sd->externalDict, lz4sd->extDictSize); | ||
432 | if (result <= 0) | 651 | if (result <= 0) |
433 | return result; | 652 | return result; |
434 | |||
435 | lz4sd->prefixSize += originalSize; | 653 | lz4sd->prefixSize += originalSize; |
436 | lz4sd->prefixEnd += originalSize; | 654 | lz4sd->prefixEnd += originalSize; |
437 | } else { | 655 | } else { |
438 | lz4sd->extDictSize = lz4sd->prefixSize; | 656 | lz4sd->extDictSize = lz4sd->prefixSize; |
439 | lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; | 657 | lz4sd->externalDict = lz4sd->prefixEnd - lz4sd->extDictSize; |
440 | result = LZ4_decompress_generic(source, dest, 0, originalSize, | 658 | result = LZ4_decompress_fast_extDict(source, dest, |
441 | endOnOutputSize, full, 0, | 659 | originalSize, lz4sd->externalDict, lz4sd->extDictSize); |
442 | usingExtDict, (BYTE *)dest, | ||
443 | lz4sd->externalDict, lz4sd->extDictSize); | ||
444 | if (result <= 0) | 660 | if (result <= 0) |
445 | return result; | 661 | return result; |
446 | lz4sd->prefixSize = originalSize; | 662 | lz4sd->prefixSize = originalSize; |
447 | lz4sd->prefixEnd = (BYTE *)dest + originalSize; | 663 | lz4sd->prefixEnd = (BYTE *)dest + originalSize; |
448 | } | 664 | } |
449 | |||
450 | return result; | 665 | return result; |
451 | } | 666 | } |
452 | 667 | ||
453 | /* | 668 | int LZ4_decompress_safe_usingDict(const char *source, char *dest, |
454 | * Advanced decoding functions : | 669 | int compressedSize, int maxOutputSize, |
455 | * *_usingDict() : | 670 | const char *dictStart, int dictSize) |
456 | * These decoding functions work the same as "_continue" ones, | ||
457 | * the dictionary must be explicitly provided within parameters | ||
458 | */ | ||
459 | static FORCE_INLINE int LZ4_decompress_usingDict_generic(const char *source, | ||
460 | char *dest, int compressedSize, int maxOutputSize, int safe, | ||
461 | const char *dictStart, int dictSize) | ||
462 | { | 671 | { |
463 | if (dictSize == 0) | 672 | if (dictSize == 0) |
464 | return LZ4_decompress_generic(source, dest, | 673 | return LZ4_decompress_safe(source, dest, |
465 | compressedSize, maxOutputSize, safe, full, 0, | 674 | compressedSize, maxOutputSize); |
466 | noDict, (BYTE *)dest, NULL, 0); | 675 | if (dictStart+dictSize == dest) { |
467 | if (dictStart + dictSize == dest) { | 676 | if (dictSize >= 64 * KB - 1) |
468 | if (dictSize >= (int)(64 * KB - 1)) | 677 | return LZ4_decompress_safe_withPrefix64k(source, dest, |
469 | return LZ4_decompress_generic(source, dest, | 678 | compressedSize, maxOutputSize); |
470 | compressedSize, maxOutputSize, safe, full, 0, | 679 | return LZ4_decompress_safe_withSmallPrefix(source, dest, |
471 | withPrefix64k, (BYTE *)dest - 64 * KB, NULL, 0); | 680 | compressedSize, maxOutputSize, dictSize); |
472 | return LZ4_decompress_generic(source, dest, compressedSize, | ||
473 | maxOutputSize, safe, full, 0, noDict, | ||
474 | (BYTE *)dest - dictSize, NULL, 0); | ||
475 | } | 681 | } |
476 | return LZ4_decompress_generic(source, dest, compressedSize, | 682 | return LZ4_decompress_safe_forceExtDict(source, dest, |
477 | maxOutputSize, safe, full, 0, usingExtDict, | 683 | compressedSize, maxOutputSize, dictStart, dictSize); |
478 | (BYTE *)dest, (const BYTE *)dictStart, dictSize); | ||
479 | } | ||
480 | |||
481 | int LZ4_decompress_safe_usingDict(const char *source, char *dest, | ||
482 | int compressedSize, int maxOutputSize, | ||
483 | const char *dictStart, int dictSize) | ||
484 | { | ||
485 | return LZ4_decompress_usingDict_generic(source, dest, | ||
486 | compressedSize, maxOutputSize, 1, dictStart, dictSize); | ||
487 | } | 684 | } |
488 | 685 | ||
489 | int LZ4_decompress_fast_usingDict(const char *source, char *dest, | 686 | int LZ4_decompress_fast_usingDict(const char *source, char *dest, |
490 | int originalSize, const char *dictStart, int dictSize) | 687 | int originalSize, |
688 | const char *dictStart, int dictSize) | ||
491 | { | 689 | { |
492 | return LZ4_decompress_usingDict_generic(source, dest, 0, | 690 | if (dictSize == 0 || dictStart + dictSize == dest) |
493 | originalSize, 0, dictStart, dictSize); | 691 | return LZ4_decompress_fast(source, dest, originalSize); |
692 | |||
693 | return LZ4_decompress_fast_extDict(source, dest, originalSize, | ||
694 | dictStart, dictSize); | ||
494 | } | 695 | } |
495 | 696 | ||
496 | #ifndef STATIC | 697 | #ifndef STATIC |
diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h index 00a0b58a0871..1a7fa9d9170f 100644 --- a/lib/lz4/lz4defs.h +++ b/lib/lz4/lz4defs.h | |||
@@ -75,6 +75,11 @@ typedef uintptr_t uptrval; | |||
75 | #define WILDCOPYLENGTH 8 | 75 | #define WILDCOPYLENGTH 8 |
76 | #define LASTLITERALS 5 | 76 | #define LASTLITERALS 5 |
77 | #define MFLIMIT (WILDCOPYLENGTH + MINMATCH) | 77 | #define MFLIMIT (WILDCOPYLENGTH + MINMATCH) |
78 | /* | ||
79 | * ensure it's possible to write 2 x wildcopyLength | ||
80 | * without overflowing output buffer | ||
81 | */ | ||
82 | #define MATCH_SAFEGUARD_DISTANCE ((2 * WILDCOPYLENGTH) - MINMATCH) | ||
78 | 83 | ||
79 | /* Increase this value ==> compression run slower on incompressible data */ | 84 | /* Increase this value ==> compression run slower on incompressible data */ |
80 | #define LZ4_SKIPTRIGGER 6 | 85 | #define LZ4_SKIPTRIGGER 6 |
@@ -222,6 +227,8 @@ typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive; | |||
222 | typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive; | 227 | typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive; |
223 | 228 | ||
224 | typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive; | 229 | typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive; |
225 | typedef enum { full = 0, partial = 1 } earlyEnd_directive; | 230 | typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive; |
231 | |||
232 | #define LZ4_STATIC_ASSERT(c) BUILD_BUG_ON(!(c)) | ||
226 | 233 | ||
227 | #endif | 234 | #endif |
diff --git a/lib/parser.c b/lib/parser.c index 3278958b472a..dd70e5e6c9e2 100644 --- a/lib/parser.c +++ b/lib/parser.c | |||
@@ -131,13 +131,10 @@ static int match_number(substring_t *s, int *result, int base) | |||
131 | char *buf; | 131 | char *buf; |
132 | int ret; | 132 | int ret; |
133 | long val; | 133 | long val; |
134 | size_t len = s->to - s->from; | ||
135 | 134 | ||
136 | buf = kmalloc(len + 1, GFP_KERNEL); | 135 | buf = match_strdup(s); |
137 | if (!buf) | 136 | if (!buf) |
138 | return -ENOMEM; | 137 | return -ENOMEM; |
139 | memcpy(buf, s->from, len); | ||
140 | buf[len] = '\0'; | ||
141 | 138 | ||
142 | ret = 0; | 139 | ret = 0; |
143 | val = simple_strtol(buf, &endp, base); | 140 | val = simple_strtol(buf, &endp, base); |
@@ -166,13 +163,10 @@ static int match_u64int(substring_t *s, u64 *result, int base) | |||
166 | char *buf; | 163 | char *buf; |
167 | int ret; | 164 | int ret; |
168 | u64 val; | 165 | u64 val; |
169 | size_t len = s->to - s->from; | ||
170 | 166 | ||
171 | buf = kmalloc(len + 1, GFP_KERNEL); | 167 | buf = match_strdup(s); |
172 | if (!buf) | 168 | if (!buf) |
173 | return -ENOMEM; | 169 | return -ENOMEM; |
174 | memcpy(buf, s->from, len); | ||
175 | buf[len] = '\0'; | ||
176 | 170 | ||
177 | ret = kstrtoull(buf, base, &val); | 171 | ret = kstrtoull(buf, base, &val); |
178 | if (!ret) | 172 | if (!ret) |
@@ -327,10 +321,6 @@ EXPORT_SYMBOL(match_strlcpy); | |||
327 | */ | 321 | */ |
328 | char *match_strdup(const substring_t *s) | 322 | char *match_strdup(const substring_t *s) |
329 | { | 323 | { |
330 | size_t sz = s->to - s->from + 1; | 324 | return kmemdup_nul(s->from, s->to - s->from, GFP_KERNEL); |
331 | char *p = kmalloc(sz, GFP_KERNEL); | ||
332 | if (p) | ||
333 | match_strlcpy(p, s, sz); | ||
334 | return p; | ||
335 | } | 325 | } |
336 | EXPORT_SYMBOL(match_strdup); | 326 | EXPORT_SYMBOL(match_strdup); |
diff --git a/lib/sg_pool.c b/lib/sg_pool.c index 6dd30615a201..d1c1e6388eaa 100644 --- a/lib/sg_pool.c +++ b/lib/sg_pool.c | |||
@@ -148,10 +148,9 @@ static __init int sg_pool_init(void) | |||
148 | cleanup_sdb: | 148 | cleanup_sdb: |
149 | for (i = 0; i < SG_MEMPOOL_NR; i++) { | 149 | for (i = 0; i < SG_MEMPOOL_NR; i++) { |
150 | struct sg_pool *sgp = sg_pools + i; | 150 | struct sg_pool *sgp = sg_pools + i; |
151 | if (sgp->pool) | 151 | |
152 | mempool_destroy(sgp->pool); | 152 | mempool_destroy(sgp->pool); |
153 | if (sgp->slab) | 153 | kmem_cache_destroy(sgp->slab); |
154 | kmem_cache_destroy(sgp->slab); | ||
155 | } | 154 | } |
156 | 155 | ||
157 | return -ENOMEM; | 156 | return -ENOMEM; |
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c index 58a733b10387..48f14cd58c77 100644 --- a/lib/zlib_inflate/inflate.c +++ b/lib/zlib_inflate/inflate.c | |||
@@ -382,6 +382,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
382 | strm->adler = state->check = REVERSE(hold); | 382 | strm->adler = state->check = REVERSE(hold); |
383 | INITBITS(); | 383 | INITBITS(); |
384 | state->mode = DICT; | 384 | state->mode = DICT; |
385 | /* fall through */ | ||
385 | case DICT: | 386 | case DICT: |
386 | if (state->havedict == 0) { | 387 | if (state->havedict == 0) { |
387 | RESTORE(); | 388 | RESTORE(); |
@@ -389,8 +390,10 @@ int zlib_inflate(z_streamp strm, int flush) | |||
389 | } | 390 | } |
390 | strm->adler = state->check = zlib_adler32(0L, NULL, 0); | 391 | strm->adler = state->check = zlib_adler32(0L, NULL, 0); |
391 | state->mode = TYPE; | 392 | state->mode = TYPE; |
393 | /* fall through */ | ||
392 | case TYPE: | 394 | case TYPE: |
393 | if (flush == Z_BLOCK) goto inf_leave; | 395 | if (flush == Z_BLOCK) goto inf_leave; |
396 | /* fall through */ | ||
394 | case TYPEDO: | 397 | case TYPEDO: |
395 | if (state->last) { | 398 | if (state->last) { |
396 | BYTEBITS(); | 399 | BYTEBITS(); |
@@ -428,6 +431,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
428 | state->length = (unsigned)hold & 0xffff; | 431 | state->length = (unsigned)hold & 0xffff; |
429 | INITBITS(); | 432 | INITBITS(); |
430 | state->mode = COPY; | 433 | state->mode = COPY; |
434 | /* fall through */ | ||
431 | case COPY: | 435 | case COPY: |
432 | copy = state->length; | 436 | copy = state->length; |
433 | if (copy) { | 437 | if (copy) { |
@@ -461,6 +465,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
461 | #endif | 465 | #endif |
462 | state->have = 0; | 466 | state->have = 0; |
463 | state->mode = LENLENS; | 467 | state->mode = LENLENS; |
468 | /* fall through */ | ||
464 | case LENLENS: | 469 | case LENLENS: |
465 | while (state->have < state->ncode) { | 470 | while (state->have < state->ncode) { |
466 | NEEDBITS(3); | 471 | NEEDBITS(3); |
@@ -481,6 +486,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
481 | } | 486 | } |
482 | state->have = 0; | 487 | state->have = 0; |
483 | state->mode = CODELENS; | 488 | state->mode = CODELENS; |
489 | /* fall through */ | ||
484 | case CODELENS: | 490 | case CODELENS: |
485 | while (state->have < state->nlen + state->ndist) { | 491 | while (state->have < state->nlen + state->ndist) { |
486 | for (;;) { | 492 | for (;;) { |
@@ -554,6 +560,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
554 | break; | 560 | break; |
555 | } | 561 | } |
556 | state->mode = LEN; | 562 | state->mode = LEN; |
563 | /* fall through */ | ||
557 | case LEN: | 564 | case LEN: |
558 | if (have >= 6 && left >= 258) { | 565 | if (have >= 6 && left >= 258) { |
559 | RESTORE(); | 566 | RESTORE(); |
@@ -593,6 +600,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
593 | } | 600 | } |
594 | state->extra = (unsigned)(this.op) & 15; | 601 | state->extra = (unsigned)(this.op) & 15; |
595 | state->mode = LENEXT; | 602 | state->mode = LENEXT; |
603 | /* fall through */ | ||
596 | case LENEXT: | 604 | case LENEXT: |
597 | if (state->extra) { | 605 | if (state->extra) { |
598 | NEEDBITS(state->extra); | 606 | NEEDBITS(state->extra); |
@@ -600,6 +608,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
600 | DROPBITS(state->extra); | 608 | DROPBITS(state->extra); |
601 | } | 609 | } |
602 | state->mode = DIST; | 610 | state->mode = DIST; |
611 | /* fall through */ | ||
603 | case DIST: | 612 | case DIST: |
604 | for (;;) { | 613 | for (;;) { |
605 | this = state->distcode[BITS(state->distbits)]; | 614 | this = state->distcode[BITS(state->distbits)]; |
@@ -625,6 +634,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
625 | state->offset = (unsigned)this.val; | 634 | state->offset = (unsigned)this.val; |
626 | state->extra = (unsigned)(this.op) & 15; | 635 | state->extra = (unsigned)(this.op) & 15; |
627 | state->mode = DISTEXT; | 636 | state->mode = DISTEXT; |
637 | /* fall through */ | ||
628 | case DISTEXT: | 638 | case DISTEXT: |
629 | if (state->extra) { | 639 | if (state->extra) { |
630 | NEEDBITS(state->extra); | 640 | NEEDBITS(state->extra); |
@@ -644,6 +654,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
644 | break; | 654 | break; |
645 | } | 655 | } |
646 | state->mode = MATCH; | 656 | state->mode = MATCH; |
657 | /* fall through */ | ||
647 | case MATCH: | 658 | case MATCH: |
648 | if (left == 0) goto inf_leave; | 659 | if (left == 0) goto inf_leave; |
649 | copy = out - left; | 660 | copy = out - left; |
@@ -694,6 +705,7 @@ int zlib_inflate(z_streamp strm, int flush) | |||
694 | INITBITS(); | 705 | INITBITS(); |
695 | } | 706 | } |
696 | state->mode = DONE; | 707 | state->mode = DONE; |
708 | /* fall through */ | ||
697 | case DONE: | 709 | case DONE: |
698 | ret = Z_STREAM_END; | 710 | ret = Z_STREAM_END; |
699 | goto inf_leave; | 711 | goto inf_leave; |
diff --git a/mm/Kconfig b/mm/Kconfig index 02301a89089e..d85e39da47ae 100644 --- a/mm/Kconfig +++ b/mm/Kconfig | |||
@@ -127,9 +127,6 @@ config SPARSEMEM_VMEMMAP | |||
127 | pfn_to_page and page_to_pfn operations. This is the most | 127 | pfn_to_page and page_to_pfn operations. This is the most |
128 | efficient option when sufficient kernel resources are available. | 128 | efficient option when sufficient kernel resources are available. |
129 | 129 | ||
130 | config HAVE_MEMBLOCK | ||
131 | bool | ||
132 | |||
133 | config HAVE_MEMBLOCK_NODE_MAP | 130 | config HAVE_MEMBLOCK_NODE_MAP |
134 | bool | 131 | bool |
135 | 132 | ||
@@ -142,9 +139,6 @@ config HAVE_GENERIC_GUP | |||
142 | config ARCH_DISCARD_MEMBLOCK | 139 | config ARCH_DISCARD_MEMBLOCK |
143 | bool | 140 | bool |
144 | 141 | ||
145 | config NO_BOOTMEM | ||
146 | bool | ||
147 | |||
148 | config MEMORY_ISOLATION | 142 | config MEMORY_ISOLATION |
149 | bool | 143 | bool |
150 | 144 | ||
@@ -481,7 +475,7 @@ config FRONTSWAP | |||
481 | 475 | ||
482 | config CMA | 476 | config CMA |
483 | bool "Contiguous Memory Allocator" | 477 | bool "Contiguous Memory Allocator" |
484 | depends on HAVE_MEMBLOCK && MMU | 478 | depends on MMU |
485 | select MIGRATION | 479 | select MIGRATION |
486 | select MEMORY_ISOLATION | 480 | select MEMORY_ISOLATION |
487 | help | 481 | help |
@@ -634,7 +628,6 @@ config MAX_STACK_SIZE_MB | |||
634 | config DEFERRED_STRUCT_PAGE_INIT | 628 | config DEFERRED_STRUCT_PAGE_INIT |
635 | bool "Defer initialisation of struct pages to kthreads" | 629 | bool "Defer initialisation of struct pages to kthreads" |
636 | default n | 630 | default n |
637 | depends on NO_BOOTMEM | ||
638 | depends on SPARSEMEM | 631 | depends on SPARSEMEM |
639 | depends on !NEED_PER_CPU_KM | 632 | depends on !NEED_PER_CPU_KM |
640 | depends on 64BIT | 633 | depends on 64BIT |
diff --git a/mm/Makefile b/mm/Makefile index 6485d5745dd7..d210cc9d6f80 100644 --- a/mm/Makefile +++ b/mm/Makefile | |||
@@ -42,17 +42,11 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ | |||
42 | debug.o $(mmu-y) | 42 | debug.o $(mmu-y) |
43 | 43 | ||
44 | obj-y += init-mm.o | 44 | obj-y += init-mm.o |
45 | 45 | obj-y += memblock.o | |
46 | ifdef CONFIG_NO_BOOTMEM | ||
47 | obj-y += nobootmem.o | ||
48 | else | ||
49 | obj-y += bootmem.o | ||
50 | endif | ||
51 | 46 | ||
52 | ifdef CONFIG_MMU | 47 | ifdef CONFIG_MMU |
53 | obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o | 48 | obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o |
54 | endif | 49 | endif |
55 | obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o | ||
56 | 50 | ||
57 | obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o swap_slots.o | 51 | obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o swap_slots.o |
58 | obj-$(CONFIG_FRONTSWAP) += frontswap.o | 52 | obj-$(CONFIG_FRONTSWAP) += frontswap.o |
diff --git a/mm/bootmem.c b/mm/bootmem.c deleted file mode 100644 index 97db0e8e362b..000000000000 --- a/mm/bootmem.c +++ /dev/null | |||
@@ -1,811 +0,0 @@ | |||
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/bug.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/bootmem.h> | ||
21 | |||
22 | #include "internal.h" | ||
23 | |||
24 | /** | ||
25 | * DOC: bootmem overview | ||
26 | * | ||
27 | * Bootmem is a boot-time physical memory allocator and configurator. | ||
28 | * | ||
29 | * It is used early in the boot process before the page allocator is | ||
30 | * set up. | ||
31 | * | ||
32 | * Bootmem is based on the most basic of allocators, a First Fit | ||
33 | * allocator which uses a bitmap to represent memory. If a bit is 1, | ||
34 | * the page is allocated and 0 if unallocated. To satisfy allocations | ||
35 | * of sizes smaller than a page, the allocator records the Page Frame | ||
36 | * Number (PFN) of the last allocation and the offset the allocation | ||
37 | * ended at. Subsequent small allocations are merged together and | ||
38 | * stored on the same page. | ||
39 | * | ||
40 | * The information used by the bootmem allocator is represented by | ||
41 | * :c:type:`struct bootmem_data`. An array to hold up to %MAX_NUMNODES | ||
42 | * such structures is statically allocated and then it is discarded | ||
43 | * when the system initialization completes. Each entry in this array | ||
44 | * corresponds to a node with memory. For UMA systems only entry 0 is | ||
45 | * used. | ||
46 | * | ||
47 | * The bootmem allocator is initialized during early architecture | ||
48 | * specific setup. Each architecture is required to supply a | ||
49 | * :c:func:`setup_arch` function which, among other tasks, is | ||
50 | * responsible for acquiring the necessary parameters to initialise | ||
51 | * the boot memory allocator. These parameters define limits of usable | ||
52 | * physical memory: | ||
53 | * | ||
54 | * * @min_low_pfn - the lowest PFN that is available in the system | ||
55 | * * @max_low_pfn - the highest PFN that may be addressed by low | ||
56 | * memory (%ZONE_NORMAL) | ||
57 | * * @max_pfn - the last PFN available to the system. | ||
58 | * | ||
59 | * After those limits are determined, the :c:func:`init_bootmem` or | ||
60 | * :c:func:`init_bootmem_node` function should be called to initialize | ||
61 | * the bootmem allocator. The UMA case should use the `init_bootmem` | ||
62 | * function. It will initialize ``contig_page_data`` structure that | ||
63 | * represents the only memory node in the system. In the NUMA case the | ||
64 | * `init_bootmem_node` function should be called to initialize the | ||
65 | * bootmem allocator for each node. | ||
66 | * | ||
67 | * Once the allocator is set up, it is possible to use either single | ||
68 | * node or NUMA variant of the allocation APIs. | ||
69 | */ | ||
70 | |||
71 | #ifndef CONFIG_NEED_MULTIPLE_NODES | ||
72 | struct pglist_data __refdata contig_page_data = { | ||
73 | .bdata = &bootmem_node_data[0] | ||
74 | }; | ||
75 | EXPORT_SYMBOL(contig_page_data); | ||
76 | #endif | ||
77 | |||
78 | unsigned long max_low_pfn; | ||
79 | unsigned long min_low_pfn; | ||
80 | unsigned long max_pfn; | ||
81 | unsigned long long max_possible_pfn; | ||
82 | |||
83 | bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata; | ||
84 | |||
85 | static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list); | ||
86 | |||
87 | static int bootmem_debug; | ||
88 | |||
89 | static int __init bootmem_debug_setup(char *buf) | ||
90 | { | ||
91 | bootmem_debug = 1; | ||
92 | return 0; | ||
93 | } | ||
94 | early_param("bootmem_debug", bootmem_debug_setup); | ||
95 | |||
96 | #define bdebug(fmt, args...) ({ \ | ||
97 | if (unlikely(bootmem_debug)) \ | ||
98 | pr_info("bootmem::%s " fmt, \ | ||
99 | __func__, ## args); \ | ||
100 | }) | ||
101 | |||
102 | static unsigned long __init bootmap_bytes(unsigned long pages) | ||
103 | { | ||
104 | unsigned long bytes = DIV_ROUND_UP(pages, BITS_PER_BYTE); | ||
105 | |||
106 | return ALIGN(bytes, sizeof(long)); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * bootmem_bootmap_pages - calculate bitmap size in pages | ||
111 | * @pages: number of pages the bitmap has to represent | ||
112 | * | ||
113 | * Return: the number of pages needed to hold the bitmap. | ||
114 | */ | ||
115 | unsigned long __init bootmem_bootmap_pages(unsigned long pages) | ||
116 | { | ||
117 | unsigned long bytes = bootmap_bytes(pages); | ||
118 | |||
119 | return PAGE_ALIGN(bytes) >> PAGE_SHIFT; | ||
120 | } | ||
121 | |||
122 | /* | ||
123 | * link bdata in order | ||
124 | */ | ||
125 | static void __init link_bootmem(bootmem_data_t *bdata) | ||
126 | { | ||
127 | bootmem_data_t *ent; | ||
128 | |||
129 | list_for_each_entry(ent, &bdata_list, list) { | ||
130 | if (bdata->node_min_pfn < ent->node_min_pfn) { | ||
131 | list_add_tail(&bdata->list, &ent->list); | ||
132 | return; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | list_add_tail(&bdata->list, &bdata_list); | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * Called once to set up the allocator itself. | ||
141 | */ | ||
142 | static unsigned long __init init_bootmem_core(bootmem_data_t *bdata, | ||
143 | unsigned long mapstart, unsigned long start, unsigned long end) | ||
144 | { | ||
145 | unsigned long mapsize; | ||
146 | |||
147 | mminit_validate_memmodel_limits(&start, &end); | ||
148 | bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart)); | ||
149 | bdata->node_min_pfn = start; | ||
150 | bdata->node_low_pfn = end; | ||
151 | link_bootmem(bdata); | ||
152 | |||
153 | /* | ||
154 | * Initially all pages are reserved - setup_arch() has to | ||
155 | * register free RAM areas explicitly. | ||
156 | */ | ||
157 | mapsize = bootmap_bytes(end - start); | ||
158 | memset(bdata->node_bootmem_map, 0xff, mapsize); | ||
159 | |||
160 | bdebug("nid=%td start=%lx map=%lx end=%lx mapsize=%lx\n", | ||
161 | bdata - bootmem_node_data, start, mapstart, end, mapsize); | ||
162 | |||
163 | return mapsize; | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * init_bootmem_node - register a node as boot memory | ||
168 | * @pgdat: node to register | ||
169 | * @freepfn: pfn where the bitmap for this node is to be placed | ||
170 | * @startpfn: first pfn on the node | ||
171 | * @endpfn: first pfn after the node | ||
172 | * | ||
173 | * Return: the number of bytes needed to hold the bitmap for this node. | ||
174 | */ | ||
175 | unsigned long __init init_bootmem_node(pg_data_t *pgdat, unsigned long freepfn, | ||
176 | unsigned long startpfn, unsigned long endpfn) | ||
177 | { | ||
178 | return init_bootmem_core(pgdat->bdata, freepfn, startpfn, endpfn); | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * init_bootmem - register boot memory | ||
183 | * @start: pfn where the bitmap is to be placed | ||
184 | * @pages: number of available physical pages | ||
185 | * | ||
186 | * Return: the number of bytes needed to hold the bitmap. | ||
187 | */ | ||
188 | unsigned long __init init_bootmem(unsigned long start, unsigned long pages) | ||
189 | { | ||
190 | max_low_pfn = pages; | ||
191 | min_low_pfn = start; | ||
192 | return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages); | ||
193 | } | ||
194 | |||
195 | void __init free_bootmem_late(unsigned long physaddr, unsigned long size) | ||
196 | { | ||
197 | unsigned long cursor, end; | ||
198 | |||
199 | kmemleak_free_part_phys(physaddr, size); | ||
200 | |||
201 | cursor = PFN_UP(physaddr); | ||
202 | end = PFN_DOWN(physaddr + size); | ||
203 | |||
204 | for (; cursor < end; cursor++) { | ||
205 | __free_pages_bootmem(pfn_to_page(cursor), cursor, 0); | ||
206 | totalram_pages++; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) | ||
211 | { | ||
212 | struct page *page; | ||
213 | unsigned long *map, start, end, pages, cur, count = 0; | ||
214 | |||
215 | if (!bdata->node_bootmem_map) | ||
216 | return 0; | ||
217 | |||
218 | map = bdata->node_bootmem_map; | ||
219 | start = bdata->node_min_pfn; | ||
220 | end = bdata->node_low_pfn; | ||
221 | |||
222 | bdebug("nid=%td start=%lx end=%lx\n", | ||
223 | bdata - bootmem_node_data, start, end); | ||
224 | |||
225 | while (start < end) { | ||
226 | unsigned long idx, vec; | ||
227 | unsigned shift; | ||
228 | |||
229 | idx = start - bdata->node_min_pfn; | ||
230 | shift = idx & (BITS_PER_LONG - 1); | ||
231 | /* | ||
232 | * vec holds at most BITS_PER_LONG map bits, | ||
233 | * bit 0 corresponds to start. | ||
234 | */ | ||
235 | vec = ~map[idx / BITS_PER_LONG]; | ||
236 | |||
237 | if (shift) { | ||
238 | vec >>= shift; | ||
239 | if (end - start >= BITS_PER_LONG) | ||
240 | vec |= ~map[idx / BITS_PER_LONG + 1] << | ||
241 | (BITS_PER_LONG - shift); | ||
242 | } | ||
243 | /* | ||
244 | * If we have a properly aligned and fully unreserved | ||
245 | * BITS_PER_LONG block of pages in front of us, free | ||
246 | * it in one go. | ||
247 | */ | ||
248 | if (IS_ALIGNED(start, BITS_PER_LONG) && vec == ~0UL) { | ||
249 | int order = ilog2(BITS_PER_LONG); | ||
250 | |||
251 | __free_pages_bootmem(pfn_to_page(start), start, order); | ||
252 | count += BITS_PER_LONG; | ||
253 | start += BITS_PER_LONG; | ||
254 | } else { | ||
255 | cur = start; | ||
256 | |||
257 | start = ALIGN(start + 1, BITS_PER_LONG); | ||
258 | while (vec && cur != start) { | ||
259 | if (vec & 1) { | ||
260 | page = pfn_to_page(cur); | ||
261 | __free_pages_bootmem(page, cur, 0); | ||
262 | count++; | ||
263 | } | ||
264 | vec >>= 1; | ||
265 | ++cur; | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | |||
270 | cur = bdata->node_min_pfn; | ||
271 | page = virt_to_page(bdata->node_bootmem_map); | ||
272 | pages = bdata->node_low_pfn - bdata->node_min_pfn; | ||
273 | pages = bootmem_bootmap_pages(pages); | ||
274 | count += pages; | ||
275 | while (pages--) | ||
276 | __free_pages_bootmem(page++, cur++, 0); | ||
277 | bdata->node_bootmem_map = NULL; | ||
278 | |||
279 | bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count); | ||
280 | |||
281 | return count; | ||
282 | } | ||
283 | |||
284 | static int reset_managed_pages_done __initdata; | ||
285 | |||
286 | void reset_node_managed_pages(pg_data_t *pgdat) | ||
287 | { | ||
288 | struct zone *z; | ||
289 | |||
290 | for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) | ||
291 | z->managed_pages = 0; | ||
292 | } | ||
293 | |||
294 | void __init reset_all_zones_managed_pages(void) | ||
295 | { | ||
296 | struct pglist_data *pgdat; | ||
297 | |||
298 | if (reset_managed_pages_done) | ||
299 | return; | ||
300 | |||
301 | for_each_online_pgdat(pgdat) | ||
302 | reset_node_managed_pages(pgdat); | ||
303 | |||
304 | reset_managed_pages_done = 1; | ||
305 | } | ||
306 | |||
307 | unsigned long __init free_all_bootmem(void) | ||
308 | { | ||
309 | unsigned long total_pages = 0; | ||
310 | bootmem_data_t *bdata; | ||
311 | |||
312 | reset_all_zones_managed_pages(); | ||
313 | |||
314 | list_for_each_entry(bdata, &bdata_list, list) | ||
315 | total_pages += free_all_bootmem_core(bdata); | ||
316 | |||
317 | totalram_pages += total_pages; | ||
318 | |||
319 | return total_pages; | ||
320 | } | ||
321 | |||
322 | static void __init __free(bootmem_data_t *bdata, | ||
323 | unsigned long sidx, unsigned long eidx) | ||
324 | { | ||
325 | unsigned long idx; | ||
326 | |||
327 | bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data, | ||
328 | sidx + bdata->node_min_pfn, | ||
329 | eidx + bdata->node_min_pfn); | ||
330 | |||
331 | if (WARN_ON(bdata->node_bootmem_map == NULL)) | ||
332 | return; | ||
333 | |||
334 | if (bdata->hint_idx > sidx) | ||
335 | bdata->hint_idx = sidx; | ||
336 | |||
337 | for (idx = sidx; idx < eidx; idx++) | ||
338 | if (!test_and_clear_bit(idx, bdata->node_bootmem_map)) | ||
339 | BUG(); | ||
340 | } | ||
341 | |||
342 | static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx, | ||
343 | unsigned long eidx, int flags) | ||
344 | { | ||
345 | unsigned long idx; | ||
346 | int exclusive = flags & BOOTMEM_EXCLUSIVE; | ||
347 | |||
348 | bdebug("nid=%td start=%lx end=%lx flags=%x\n", | ||
349 | bdata - bootmem_node_data, | ||
350 | sidx + bdata->node_min_pfn, | ||
351 | eidx + bdata->node_min_pfn, | ||
352 | flags); | ||
353 | |||
354 | if (WARN_ON(bdata->node_bootmem_map == NULL)) | ||
355 | return 0; | ||
356 | |||
357 | for (idx = sidx; idx < eidx; idx++) | ||
358 | if (test_and_set_bit(idx, bdata->node_bootmem_map)) { | ||
359 | if (exclusive) { | ||
360 | __free(bdata, sidx, idx); | ||
361 | return -EBUSY; | ||
362 | } | ||
363 | bdebug("silent double reserve of PFN %lx\n", | ||
364 | idx + bdata->node_min_pfn); | ||
365 | } | ||
366 | return 0; | ||
367 | } | ||
368 | |||
369 | static int __init mark_bootmem_node(bootmem_data_t *bdata, | ||
370 | unsigned long start, unsigned long end, | ||
371 | int reserve, int flags) | ||
372 | { | ||
373 | unsigned long sidx, eidx; | ||
374 | |||
375 | bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n", | ||
376 | bdata - bootmem_node_data, start, end, reserve, flags); | ||
377 | |||
378 | BUG_ON(start < bdata->node_min_pfn); | ||
379 | BUG_ON(end > bdata->node_low_pfn); | ||
380 | |||
381 | sidx = start - bdata->node_min_pfn; | ||
382 | eidx = end - bdata->node_min_pfn; | ||
383 | |||
384 | if (reserve) | ||
385 | return __reserve(bdata, sidx, eidx, flags); | ||
386 | else | ||
387 | __free(bdata, sidx, eidx); | ||
388 | return 0; | ||
389 | } | ||
390 | |||
391 | static int __init mark_bootmem(unsigned long start, unsigned long end, | ||
392 | int reserve, int flags) | ||
393 | { | ||
394 | unsigned long pos; | ||
395 | bootmem_data_t *bdata; | ||
396 | |||
397 | pos = start; | ||
398 | list_for_each_entry(bdata, &bdata_list, list) { | ||
399 | int err; | ||
400 | unsigned long max; | ||
401 | |||
402 | if (pos < bdata->node_min_pfn || | ||
403 | pos >= bdata->node_low_pfn) { | ||
404 | BUG_ON(pos != start); | ||
405 | continue; | ||
406 | } | ||
407 | |||
408 | max = min(bdata->node_low_pfn, end); | ||
409 | |||
410 | err = mark_bootmem_node(bdata, pos, max, reserve, flags); | ||
411 | if (reserve && err) { | ||
412 | mark_bootmem(start, pos, 0, 0); | ||
413 | return err; | ||
414 | } | ||
415 | |||
416 | if (max == end) | ||
417 | return 0; | ||
418 | pos = bdata->node_low_pfn; | ||
419 | } | ||
420 | BUG(); | ||
421 | } | ||
422 | |||
423 | void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, | ||
424 | unsigned long size) | ||
425 | { | ||
426 | unsigned long start, end; | ||
427 | |||
428 | kmemleak_free_part_phys(physaddr, size); | ||
429 | |||
430 | start = PFN_UP(physaddr); | ||
431 | end = PFN_DOWN(physaddr + size); | ||
432 | |||
433 | mark_bootmem_node(pgdat->bdata, start, end, 0, 0); | ||
434 | } | ||
435 | |||
436 | void __init free_bootmem(unsigned long physaddr, unsigned long size) | ||
437 | { | ||
438 | unsigned long start, end; | ||
439 | |||
440 | kmemleak_free_part_phys(physaddr, size); | ||
441 | |||
442 | start = PFN_UP(physaddr); | ||
443 | end = PFN_DOWN(physaddr + size); | ||
444 | |||
445 | mark_bootmem(start, end, 0, 0); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * reserve_bootmem_node - mark a page range as reserved | ||
450 | * @pgdat: node the range resides on | ||
451 | * @physaddr: starting address of the range | ||
452 | * @size: size of the range in bytes | ||
453 | * @flags: reservation flags (see linux/bootmem.h) | ||
454 | * | ||
455 | * Partial pages will be reserved. | ||
456 | * | ||
457 | * The range must reside completely on the specified node. | ||
458 | * | ||
459 | * Return: 0 on success, -errno on failure. | ||
460 | */ | ||
461 | int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, | ||
462 | unsigned long size, int flags) | ||
463 | { | ||
464 | unsigned long start, end; | ||
465 | |||
466 | start = PFN_DOWN(physaddr); | ||
467 | end = PFN_UP(physaddr + size); | ||
468 | |||
469 | return mark_bootmem_node(pgdat->bdata, start, end, 1, flags); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * reserve_bootmem - mark a page range as reserved | ||
474 | * @addr: starting address of the range | ||
475 | * @size: size of the range in bytes | ||
476 | * @flags: reservation flags (see linux/bootmem.h) | ||
477 | * | ||
478 | * Partial pages will be reserved. | ||
479 | * | ||
480 | * The range must be contiguous but may span node boundaries. | ||
481 | * | ||
482 | * Return: 0 on success, -errno on failure. | ||
483 | */ | ||
484 | int __init reserve_bootmem(unsigned long addr, unsigned long size, | ||
485 | int flags) | ||
486 | { | ||
487 | unsigned long start, end; | ||
488 | |||
489 | start = PFN_DOWN(addr); | ||
490 | end = PFN_UP(addr + size); | ||
491 | |||
492 | return mark_bootmem(start, end, 1, flags); | ||
493 | } | ||
494 | |||
495 | static unsigned long __init align_idx(struct bootmem_data *bdata, | ||
496 | unsigned long idx, unsigned long step) | ||
497 | { | ||
498 | unsigned long base = bdata->node_min_pfn; | ||
499 | |||
500 | /* | ||
501 | * Align the index with respect to the node start so that the | ||
502 | * combination of both satisfies the requested alignment. | ||
503 | */ | ||
504 | |||
505 | return ALIGN(base + idx, step) - base; | ||
506 | } | ||
507 | |||
508 | static unsigned long __init align_off(struct bootmem_data *bdata, | ||
509 | unsigned long off, unsigned long align) | ||
510 | { | ||
511 | unsigned long base = PFN_PHYS(bdata->node_min_pfn); | ||
512 | |||
513 | /* Same as align_idx for byte offsets */ | ||
514 | |||
515 | return ALIGN(base + off, align) - base; | ||
516 | } | ||
517 | |||
518 | static void * __init alloc_bootmem_bdata(struct bootmem_data *bdata, | ||
519 | unsigned long size, unsigned long align, | ||
520 | unsigned long goal, unsigned long limit) | ||
521 | { | ||
522 | unsigned long fallback = 0; | ||
523 | unsigned long min, max, start, sidx, midx, step; | ||
524 | |||
525 | bdebug("nid=%td size=%lx [%lu pages] align=%lx goal=%lx limit=%lx\n", | ||
526 | bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT, | ||
527 | align, goal, limit); | ||
528 | |||
529 | BUG_ON(!size); | ||
530 | BUG_ON(align & (align - 1)); | ||
531 | BUG_ON(limit && goal + size > limit); | ||
532 | |||
533 | if (!bdata->node_bootmem_map) | ||
534 | return NULL; | ||
535 | |||
536 | min = bdata->node_min_pfn; | ||
537 | max = bdata->node_low_pfn; | ||
538 | |||
539 | goal >>= PAGE_SHIFT; | ||
540 | limit >>= PAGE_SHIFT; | ||
541 | |||
542 | if (limit && max > limit) | ||
543 | max = limit; | ||
544 | if (max <= min) | ||
545 | return NULL; | ||
546 | |||
547 | step = max(align >> PAGE_SHIFT, 1UL); | ||
548 | |||
549 | if (goal && min < goal && goal < max) | ||
550 | start = ALIGN(goal, step); | ||
551 | else | ||
552 | start = ALIGN(min, step); | ||
553 | |||
554 | sidx = start - bdata->node_min_pfn; | ||
555 | midx = max - bdata->node_min_pfn; | ||
556 | |||
557 | if (bdata->hint_idx > sidx) { | ||
558 | /* | ||
559 | * Handle the valid case of sidx being zero and still | ||
560 | * catch the fallback below. | ||
561 | */ | ||
562 | fallback = sidx + 1; | ||
563 | sidx = align_idx(bdata, bdata->hint_idx, step); | ||
564 | } | ||
565 | |||
566 | while (1) { | ||
567 | int merge; | ||
568 | void *region; | ||
569 | unsigned long eidx, i, start_off, end_off; | ||
570 | find_block: | ||
571 | sidx = find_next_zero_bit(bdata->node_bootmem_map, midx, sidx); | ||
572 | sidx = align_idx(bdata, sidx, step); | ||
573 | eidx = sidx + PFN_UP(size); | ||
574 | |||
575 | if (sidx >= midx || eidx > midx) | ||
576 | break; | ||
577 | |||
578 | for (i = sidx; i < eidx; i++) | ||
579 | if (test_bit(i, bdata->node_bootmem_map)) { | ||
580 | sidx = align_idx(bdata, i, step); | ||
581 | if (sidx == i) | ||
582 | sidx += step; | ||
583 | goto find_block; | ||
584 | } | ||
585 | |||
586 | if (bdata->last_end_off & (PAGE_SIZE - 1) && | ||
587 | PFN_DOWN(bdata->last_end_off) + 1 == sidx) | ||
588 | start_off = align_off(bdata, bdata->last_end_off, align); | ||
589 | else | ||
590 | start_off = PFN_PHYS(sidx); | ||
591 | |||
592 | merge = PFN_DOWN(start_off) < sidx; | ||
593 | end_off = start_off + size; | ||
594 | |||
595 | bdata->last_end_off = end_off; | ||
596 | bdata->hint_idx = PFN_UP(end_off); | ||
597 | |||
598 | /* | ||
599 | * Reserve the area now: | ||
600 | */ | ||
601 | if (__reserve(bdata, PFN_DOWN(start_off) + merge, | ||
602 | PFN_UP(end_off), BOOTMEM_EXCLUSIVE)) | ||
603 | BUG(); | ||
604 | |||
605 | region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) + | ||
606 | start_off); | ||
607 | memset(region, 0, size); | ||
608 | /* | ||
609 | * The min_count is set to 0 so that bootmem allocated blocks | ||
610 | * are never reported as leaks. | ||
611 | */ | ||
612 | kmemleak_alloc(region, size, 0, 0); | ||
613 | return region; | ||
614 | } | ||
615 | |||
616 | if (fallback) { | ||
617 | sidx = align_idx(bdata, fallback - 1, step); | ||
618 | fallback = 0; | ||
619 | goto find_block; | ||
620 | } | ||
621 | |||
622 | return NULL; | ||
623 | } | ||
624 | |||
625 | static void * __init alloc_bootmem_core(unsigned long size, | ||
626 | unsigned long align, | ||
627 | unsigned long goal, | ||
628 | unsigned long limit) | ||
629 | { | ||
630 | bootmem_data_t *bdata; | ||
631 | void *region; | ||
632 | |||
633 | if (WARN_ON_ONCE(slab_is_available())) | ||
634 | return kzalloc(size, GFP_NOWAIT); | ||
635 | |||
636 | list_for_each_entry(bdata, &bdata_list, list) { | ||
637 | if (goal && bdata->node_low_pfn <= PFN_DOWN(goal)) | ||
638 | continue; | ||
639 | if (limit && bdata->node_min_pfn >= PFN_DOWN(limit)) | ||
640 | break; | ||
641 | |||
642 | region = alloc_bootmem_bdata(bdata, size, align, goal, limit); | ||
643 | if (region) | ||
644 | return region; | ||
645 | } | ||
646 | |||
647 | return NULL; | ||
648 | } | ||
649 | |||
650 | static void * __init ___alloc_bootmem_nopanic(unsigned long size, | ||
651 | unsigned long align, | ||
652 | unsigned long goal, | ||
653 | unsigned long limit) | ||
654 | { | ||
655 | void *ptr; | ||
656 | |||
657 | restart: | ||
658 | ptr = alloc_bootmem_core(size, align, goal, limit); | ||
659 | if (ptr) | ||
660 | return ptr; | ||
661 | if (goal) { | ||
662 | goal = 0; | ||
663 | goto restart; | ||
664 | } | ||
665 | |||
666 | return NULL; | ||
667 | } | ||
668 | |||
669 | void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align, | ||
670 | unsigned long goal) | ||
671 | { | ||
672 | unsigned long limit = 0; | ||
673 | |||
674 | return ___alloc_bootmem_nopanic(size, align, goal, limit); | ||
675 | } | ||
676 | |||
677 | static void * __init ___alloc_bootmem(unsigned long size, unsigned long align, | ||
678 | unsigned long goal, unsigned long limit) | ||
679 | { | ||
680 | void *mem = ___alloc_bootmem_nopanic(size, align, goal, limit); | ||
681 | |||
682 | if (mem) | ||
683 | return mem; | ||
684 | /* | ||
685 | * Whoops, we cannot satisfy the allocation request. | ||
686 | */ | ||
687 | pr_alert("bootmem alloc of %lu bytes failed!\n", size); | ||
688 | panic("Out of memory"); | ||
689 | return NULL; | ||
690 | } | ||
691 | |||
692 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, | ||
693 | unsigned long goal) | ||
694 | { | ||
695 | unsigned long limit = 0; | ||
696 | |||
697 | return ___alloc_bootmem(size, align, goal, limit); | ||
698 | } | ||
699 | |||
700 | void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat, | ||
701 | unsigned long size, unsigned long align, | ||
702 | unsigned long goal, unsigned long limit) | ||
703 | { | ||
704 | void *ptr; | ||
705 | |||
706 | if (WARN_ON_ONCE(slab_is_available())) | ||
707 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
708 | again: | ||
709 | |||
710 | /* do not panic in alloc_bootmem_bdata() */ | ||
711 | if (limit && goal + size > limit) | ||
712 | limit = 0; | ||
713 | |||
714 | ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, limit); | ||
715 | if (ptr) | ||
716 | return ptr; | ||
717 | |||
718 | ptr = alloc_bootmem_core(size, align, goal, limit); | ||
719 | if (ptr) | ||
720 | return ptr; | ||
721 | |||
722 | if (goal) { | ||
723 | goal = 0; | ||
724 | goto again; | ||
725 | } | ||
726 | |||
727 | return NULL; | ||
728 | } | ||
729 | |||
730 | void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size, | ||
731 | unsigned long align, unsigned long goal) | ||
732 | { | ||
733 | return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0); | ||
734 | } | ||
735 | |||
736 | void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, | ||
737 | unsigned long align, unsigned long goal, | ||
738 | unsigned long limit) | ||
739 | { | ||
740 | void *ptr; | ||
741 | |||
742 | ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0); | ||
743 | if (ptr) | ||
744 | return ptr; | ||
745 | |||
746 | pr_alert("bootmem alloc of %lu bytes failed!\n", size); | ||
747 | panic("Out of memory"); | ||
748 | return NULL; | ||
749 | } | ||
750 | |||
751 | void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, | ||
752 | unsigned long align, unsigned long goal) | ||
753 | { | ||
754 | if (WARN_ON_ONCE(slab_is_available())) | ||
755 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
756 | |||
757 | return ___alloc_bootmem_node(pgdat, size, align, goal, 0); | ||
758 | } | ||
759 | |||
760 | void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size, | ||
761 | unsigned long align, unsigned long goal) | ||
762 | { | ||
763 | #ifdef MAX_DMA32_PFN | ||
764 | unsigned long end_pfn; | ||
765 | |||
766 | if (WARN_ON_ONCE(slab_is_available())) | ||
767 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
768 | |||
769 | /* update goal according ...MAX_DMA32_PFN */ | ||
770 | end_pfn = pgdat_end_pfn(pgdat); | ||
771 | |||
772 | if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) && | ||
773 | (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) { | ||
774 | void *ptr; | ||
775 | unsigned long new_goal; | ||
776 | |||
777 | new_goal = MAX_DMA32_PFN << PAGE_SHIFT; | ||
778 | ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, | ||
779 | new_goal, 0); | ||
780 | if (ptr) | ||
781 | return ptr; | ||
782 | } | ||
783 | #endif | ||
784 | |||
785 | return __alloc_bootmem_node(pgdat, size, align, goal); | ||
786 | |||
787 | } | ||
788 | |||
789 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, | ||
790 | unsigned long goal) | ||
791 | { | ||
792 | return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT); | ||
793 | } | ||
794 | |||
795 | void * __init __alloc_bootmem_low_nopanic(unsigned long size, | ||
796 | unsigned long align, | ||
797 | unsigned long goal) | ||
798 | { | ||
799 | return ___alloc_bootmem_nopanic(size, align, goal, | ||
800 | ARCH_LOW_ADDRESS_LIMIT); | ||
801 | } | ||
802 | |||
803 | void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, | ||
804 | unsigned long align, unsigned long goal) | ||
805 | { | ||
806 | if (WARN_ON_ONCE(slab_is_available())) | ||
807 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
808 | |||
809 | return ___alloc_bootmem_node(pgdat, size, align, | ||
810 | goal, ARCH_LOW_ADDRESS_LIMIT); | ||
811 | } | ||
@@ -1817,8 +1817,8 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, | |||
1817 | * interrupts disabled by get_futex_key. | 1817 | * interrupts disabled by get_futex_key. |
1818 | * | 1818 | * |
1819 | * With interrupts disabled, we block page table pages from being | 1819 | * With interrupts disabled, we block page table pages from being |
1820 | * freed from under us. See mmu_gather_tlb in asm-generic/tlb.h | 1820 | * freed from under us. See struct mmu_table_batch comments in |
1821 | * for more details. | 1821 | * include/asm-generic/tlb.h for more details. |
1822 | * | 1822 | * |
1823 | * We do not adopt an rcu_read_lock(.) here as we also want to | 1823 | * We do not adopt an rcu_read_lock(.) here as we also want to |
1824 | * block IPIs that come from THPs splitting. | 1824 | * block IPIs that come from THPs splitting. |
diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c index debf11388a60..5b42d3d4b60a 100644 --- a/mm/gup_benchmark.c +++ b/mm/gup_benchmark.c | |||
@@ -27,6 +27,9 @@ static int __gup_benchmark_ioctl(unsigned int cmd, | |||
27 | int nr; | 27 | int nr; |
28 | struct page **pages; | 28 | struct page **pages; |
29 | 29 | ||
30 | if (gup->size > ULONG_MAX) | ||
31 | return -EINVAL; | ||
32 | |||
30 | nr_pages = gup->size / PAGE_SIZE; | 33 | nr_pages = gup->size / PAGE_SIZE; |
31 | pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL); | 34 | pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL); |
32 | if (!pages) | 35 | if (!pages) |
@@ -11,7 +11,7 @@ | |||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | * | 13 | * |
14 | * Authors: Jérôme Glisse <jglisse@redhat.com> | 14 | * Authors: Jérôme Glisse <jglisse@redhat.com> |
15 | */ | 15 | */ |
16 | /* | 16 | /* |
17 | * Refer to include/linux/hmm.h for information about heterogeneous memory | 17 | * Refer to include/linux/hmm.h for information about heterogeneous memory |
@@ -43,7 +43,6 @@ static const struct mmu_notifier_ops hmm_mmu_notifier_ops; | |||
43 | * | 43 | * |
44 | * @mm: mm struct this HMM struct is bound to | 44 | * @mm: mm struct this HMM struct is bound to |
45 | * @lock: lock protecting ranges list | 45 | * @lock: lock protecting ranges list |
46 | * @sequence: we track updates to the CPU page table with a sequence number | ||
47 | * @ranges: list of range being snapshotted | 46 | * @ranges: list of range being snapshotted |
48 | * @mirrors: list of mirrors for this mm | 47 | * @mirrors: list of mirrors for this mm |
49 | * @mmu_notifier: mmu notifier to track updates to CPU page table | 48 | * @mmu_notifier: mmu notifier to track updates to CPU page table |
@@ -52,7 +51,6 @@ static const struct mmu_notifier_ops hmm_mmu_notifier_ops; | |||
52 | struct hmm { | 51 | struct hmm { |
53 | struct mm_struct *mm; | 52 | struct mm_struct *mm; |
54 | spinlock_t lock; | 53 | spinlock_t lock; |
55 | atomic_t sequence; | ||
56 | struct list_head ranges; | 54 | struct list_head ranges; |
57 | struct list_head mirrors; | 55 | struct list_head mirrors; |
58 | struct mmu_notifier mmu_notifier; | 56 | struct mmu_notifier mmu_notifier; |
@@ -85,22 +83,11 @@ static struct hmm *hmm_register(struct mm_struct *mm) | |||
85 | return NULL; | 83 | return NULL; |
86 | INIT_LIST_HEAD(&hmm->mirrors); | 84 | INIT_LIST_HEAD(&hmm->mirrors); |
87 | init_rwsem(&hmm->mirrors_sem); | 85 | init_rwsem(&hmm->mirrors_sem); |
88 | atomic_set(&hmm->sequence, 0); | ||
89 | hmm->mmu_notifier.ops = NULL; | 86 | hmm->mmu_notifier.ops = NULL; |
90 | INIT_LIST_HEAD(&hmm->ranges); | 87 | INIT_LIST_HEAD(&hmm->ranges); |
91 | spin_lock_init(&hmm->lock); | 88 | spin_lock_init(&hmm->lock); |
92 | hmm->mm = mm; | 89 | hmm->mm = mm; |
93 | 90 | ||
94 | /* | ||
95 | * We should only get here if hold the mmap_sem in write mode ie on | ||
96 | * registration of first mirror through hmm_mirror_register() | ||
97 | */ | ||
98 | hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops; | ||
99 | if (__mmu_notifier_register(&hmm->mmu_notifier, mm)) { | ||
100 | kfree(hmm); | ||
101 | return NULL; | ||
102 | } | ||
103 | |||
104 | spin_lock(&mm->page_table_lock); | 91 | spin_lock(&mm->page_table_lock); |
105 | if (!mm->hmm) | 92 | if (!mm->hmm) |
106 | mm->hmm = hmm; | 93 | mm->hmm = hmm; |
@@ -108,12 +95,27 @@ static struct hmm *hmm_register(struct mm_struct *mm) | |||
108 | cleanup = true; | 95 | cleanup = true; |
109 | spin_unlock(&mm->page_table_lock); | 96 | spin_unlock(&mm->page_table_lock); |
110 | 97 | ||
111 | if (cleanup) { | 98 | if (cleanup) |
112 | mmu_notifier_unregister(&hmm->mmu_notifier, mm); | 99 | goto error; |
113 | kfree(hmm); | 100 | |
114 | } | 101 | /* |
102 | * We should only get here if hold the mmap_sem in write mode ie on | ||
103 | * registration of first mirror through hmm_mirror_register() | ||
104 | */ | ||
105 | hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops; | ||
106 | if (__mmu_notifier_register(&hmm->mmu_notifier, mm)) | ||
107 | goto error_mm; | ||
115 | 108 | ||
116 | return mm->hmm; | 109 | return mm->hmm; |
110 | |||
111 | error_mm: | ||
112 | spin_lock(&mm->page_table_lock); | ||
113 | if (mm->hmm == hmm) | ||
114 | mm->hmm = NULL; | ||
115 | spin_unlock(&mm->page_table_lock); | ||
116 | error: | ||
117 | kfree(hmm); | ||
118 | return NULL; | ||
117 | } | 119 | } |
118 | 120 | ||
119 | void hmm_mm_destroy(struct mm_struct *mm) | 121 | void hmm_mm_destroy(struct mm_struct *mm) |
@@ -121,10 +123,8 @@ void hmm_mm_destroy(struct mm_struct *mm) | |||
121 | kfree(mm->hmm); | 123 | kfree(mm->hmm); |
122 | } | 124 | } |
123 | 125 | ||
124 | static void hmm_invalidate_range(struct hmm *hmm, | 126 | static int hmm_invalidate_range(struct hmm *hmm, bool device, |
125 | enum hmm_update_type action, | 127 | const struct hmm_update *update) |
126 | unsigned long start, | ||
127 | unsigned long end) | ||
128 | { | 128 | { |
129 | struct hmm_mirror *mirror; | 129 | struct hmm_mirror *mirror; |
130 | struct hmm_range *range; | 130 | struct hmm_range *range; |
@@ -133,22 +133,33 @@ static void hmm_invalidate_range(struct hmm *hmm, | |||
133 | list_for_each_entry(range, &hmm->ranges, list) { | 133 | list_for_each_entry(range, &hmm->ranges, list) { |
134 | unsigned long addr, idx, npages; | 134 | unsigned long addr, idx, npages; |
135 | 135 | ||
136 | if (end < range->start || start >= range->end) | 136 | if (update->end < range->start || update->start >= range->end) |
137 | continue; | 137 | continue; |
138 | 138 | ||
139 | range->valid = false; | 139 | range->valid = false; |
140 | addr = max(start, range->start); | 140 | addr = max(update->start, range->start); |
141 | idx = (addr - range->start) >> PAGE_SHIFT; | 141 | idx = (addr - range->start) >> PAGE_SHIFT; |
142 | npages = (min(range->end, end) - addr) >> PAGE_SHIFT; | 142 | npages = (min(range->end, update->end) - addr) >> PAGE_SHIFT; |
143 | memset(&range->pfns[idx], 0, sizeof(*range->pfns) * npages); | 143 | memset(&range->pfns[idx], 0, sizeof(*range->pfns) * npages); |
144 | } | 144 | } |
145 | spin_unlock(&hmm->lock); | 145 | spin_unlock(&hmm->lock); |
146 | 146 | ||
147 | if (!device) | ||
148 | return 0; | ||
149 | |||
147 | down_read(&hmm->mirrors_sem); | 150 | down_read(&hmm->mirrors_sem); |
148 | list_for_each_entry(mirror, &hmm->mirrors, list) | 151 | list_for_each_entry(mirror, &hmm->mirrors, list) { |
149 | mirror->ops->sync_cpu_device_pagetables(mirror, action, | 152 | int ret; |
150 | start, end); | 153 | |
154 | ret = mirror->ops->sync_cpu_device_pagetables(mirror, update); | ||
155 | if (!update->blockable && ret == -EAGAIN) { | ||
156 | up_read(&hmm->mirrors_sem); | ||
157 | return -EAGAIN; | ||
158 | } | ||
159 | } | ||
151 | up_read(&hmm->mirrors_sem); | 160 | up_read(&hmm->mirrors_sem); |
161 | |||
162 | return 0; | ||
152 | } | 163 | } |
153 | 164 | ||
154 | static void hmm_release(struct mmu_notifier *mn, struct mm_struct *mm) | 165 | static void hmm_release(struct mmu_notifier *mn, struct mm_struct *mm) |
@@ -178,18 +189,21 @@ static void hmm_release(struct mmu_notifier *mn, struct mm_struct *mm) | |||
178 | } | 189 | } |
179 | 190 | ||
180 | static int hmm_invalidate_range_start(struct mmu_notifier *mn, | 191 | static int hmm_invalidate_range_start(struct mmu_notifier *mn, |
181 | struct mm_struct *mm, | 192 | struct mm_struct *mm, |
182 | unsigned long start, | 193 | unsigned long start, |
183 | unsigned long end, | 194 | unsigned long end, |
184 | bool blockable) | 195 | bool blockable) |
185 | { | 196 | { |
197 | struct hmm_update update; | ||
186 | struct hmm *hmm = mm->hmm; | 198 | struct hmm *hmm = mm->hmm; |
187 | 199 | ||
188 | VM_BUG_ON(!hmm); | 200 | VM_BUG_ON(!hmm); |
189 | 201 | ||
190 | atomic_inc(&hmm->sequence); | 202 | update.start = start; |
191 | 203 | update.end = end; | |
192 | return 0; | 204 | update.event = HMM_UPDATE_INVALIDATE; |
205 | update.blockable = blockable; | ||
206 | return hmm_invalidate_range(hmm, true, &update); | ||
193 | } | 207 | } |
194 | 208 | ||
195 | static void hmm_invalidate_range_end(struct mmu_notifier *mn, | 209 | static void hmm_invalidate_range_end(struct mmu_notifier *mn, |
@@ -197,11 +211,16 @@ static void hmm_invalidate_range_end(struct mmu_notifier *mn, | |||
197 | unsigned long start, | 211 | unsigned long start, |
198 | unsigned long end) | 212 | unsigned long end) |
199 | { | 213 | { |
214 | struct hmm_update update; | ||
200 | struct hmm *hmm = mm->hmm; | 215 | struct hmm *hmm = mm->hmm; |
201 | 216 | ||
202 | VM_BUG_ON(!hmm); | 217 | VM_BUG_ON(!hmm); |
203 | 218 | ||
204 | hmm_invalidate_range(mm->hmm, HMM_UPDATE_INVALIDATE, start, end); | 219 | update.start = start; |
220 | update.end = end; | ||
221 | update.event = HMM_UPDATE_INVALIDATE; | ||
222 | update.blockable = true; | ||
223 | hmm_invalidate_range(hmm, false, &update); | ||
205 | } | 224 | } |
206 | 225 | ||
207 | static const struct mmu_notifier_ops hmm_mmu_notifier_ops = { | 226 | static const struct mmu_notifier_ops hmm_mmu_notifier_ops = { |
@@ -278,12 +297,13 @@ void hmm_mirror_unregister(struct hmm_mirror *mirror) | |||
278 | if (!should_unregister || mm == NULL) | 297 | if (!should_unregister || mm == NULL) |
279 | return; | 298 | return; |
280 | 299 | ||
300 | mmu_notifier_unregister_no_release(&hmm->mmu_notifier, mm); | ||
301 | |||
281 | spin_lock(&mm->page_table_lock); | 302 | spin_lock(&mm->page_table_lock); |
282 | if (mm->hmm == hmm) | 303 | if (mm->hmm == hmm) |
283 | mm->hmm = NULL; | 304 | mm->hmm = NULL; |
284 | spin_unlock(&mm->page_table_lock); | 305 | spin_unlock(&mm->page_table_lock); |
285 | 306 | ||
286 | mmu_notifier_unregister_no_release(&hmm->mmu_notifier, mm); | ||
287 | kfree(hmm); | 307 | kfree(hmm); |
288 | } | 308 | } |
289 | EXPORT_SYMBOL(hmm_mirror_unregister); | 309 | EXPORT_SYMBOL(hmm_mirror_unregister); |
@@ -571,22 +591,42 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, | |||
571 | { | 591 | { |
572 | struct hmm_vma_walk *hmm_vma_walk = walk->private; | 592 | struct hmm_vma_walk *hmm_vma_walk = walk->private; |
573 | struct hmm_range *range = hmm_vma_walk->range; | 593 | struct hmm_range *range = hmm_vma_walk->range; |
594 | struct vm_area_struct *vma = walk->vma; | ||
574 | uint64_t *pfns = range->pfns; | 595 | uint64_t *pfns = range->pfns; |
575 | unsigned long addr = start, i; | 596 | unsigned long addr = start, i; |
576 | pte_t *ptep; | 597 | pte_t *ptep; |
598 | pmd_t pmd; | ||
577 | 599 | ||
578 | i = (addr - range->start) >> PAGE_SHIFT; | ||
579 | 600 | ||
580 | again: | 601 | again: |
581 | if (pmd_none(*pmdp)) | 602 | pmd = READ_ONCE(*pmdp); |
603 | if (pmd_none(pmd)) | ||
582 | return hmm_vma_walk_hole(start, end, walk); | 604 | return hmm_vma_walk_hole(start, end, walk); |
583 | 605 | ||
584 | if (pmd_huge(*pmdp) && (range->vma->vm_flags & VM_HUGETLB)) | 606 | if (pmd_huge(pmd) && (range->vma->vm_flags & VM_HUGETLB)) |
585 | return hmm_pfns_bad(start, end, walk); | 607 | return hmm_pfns_bad(start, end, walk); |
586 | 608 | ||
587 | if (pmd_devmap(*pmdp) || pmd_trans_huge(*pmdp)) { | 609 | if (thp_migration_supported() && is_pmd_migration_entry(pmd)) { |
588 | pmd_t pmd; | 610 | bool fault, write_fault; |
611 | unsigned long npages; | ||
612 | uint64_t *pfns; | ||
613 | |||
614 | i = (addr - range->start) >> PAGE_SHIFT; | ||
615 | npages = (end - addr) >> PAGE_SHIFT; | ||
616 | pfns = &range->pfns[i]; | ||
589 | 617 | ||
618 | hmm_range_need_fault(hmm_vma_walk, pfns, npages, | ||
619 | 0, &fault, &write_fault); | ||
620 | if (fault || write_fault) { | ||
621 | hmm_vma_walk->last = addr; | ||
622 | pmd_migration_entry_wait(vma->vm_mm, pmdp); | ||
623 | return -EAGAIN; | ||
624 | } | ||
625 | return 0; | ||
626 | } else if (!pmd_present(pmd)) | ||
627 | return hmm_pfns_bad(start, end, walk); | ||
628 | |||
629 | if (pmd_devmap(pmd) || pmd_trans_huge(pmd)) { | ||
590 | /* | 630 | /* |
591 | * No need to take pmd_lock here, even if some other threads | 631 | * No need to take pmd_lock here, even if some other threads |
592 | * is splitting the huge pmd we will get that event through | 632 | * is splitting the huge pmd we will get that event through |
@@ -601,13 +641,21 @@ again: | |||
601 | if (!pmd_devmap(pmd) && !pmd_trans_huge(pmd)) | 641 | if (!pmd_devmap(pmd) && !pmd_trans_huge(pmd)) |
602 | goto again; | 642 | goto again; |
603 | 643 | ||
644 | i = (addr - range->start) >> PAGE_SHIFT; | ||
604 | return hmm_vma_handle_pmd(walk, addr, end, &pfns[i], pmd); | 645 | return hmm_vma_handle_pmd(walk, addr, end, &pfns[i], pmd); |
605 | } | 646 | } |
606 | 647 | ||
607 | if (pmd_bad(*pmdp)) | 648 | /* |
649 | * We have handled all the valid case above ie either none, migration, | ||
650 | * huge or transparent huge. At this point either it is a valid pmd | ||
651 | * entry pointing to pte directory or it is a bad pmd that will not | ||
652 | * recover. | ||
653 | */ | ||
654 | if (pmd_bad(pmd)) | ||
608 | return hmm_pfns_bad(start, end, walk); | 655 | return hmm_pfns_bad(start, end, walk); |
609 | 656 | ||
610 | ptep = pte_offset_map(pmdp, addr); | 657 | ptep = pte_offset_map(pmdp, addr); |
658 | i = (addr - range->start) >> PAGE_SHIFT; | ||
611 | for (; addr < end; addr += PAGE_SIZE, ptep++, i++) { | 659 | for (; addr < end; addr += PAGE_SIZE, ptep++, i++) { |
612 | int r; | 660 | int r; |
613 | 661 | ||
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7b5c0ad9a6bd..c007fb5fb8d5 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
16 | #include <linux/cpuset.h> | 16 | #include <linux/cpuset.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/bootmem.h> | 18 | #include <linux/memblock.h> |
19 | #include <linux/sysfs.h> | 19 | #include <linux/sysfs.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/mmdebug.h> | 21 | #include <linux/mmdebug.h> |
@@ -2100,9 +2100,9 @@ int __alloc_bootmem_huge_page(struct hstate *h) | |||
2100 | for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { | 2100 | for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { |
2101 | void *addr; | 2101 | void *addr; |
2102 | 2102 | ||
2103 | addr = memblock_virt_alloc_try_nid_raw( | 2103 | addr = memblock_alloc_try_nid_raw( |
2104 | huge_page_size(h), huge_page_size(h), | 2104 | huge_page_size(h), huge_page_size(h), |
2105 | 0, BOOTMEM_ALLOC_ACCESSIBLE, node); | 2105 | 0, MEMBLOCK_ALLOC_ACCESSIBLE, node); |
2106 | if (addr) { | 2106 | if (addr) { |
2107 | /* | 2107 | /* |
2108 | * Use the beginning of the huge page to store the | 2108 | * Use the beginning of the huge page to store the |
diff --git a/mm/internal.h b/mm/internal.h index 87256ae1bef8..291eb2b6d1d8 100644 --- a/mm/internal.h +++ b/mm/internal.h | |||
@@ -161,7 +161,7 @@ static inline struct page *pageblock_pfn_to_page(unsigned long start_pfn, | |||
161 | } | 161 | } |
162 | 162 | ||
163 | extern int __isolate_free_page(struct page *page, unsigned int order); | 163 | extern int __isolate_free_page(struct page *page, unsigned int order); |
164 | extern void __free_pages_bootmem(struct page *page, unsigned long pfn, | 164 | extern void memblock_free_pages(struct page *page, unsigned long pfn, |
165 | unsigned int order); | 165 | unsigned int order); |
166 | extern void prep_compound_page(struct page *page, unsigned int order); | 166 | extern void prep_compound_page(struct page *page, unsigned int order); |
167 | extern void post_alloc_hook(struct page *page, unsigned int order, | 167 | extern void post_alloc_hook(struct page *page, unsigned int order, |
diff --git a/mm/kasan/kasan_init.c b/mm/kasan/kasan_init.c index 7a2a2f13f86f..c7550eb65922 100644 --- a/mm/kasan/kasan_init.c +++ b/mm/kasan/kasan_init.c | |||
@@ -10,11 +10,10 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/bootmem.h> | 13 | #include <linux/memblock.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kasan.h> | 15 | #include <linux/kasan.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/memblock.h> | ||
18 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
19 | #include <linux/pfn.h> | 18 | #include <linux/pfn.h> |
20 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
@@ -83,8 +82,8 @@ static inline bool kasan_zero_page_entry(pte_t pte) | |||
83 | 82 | ||
84 | static __init void *early_alloc(size_t size, int node) | 83 | static __init void *early_alloc(size_t size, int node) |
85 | { | 84 | { |
86 | return memblock_virt_alloc_try_nid(size, size, __pa(MAX_DMA_ADDRESS), | 85 | return memblock_alloc_try_nid(size, size, __pa(MAX_DMA_ADDRESS), |
87 | BOOTMEM_ALLOC_ACCESSIBLE, node); | 86 | MEMBLOCK_ALLOC_ACCESSIBLE, node); |
88 | } | 87 | } |
89 | 88 | ||
90 | static void __ref zero_pte_populate(pmd_t *pmd, unsigned long addr, | 89 | static void __ref zero_pte_populate(pmd_t *pmd, unsigned long addr, |
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 4f7e4b5a2f08..877de4fa0720 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -92,7 +92,7 @@ | |||
92 | #include <linux/stacktrace.h> | 92 | #include <linux/stacktrace.h> |
93 | #include <linux/cache.h> | 93 | #include <linux/cache.h> |
94 | #include <linux/percpu.h> | 94 | #include <linux/percpu.h> |
95 | #include <linux/bootmem.h> | 95 | #include <linux/memblock.h> |
96 | #include <linux/pfn.h> | 96 | #include <linux/pfn.h> |
97 | #include <linux/mmzone.h> | 97 | #include <linux/mmzone.h> |
98 | #include <linux/slab.h> | 98 | #include <linux/slab.h> |
diff --git a/mm/memblock.c b/mm/memblock.c index a85315083b5a..7df468c8ebc8 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/kmemleak.h> | 20 | #include <linux/kmemleak.h> |
21 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
22 | #include <linux/memblock.h> | 22 | #include <linux/memblock.h> |
23 | #include <linux/bootmem.h> | ||
24 | 23 | ||
25 | #include <asm/sections.h> | 24 | #include <asm/sections.h> |
26 | #include <linux/io.h> | 25 | #include <linux/io.h> |
@@ -82,6 +81,16 @@ | |||
82 | * initialization compltes. | 81 | * initialization compltes. |
83 | */ | 82 | */ |
84 | 83 | ||
84 | #ifndef CONFIG_NEED_MULTIPLE_NODES | ||
85 | struct pglist_data __refdata contig_page_data; | ||
86 | EXPORT_SYMBOL(contig_page_data); | ||
87 | #endif | ||
88 | |||
89 | unsigned long max_low_pfn; | ||
90 | unsigned long min_low_pfn; | ||
91 | unsigned long max_pfn; | ||
92 | unsigned long long max_possible_pfn; | ||
93 | |||
85 | static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; | 94 | static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; |
86 | static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; | 95 | static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; |
87 | #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP | 96 | #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP |
@@ -1238,8 +1247,11 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, | |||
1238 | { | 1247 | { |
1239 | phys_addr_t found; | 1248 | phys_addr_t found; |
1240 | 1249 | ||
1241 | if (!align) | 1250 | if (!align) { |
1251 | /* Can't use WARNs this early in boot on powerpc */ | ||
1252 | dump_stack(); | ||
1242 | align = SMP_CACHE_BYTES; | 1253 | align = SMP_CACHE_BYTES; |
1254 | } | ||
1243 | 1255 | ||
1244 | found = memblock_find_in_range_node(size, align, start, end, nid, | 1256 | found = memblock_find_in_range_node(size, align, start, end, nid, |
1245 | flags); | 1257 | flags); |
@@ -1269,7 +1281,7 @@ phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size, | |||
1269 | return memblock_alloc_range_nid(size, align, 0, max_addr, nid, flags); | 1281 | return memblock_alloc_range_nid(size, align, 0, max_addr, nid, flags); |
1270 | } | 1282 | } |
1271 | 1283 | ||
1272 | phys_addr_t __init memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid) | 1284 | phys_addr_t __init memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align, int nid) |
1273 | { | 1285 | { |
1274 | enum memblock_flags flags = choose_memblock_flags(); | 1286 | enum memblock_flags flags = choose_memblock_flags(); |
1275 | phys_addr_t ret; | 1287 | phys_addr_t ret; |
@@ -1304,23 +1316,22 @@ phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys | |||
1304 | return alloc; | 1316 | return alloc; |
1305 | } | 1317 | } |
1306 | 1318 | ||
1307 | phys_addr_t __init memblock_alloc(phys_addr_t size, phys_addr_t align) | 1319 | phys_addr_t __init memblock_phys_alloc(phys_addr_t size, phys_addr_t align) |
1308 | { | 1320 | { |
1309 | return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); | 1321 | return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); |
1310 | } | 1322 | } |
1311 | 1323 | ||
1312 | phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid) | 1324 | phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid) |
1313 | { | 1325 | { |
1314 | phys_addr_t res = memblock_alloc_nid(size, align, nid); | 1326 | phys_addr_t res = memblock_phys_alloc_nid(size, align, nid); |
1315 | 1327 | ||
1316 | if (res) | 1328 | if (res) |
1317 | return res; | 1329 | return res; |
1318 | return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); | 1330 | return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); |
1319 | } | 1331 | } |
1320 | 1332 | ||
1321 | #if defined(CONFIG_NO_BOOTMEM) | ||
1322 | /** | 1333 | /** |
1323 | * memblock_virt_alloc_internal - allocate boot memory block | 1334 | * memblock_alloc_internal - allocate boot memory block |
1324 | * @size: size of memory block to be allocated in bytes | 1335 | * @size: size of memory block to be allocated in bytes |
1325 | * @align: alignment of the region and block's size | 1336 | * @align: alignment of the region and block's size |
1326 | * @min_addr: the lower bound of the memory region to allocate (phys address) | 1337 | * @min_addr: the lower bound of the memory region to allocate (phys address) |
@@ -1333,9 +1344,7 @@ phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, i | |||
1333 | * hold the requested memory. | 1344 | * hold the requested memory. |
1334 | * | 1345 | * |
1335 | * The allocation is performed from memory region limited by | 1346 | * The allocation is performed from memory region limited by |
1336 | * memblock.current_limit if @max_addr == %BOOTMEM_ALLOC_ACCESSIBLE. | 1347 | * memblock.current_limit if @max_addr == %MEMBLOCK_ALLOC_ACCESSIBLE. |
1337 | * | ||
1338 | * The memory block is aligned on %SMP_CACHE_BYTES if @align == 0. | ||
1339 | * | 1348 | * |
1340 | * The phys address of allocated boot memory block is converted to virtual and | 1349 | * The phys address of allocated boot memory block is converted to virtual and |
1341 | * allocated memory is reset to 0. | 1350 | * allocated memory is reset to 0. |
@@ -1346,7 +1355,7 @@ phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, i | |||
1346 | * Return: | 1355 | * Return: |
1347 | * Virtual address of allocated memory block on success, NULL on failure. | 1356 | * Virtual address of allocated memory block on success, NULL on failure. |
1348 | */ | 1357 | */ |
1349 | static void * __init memblock_virt_alloc_internal( | 1358 | static void * __init memblock_alloc_internal( |
1350 | phys_addr_t size, phys_addr_t align, | 1359 | phys_addr_t size, phys_addr_t align, |
1351 | phys_addr_t min_addr, phys_addr_t max_addr, | 1360 | phys_addr_t min_addr, phys_addr_t max_addr, |
1352 | int nid) | 1361 | int nid) |
@@ -1361,13 +1370,15 @@ static void * __init memblock_virt_alloc_internal( | |||
1361 | /* | 1370 | /* |
1362 | * Detect any accidental use of these APIs after slab is ready, as at | 1371 | * Detect any accidental use of these APIs after slab is ready, as at |
1363 | * this moment memblock may be deinitialized already and its | 1372 | * this moment memblock may be deinitialized already and its |
1364 | * internal data may be destroyed (after execution of free_all_bootmem) | 1373 | * internal data may be destroyed (after execution of memblock_free_all) |
1365 | */ | 1374 | */ |
1366 | if (WARN_ON_ONCE(slab_is_available())) | 1375 | if (WARN_ON_ONCE(slab_is_available())) |
1367 | return kzalloc_node(size, GFP_NOWAIT, nid); | 1376 | return kzalloc_node(size, GFP_NOWAIT, nid); |
1368 | 1377 | ||
1369 | if (!align) | 1378 | if (!align) { |
1379 | dump_stack(); | ||
1370 | align = SMP_CACHE_BYTES; | 1380 | align = SMP_CACHE_BYTES; |
1381 | } | ||
1371 | 1382 | ||
1372 | if (max_addr > memblock.current_limit) | 1383 | if (max_addr > memblock.current_limit) |
1373 | max_addr = memblock.current_limit; | 1384 | max_addr = memblock.current_limit; |
@@ -1413,14 +1424,14 @@ done: | |||
1413 | } | 1424 | } |
1414 | 1425 | ||
1415 | /** | 1426 | /** |
1416 | * memblock_virt_alloc_try_nid_raw - allocate boot memory block without zeroing | 1427 | * memblock_alloc_try_nid_raw - allocate boot memory block without zeroing |
1417 | * memory and without panicking | 1428 | * memory and without panicking |
1418 | * @size: size of memory block to be allocated in bytes | 1429 | * @size: size of memory block to be allocated in bytes |
1419 | * @align: alignment of the region and block's size | 1430 | * @align: alignment of the region and block's size |
1420 | * @min_addr: the lower bound of the memory region from where the allocation | 1431 | * @min_addr: the lower bound of the memory region from where the allocation |
1421 | * is preferred (phys address) | 1432 | * is preferred (phys address) |
1422 | * @max_addr: the upper bound of the memory region from where the allocation | 1433 | * @max_addr: the upper bound of the memory region from where the allocation |
1423 | * is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to | 1434 | * is preferred (phys address), or %MEMBLOCK_ALLOC_ACCESSIBLE to |
1424 | * allocate only from memory limited by memblock.current_limit value | 1435 | * allocate only from memory limited by memblock.current_limit value |
1425 | * @nid: nid of the free area to find, %NUMA_NO_NODE for any node | 1436 | * @nid: nid of the free area to find, %NUMA_NO_NODE for any node |
1426 | * | 1437 | * |
@@ -1431,7 +1442,7 @@ done: | |||
1431 | * Return: | 1442 | * Return: |
1432 | * Virtual address of allocated memory block on success, NULL on failure. | 1443 | * Virtual address of allocated memory block on success, NULL on failure. |
1433 | */ | 1444 | */ |
1434 | void * __init memblock_virt_alloc_try_nid_raw( | 1445 | void * __init memblock_alloc_try_nid_raw( |
1435 | phys_addr_t size, phys_addr_t align, | 1446 | phys_addr_t size, phys_addr_t align, |
1436 | phys_addr_t min_addr, phys_addr_t max_addr, | 1447 | phys_addr_t min_addr, phys_addr_t max_addr, |
1437 | int nid) | 1448 | int nid) |
@@ -1442,7 +1453,7 @@ void * __init memblock_virt_alloc_try_nid_raw( | |||
1442 | __func__, (u64)size, (u64)align, nid, &min_addr, | 1453 | __func__, (u64)size, (u64)align, nid, &min_addr, |
1443 | &max_addr, (void *)_RET_IP_); | 1454 | &max_addr, (void *)_RET_IP_); |
1444 | 1455 | ||
1445 | ptr = memblock_virt_alloc_internal(size, align, | 1456 | ptr = memblock_alloc_internal(size, align, |
1446 | min_addr, max_addr, nid); | 1457 | min_addr, max_addr, nid); |
1447 | if (ptr && size > 0) | 1458 | if (ptr && size > 0) |
1448 | page_init_poison(ptr, size); | 1459 | page_init_poison(ptr, size); |
@@ -1451,13 +1462,13 @@ void * __init memblock_virt_alloc_try_nid_raw( | |||
1451 | } | 1462 | } |
1452 | 1463 | ||
1453 | /** | 1464 | /** |
1454 | * memblock_virt_alloc_try_nid_nopanic - allocate boot memory block | 1465 | * memblock_alloc_try_nid_nopanic - allocate boot memory block |
1455 | * @size: size of memory block to be allocated in bytes | 1466 | * @size: size of memory block to be allocated in bytes |
1456 | * @align: alignment of the region and block's size | 1467 | * @align: alignment of the region and block's size |
1457 | * @min_addr: the lower bound of the memory region from where the allocation | 1468 | * @min_addr: the lower bound of the memory region from where the allocation |
1458 | * is preferred (phys address) | 1469 | * is preferred (phys address) |
1459 | * @max_addr: the upper bound of the memory region from where the allocation | 1470 | * @max_addr: the upper bound of the memory region from where the allocation |
1460 | * is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to | 1471 | * is preferred (phys address), or %MEMBLOCK_ALLOC_ACCESSIBLE to |
1461 | * allocate only from memory limited by memblock.current_limit value | 1472 | * allocate only from memory limited by memblock.current_limit value |
1462 | * @nid: nid of the free area to find, %NUMA_NO_NODE for any node | 1473 | * @nid: nid of the free area to find, %NUMA_NO_NODE for any node |
1463 | * | 1474 | * |
@@ -1467,7 +1478,7 @@ void * __init memblock_virt_alloc_try_nid_raw( | |||
1467 | * Return: | 1478 | * Return: |
1468 | * Virtual address of allocated memory block on success, NULL on failure. | 1479 | * Virtual address of allocated memory block on success, NULL on failure. |
1469 | */ | 1480 | */ |
1470 | void * __init memblock_virt_alloc_try_nid_nopanic( | 1481 | void * __init memblock_alloc_try_nid_nopanic( |
1471 | phys_addr_t size, phys_addr_t align, | 1482 | phys_addr_t size, phys_addr_t align, |
1472 | phys_addr_t min_addr, phys_addr_t max_addr, | 1483 | phys_addr_t min_addr, phys_addr_t max_addr, |
1473 | int nid) | 1484 | int nid) |
@@ -1478,7 +1489,7 @@ void * __init memblock_virt_alloc_try_nid_nopanic( | |||
1478 | __func__, (u64)size, (u64)align, nid, &min_addr, | 1489 | __func__, (u64)size, (u64)align, nid, &min_addr, |
1479 | &max_addr, (void *)_RET_IP_); | 1490 | &max_addr, (void *)_RET_IP_); |
1480 | 1491 | ||
1481 | ptr = memblock_virt_alloc_internal(size, align, | 1492 | ptr = memblock_alloc_internal(size, align, |
1482 | min_addr, max_addr, nid); | 1493 | min_addr, max_addr, nid); |
1483 | if (ptr) | 1494 | if (ptr) |
1484 | memset(ptr, 0, size); | 1495 | memset(ptr, 0, size); |
@@ -1486,24 +1497,24 @@ void * __init memblock_virt_alloc_try_nid_nopanic( | |||
1486 | } | 1497 | } |
1487 | 1498 | ||
1488 | /** | 1499 | /** |
1489 | * memblock_virt_alloc_try_nid - allocate boot memory block with panicking | 1500 | * memblock_alloc_try_nid - allocate boot memory block with panicking |
1490 | * @size: size of memory block to be allocated in bytes | 1501 | * @size: size of memory block to be allocated in bytes |
1491 | * @align: alignment of the region and block's size | 1502 | * @align: alignment of the region and block's size |
1492 | * @min_addr: the lower bound of the memory region from where the allocation | 1503 | * @min_addr: the lower bound of the memory region from where the allocation |
1493 | * is preferred (phys address) | 1504 | * is preferred (phys address) |
1494 | * @max_addr: the upper bound of the memory region from where the allocation | 1505 | * @max_addr: the upper bound of the memory region from where the allocation |
1495 | * is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to | 1506 | * is preferred (phys address), or %MEMBLOCK_ALLOC_ACCESSIBLE to |
1496 | * allocate only from memory limited by memblock.current_limit value | 1507 | * allocate only from memory limited by memblock.current_limit value |
1497 | * @nid: nid of the free area to find, %NUMA_NO_NODE for any node | 1508 | * @nid: nid of the free area to find, %NUMA_NO_NODE for any node |
1498 | * | 1509 | * |
1499 | * Public panicking version of memblock_virt_alloc_try_nid_nopanic() | 1510 | * Public panicking version of memblock_alloc_try_nid_nopanic() |
1500 | * which provides debug information (including caller info), if enabled, | 1511 | * which provides debug information (including caller info), if enabled, |
1501 | * and panics if the request can not be satisfied. | 1512 | * and panics if the request can not be satisfied. |
1502 | * | 1513 | * |
1503 | * Return: | 1514 | * Return: |
1504 | * Virtual address of allocated memory block on success, NULL on failure. | 1515 | * Virtual address of allocated memory block on success, NULL on failure. |
1505 | */ | 1516 | */ |
1506 | void * __init memblock_virt_alloc_try_nid( | 1517 | void * __init memblock_alloc_try_nid( |
1507 | phys_addr_t size, phys_addr_t align, | 1518 | phys_addr_t size, phys_addr_t align, |
1508 | phys_addr_t min_addr, phys_addr_t max_addr, | 1519 | phys_addr_t min_addr, phys_addr_t max_addr, |
1509 | int nid) | 1520 | int nid) |
@@ -1513,7 +1524,7 @@ void * __init memblock_virt_alloc_try_nid( | |||
1513 | memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pF\n", | 1524 | memblock_dbg("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pF\n", |
1514 | __func__, (u64)size, (u64)align, nid, &min_addr, | 1525 | __func__, (u64)size, (u64)align, nid, &min_addr, |
1515 | &max_addr, (void *)_RET_IP_); | 1526 | &max_addr, (void *)_RET_IP_); |
1516 | ptr = memblock_virt_alloc_internal(size, align, | 1527 | ptr = memblock_alloc_internal(size, align, |
1517 | min_addr, max_addr, nid); | 1528 | min_addr, max_addr, nid); |
1518 | if (ptr) { | 1529 | if (ptr) { |
1519 | memset(ptr, 0, size); | 1530 | memset(ptr, 0, size); |
@@ -1524,14 +1535,13 @@ void * __init memblock_virt_alloc_try_nid( | |||
1524 | __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr); | 1535 | __func__, (u64)size, (u64)align, nid, &min_addr, &max_addr); |
1525 | return NULL; | 1536 | return NULL; |
1526 | } | 1537 | } |
1527 | #endif | ||
1528 | 1538 | ||
1529 | /** | 1539 | /** |
1530 | * __memblock_free_early - free boot memory block | 1540 | * __memblock_free_early - free boot memory block |
1531 | * @base: phys starting address of the boot memory block | 1541 | * @base: phys starting address of the boot memory block |
1532 | * @size: size of the boot memory block in bytes | 1542 | * @size: size of the boot memory block in bytes |
1533 | * | 1543 | * |
1534 | * Free boot memory block previously allocated by memblock_virt_alloc_xx() API. | 1544 | * Free boot memory block previously allocated by memblock_alloc_xx() API. |
1535 | * The freeing memory will not be released to the buddy allocator. | 1545 | * The freeing memory will not be released to the buddy allocator. |
1536 | */ | 1546 | */ |
1537 | void __init __memblock_free_early(phys_addr_t base, phys_addr_t size) | 1547 | void __init __memblock_free_early(phys_addr_t base, phys_addr_t size) |
@@ -1565,7 +1575,7 @@ void __init __memblock_free_late(phys_addr_t base, phys_addr_t size) | |||
1565 | end = PFN_DOWN(base + size); | 1575 | end = PFN_DOWN(base + size); |
1566 | 1576 | ||
1567 | for (; cursor < end; cursor++) { | 1577 | for (; cursor < end; cursor++) { |
1568 | __free_pages_bootmem(pfn_to_page(cursor), cursor, 0); | 1578 | memblock_free_pages(pfn_to_page(cursor), cursor, 0); |
1569 | totalram_pages++; | 1579 | totalram_pages++; |
1570 | } | 1580 | } |
1571 | } | 1581 | } |
@@ -1879,6 +1889,100 @@ static int __init early_memblock(char *p) | |||
1879 | } | 1889 | } |
1880 | early_param("memblock", early_memblock); | 1890 | early_param("memblock", early_memblock); |
1881 | 1891 | ||
1892 | static void __init __free_pages_memory(unsigned long start, unsigned long end) | ||
1893 | { | ||
1894 | int order; | ||
1895 | |||
1896 | while (start < end) { | ||
1897 | order = min(MAX_ORDER - 1UL, __ffs(start)); | ||
1898 | |||
1899 | while (start + (1UL << order) > end) | ||
1900 | order--; | ||
1901 | |||
1902 | memblock_free_pages(pfn_to_page(start), start, order); | ||
1903 | |||
1904 | start += (1UL << order); | ||
1905 | } | ||
1906 | } | ||
1907 | |||
1908 | static unsigned long __init __free_memory_core(phys_addr_t start, | ||
1909 | phys_addr_t end) | ||
1910 | { | ||
1911 | unsigned long start_pfn = PFN_UP(start); | ||
1912 | unsigned long end_pfn = min_t(unsigned long, | ||
1913 | PFN_DOWN(end), max_low_pfn); | ||
1914 | |||
1915 | if (start_pfn >= end_pfn) | ||
1916 | return 0; | ||
1917 | |||
1918 | __free_pages_memory(start_pfn, end_pfn); | ||
1919 | |||
1920 | return end_pfn - start_pfn; | ||
1921 | } | ||
1922 | |||
1923 | static unsigned long __init free_low_memory_core_early(void) | ||
1924 | { | ||
1925 | unsigned long count = 0; | ||
1926 | phys_addr_t start, end; | ||
1927 | u64 i; | ||
1928 | |||
1929 | memblock_clear_hotplug(0, -1); | ||
1930 | |||
1931 | for_each_reserved_mem_region(i, &start, &end) | ||
1932 | reserve_bootmem_region(start, end); | ||
1933 | |||
1934 | /* | ||
1935 | * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id | ||
1936 | * because in some case like Node0 doesn't have RAM installed | ||
1937 | * low ram will be on Node1 | ||
1938 | */ | ||
1939 | for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end, | ||
1940 | NULL) | ||
1941 | count += __free_memory_core(start, end); | ||
1942 | |||
1943 | return count; | ||
1944 | } | ||
1945 | |||
1946 | static int reset_managed_pages_done __initdata; | ||
1947 | |||
1948 | void reset_node_managed_pages(pg_data_t *pgdat) | ||
1949 | { | ||
1950 | struct zone *z; | ||
1951 | |||
1952 | for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) | ||
1953 | z->managed_pages = 0; | ||
1954 | } | ||
1955 | |||
1956 | void __init reset_all_zones_managed_pages(void) | ||
1957 | { | ||
1958 | struct pglist_data *pgdat; | ||
1959 | |||
1960 | if (reset_managed_pages_done) | ||
1961 | return; | ||
1962 | |||
1963 | for_each_online_pgdat(pgdat) | ||
1964 | reset_node_managed_pages(pgdat); | ||
1965 | |||
1966 | reset_managed_pages_done = 1; | ||
1967 | } | ||
1968 | |||
1969 | /** | ||
1970 | * memblock_free_all - release free pages to the buddy allocator | ||
1971 | * | ||
1972 | * Return: the number of pages actually released. | ||
1973 | */ | ||
1974 | unsigned long __init memblock_free_all(void) | ||
1975 | { | ||
1976 | unsigned long pages; | ||
1977 | |||
1978 | reset_all_zones_managed_pages(); | ||
1979 | |||
1980 | pages = free_low_memory_core_early(); | ||
1981 | totalram_pages += pages; | ||
1982 | |||
1983 | return pages; | ||
1984 | } | ||
1985 | |||
1882 | #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) | 1986 | #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK) |
1883 | 1987 | ||
1884 | static int memblock_debug_show(struct seq_file *m, void *private) | 1988 | static int memblock_debug_show(struct seq_file *m, void *private) |
diff --git a/mm/memory.c b/mm/memory.c index 072139579d89..4ad2d293ddc2 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -1537,10 +1537,15 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, | |||
1537 | * in may not match the PFN we have mapped if the | 1537 | * in may not match the PFN we have mapped if the |
1538 | * mapped PFN is a writeable COW page. In the mkwrite | 1538 | * mapped PFN is a writeable COW page. In the mkwrite |
1539 | * case we are creating a writable PTE for a shared | 1539 | * case we are creating a writable PTE for a shared |
1540 | * mapping and we expect the PFNs to match. | 1540 | * mapping and we expect the PFNs to match. If they |
1541 | * don't match, we are likely racing with block | ||
1542 | * allocation and mapping invalidation so just skip the | ||
1543 | * update. | ||
1541 | */ | 1544 | */ |
1542 | if (WARN_ON_ONCE(pte_pfn(*pte) != pfn_t_to_pfn(pfn))) | 1545 | if (pte_pfn(*pte) != pfn_t_to_pfn(pfn)) { |
1546 | WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte))); | ||
1543 | goto out_unlock; | 1547 | goto out_unlock; |
1548 | } | ||
1544 | entry = *pte; | 1549 | entry = *pte; |
1545 | goto out_mkwrite; | 1550 | goto out_mkwrite; |
1546 | } else | 1551 | } else |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7e6509a53d79..61972da38d93 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/stop_machine.h> | 33 | #include <linux/stop_machine.h> |
34 | #include <linux/hugetlb.h> | 34 | #include <linux/hugetlb.h> |
35 | #include <linux/memblock.h> | 35 | #include <linux/memblock.h> |
36 | #include <linux/bootmem.h> | ||
37 | #include <linux/compaction.h> | 36 | #include <linux/compaction.h> |
38 | 37 | ||
39 | #include <asm/tlbflush.h> | 38 | #include <asm/tlbflush.h> |
@@ -839,7 +838,6 @@ static struct zone * __meminit move_pfn_range(int online_type, int nid, | |||
839 | return zone; | 838 | return zone; |
840 | } | 839 | } |
841 | 840 | ||
842 | /* Must be protected by mem_hotplug_begin() or a device_lock */ | ||
843 | int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) | 841 | int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_type) |
844 | { | 842 | { |
845 | unsigned long flags; | 843 | unsigned long flags; |
@@ -851,6 +849,8 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ | |||
851 | struct memory_notify arg; | 849 | struct memory_notify arg; |
852 | struct memory_block *mem; | 850 | struct memory_block *mem; |
853 | 851 | ||
852 | mem_hotplug_begin(); | ||
853 | |||
854 | /* | 854 | /* |
855 | * We can't use pfn_to_nid() because nid might be stored in struct page | 855 | * We can't use pfn_to_nid() because nid might be stored in struct page |
856 | * which is not yet initialized. Instead, we find nid from memory block. | 856 | * which is not yet initialized. Instead, we find nid from memory block. |
@@ -915,6 +915,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ | |||
915 | 915 | ||
916 | if (onlined_pages) | 916 | if (onlined_pages) |
917 | memory_notify(MEM_ONLINE, &arg); | 917 | memory_notify(MEM_ONLINE, &arg); |
918 | mem_hotplug_done(); | ||
918 | return 0; | 919 | return 0; |
919 | 920 | ||
920 | failed_addition: | 921 | failed_addition: |
@@ -922,6 +923,7 @@ failed_addition: | |||
922 | (unsigned long long) pfn << PAGE_SHIFT, | 923 | (unsigned long long) pfn << PAGE_SHIFT, |
923 | (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1); | 924 | (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1); |
924 | memory_notify(MEM_CANCEL_ONLINE, &arg); | 925 | memory_notify(MEM_CANCEL_ONLINE, &arg); |
926 | mem_hotplug_done(); | ||
925 | return ret; | 927 | return ret; |
926 | } | 928 | } |
927 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ | 929 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ |
@@ -1069,7 +1071,12 @@ static int online_memory_block(struct memory_block *mem, void *arg) | |||
1069 | return device_online(&mem->dev); | 1071 | return device_online(&mem->dev); |
1070 | } | 1072 | } |
1071 | 1073 | ||
1072 | /* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ | 1074 | /* |
1075 | * NOTE: The caller must call lock_device_hotplug() to serialize hotplug | ||
1076 | * and online/offline operations (triggered e.g. by sysfs). | ||
1077 | * | ||
1078 | * we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG | ||
1079 | */ | ||
1073 | int __ref add_memory_resource(int nid, struct resource *res, bool online) | 1080 | int __ref add_memory_resource(int nid, struct resource *res, bool online) |
1074 | { | 1081 | { |
1075 | u64 start, size; | 1082 | u64 start, size; |
@@ -1121,26 +1128,26 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online) | |||
1121 | /* create new memmap entry */ | 1128 | /* create new memmap entry */ |
1122 | firmware_map_add_hotplug(start, start + size, "System RAM"); | 1129 | firmware_map_add_hotplug(start, start + size, "System RAM"); |
1123 | 1130 | ||
1131 | /* device_online() will take the lock when calling online_pages() */ | ||
1132 | mem_hotplug_done(); | ||
1133 | |||
1124 | /* online pages if requested */ | 1134 | /* online pages if requested */ |
1125 | if (online) | 1135 | if (online) |
1126 | walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), | 1136 | walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), |
1127 | NULL, online_memory_block); | 1137 | NULL, online_memory_block); |
1128 | 1138 | ||
1129 | goto out; | 1139 | return ret; |
1130 | |||
1131 | error: | 1140 | error: |
1132 | /* rollback pgdat allocation and others */ | 1141 | /* rollback pgdat allocation and others */ |
1133 | if (new_node) | 1142 | if (new_node) |
1134 | rollback_node_hotadd(nid); | 1143 | rollback_node_hotadd(nid); |
1135 | memblock_remove(start, size); | 1144 | memblock_remove(start, size); |
1136 | |||
1137 | out: | ||
1138 | mem_hotplug_done(); | 1145 | mem_hotplug_done(); |
1139 | return ret; | 1146 | return ret; |
1140 | } | 1147 | } |
1141 | EXPORT_SYMBOL_GPL(add_memory_resource); | ||
1142 | 1148 | ||
1143 | int __ref add_memory(int nid, u64 start, u64 size) | 1149 | /* requires device_hotplug_lock, see add_memory_resource() */ |
1150 | int __ref __add_memory(int nid, u64 start, u64 size) | ||
1144 | { | 1151 | { |
1145 | struct resource *res; | 1152 | struct resource *res; |
1146 | int ret; | 1153 | int ret; |
@@ -1154,6 +1161,17 @@ int __ref add_memory(int nid, u64 start, u64 size) | |||
1154 | release_memory_resource(res); | 1161 | release_memory_resource(res); |
1155 | return ret; | 1162 | return ret; |
1156 | } | 1163 | } |
1164 | |||
1165 | int add_memory(int nid, u64 start, u64 size) | ||
1166 | { | ||
1167 | int rc; | ||
1168 | |||
1169 | lock_device_hotplug(); | ||
1170 | rc = __add_memory(nid, start, size); | ||
1171 | unlock_device_hotplug(); | ||
1172 | |||
1173 | return rc; | ||
1174 | } | ||
1157 | EXPORT_SYMBOL_GPL(add_memory); | 1175 | EXPORT_SYMBOL_GPL(add_memory); |
1158 | 1176 | ||
1159 | #ifdef CONFIG_MEMORY_HOTREMOVE | 1177 | #ifdef CONFIG_MEMORY_HOTREMOVE |
@@ -1540,10 +1558,16 @@ static int __ref __offline_pages(unsigned long start_pfn, | |||
1540 | return -EINVAL; | 1558 | return -EINVAL; |
1541 | if (!IS_ALIGNED(end_pfn, pageblock_nr_pages)) | 1559 | if (!IS_ALIGNED(end_pfn, pageblock_nr_pages)) |
1542 | return -EINVAL; | 1560 | return -EINVAL; |
1561 | |||
1562 | mem_hotplug_begin(); | ||
1563 | |||
1543 | /* This makes hotplug much easier...and readable. | 1564 | /* This makes hotplug much easier...and readable. |
1544 | we assume this for now. .*/ | 1565 | we assume this for now. .*/ |
1545 | if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, &valid_end)) | 1566 | if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, |
1567 | &valid_end)) { | ||
1568 | mem_hotplug_done(); | ||
1546 | return -EINVAL; | 1569 | return -EINVAL; |
1570 | } | ||
1547 | 1571 | ||
1548 | zone = page_zone(pfn_to_page(valid_start)); | 1572 | zone = page_zone(pfn_to_page(valid_start)); |
1549 | node = zone_to_nid(zone); | 1573 | node = zone_to_nid(zone); |
@@ -1552,8 +1576,10 @@ static int __ref __offline_pages(unsigned long start_pfn, | |||
1552 | /* set above range as isolated */ | 1576 | /* set above range as isolated */ |
1553 | ret = start_isolate_page_range(start_pfn, end_pfn, | 1577 | ret = start_isolate_page_range(start_pfn, end_pfn, |
1554 | MIGRATE_MOVABLE, true); | 1578 | MIGRATE_MOVABLE, true); |
1555 | if (ret) | 1579 | if (ret) { |
1580 | mem_hotplug_done(); | ||
1556 | return ret; | 1581 | return ret; |
1582 | } | ||
1557 | 1583 | ||
1558 | arg.start_pfn = start_pfn; | 1584 | arg.start_pfn = start_pfn; |
1559 | arg.nr_pages = nr_pages; | 1585 | arg.nr_pages = nr_pages; |
@@ -1624,6 +1650,7 @@ repeat: | |||
1624 | writeback_set_ratelimit(); | 1650 | writeback_set_ratelimit(); |
1625 | 1651 | ||
1626 | memory_notify(MEM_OFFLINE, &arg); | 1652 | memory_notify(MEM_OFFLINE, &arg); |
1653 | mem_hotplug_done(); | ||
1627 | return 0; | 1654 | return 0; |
1628 | 1655 | ||
1629 | failed_removal: | 1656 | failed_removal: |
@@ -1633,10 +1660,10 @@ failed_removal: | |||
1633 | memory_notify(MEM_CANCEL_OFFLINE, &arg); | 1660 | memory_notify(MEM_CANCEL_OFFLINE, &arg); |
1634 | /* pushback to free area */ | 1661 | /* pushback to free area */ |
1635 | undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); | 1662 | undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); |
1663 | mem_hotplug_done(); | ||
1636 | return ret; | 1664 | return ret; |
1637 | } | 1665 | } |
1638 | 1666 | ||
1639 | /* Must be protected by mem_hotplug_begin() or a device_lock */ | ||
1640 | int offline_pages(unsigned long start_pfn, unsigned long nr_pages) | 1667 | int offline_pages(unsigned long start_pfn, unsigned long nr_pages) |
1641 | { | 1668 | { |
1642 | return __offline_pages(start_pfn, start_pfn + nr_pages); | 1669 | return __offline_pages(start_pfn, start_pfn + nr_pages); |
@@ -1807,7 +1834,7 @@ EXPORT_SYMBOL(try_offline_node); | |||
1807 | * and online/offline operations before this call, as required by | 1834 | * and online/offline operations before this call, as required by |
1808 | * try_offline_node(). | 1835 | * try_offline_node(). |
1809 | */ | 1836 | */ |
1810 | void __ref remove_memory(int nid, u64 start, u64 size) | 1837 | void __ref __remove_memory(int nid, u64 start, u64 size) |
1811 | { | 1838 | { |
1812 | int ret; | 1839 | int ret; |
1813 | 1840 | ||
@@ -1836,5 +1863,12 @@ void __ref remove_memory(int nid, u64 start, u64 size) | |||
1836 | 1863 | ||
1837 | mem_hotplug_done(); | 1864 | mem_hotplug_done(); |
1838 | } | 1865 | } |
1866 | |||
1867 | void remove_memory(int nid, u64 start, u64 size) | ||
1868 | { | ||
1869 | lock_device_hotplug(); | ||
1870 | __remove_memory(nid, start, size); | ||
1871 | unlock_device_hotplug(); | ||
1872 | } | ||
1839 | EXPORT_SYMBOL_GPL(remove_memory); | 1873 | EXPORT_SYMBOL_GPL(remove_memory); |
1840 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | 1874 | #endif /* CONFIG_MEMORY_HOTREMOVE */ |
diff --git a/mm/nobootmem.c b/mm/nobootmem.c deleted file mode 100644 index 439af3b765a7..000000000000 --- a/mm/nobootmem.c +++ /dev/null | |||
@@ -1,445 +0,0 @@ | |||
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_HAVE_MEMBLOCK | ||
27 | #error CONFIG_HAVE_MEMBLOCK not defined | ||
28 | #endif | ||
29 | |||
30 | #ifndef CONFIG_NEED_MULTIPLE_NODES | ||
31 | struct pglist_data __refdata contig_page_data; | ||
32 | EXPORT_SYMBOL(contig_page_data); | ||
33 | #endif | ||
34 | |||
35 | unsigned long max_low_pfn; | ||
36 | unsigned long min_low_pfn; | ||
37 | unsigned long max_pfn; | ||
38 | unsigned long long max_possible_pfn; | ||
39 | |||
40 | static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align, | ||
41 | u64 goal, u64 limit) | ||
42 | { | ||
43 | void *ptr; | ||
44 | u64 addr; | ||
45 | enum memblock_flags flags = choose_memblock_flags(); | ||
46 | |||
47 | if (limit > memblock.current_limit) | ||
48 | limit = memblock.current_limit; | ||
49 | |||
50 | again: | ||
51 | addr = memblock_find_in_range_node(size, align, goal, limit, nid, | ||
52 | flags); | ||
53 | if (!addr && (flags & MEMBLOCK_MIRROR)) { | ||
54 | flags &= ~MEMBLOCK_MIRROR; | ||
55 | pr_warn("Could not allocate %pap bytes of mirrored memory\n", | ||
56 | &size); | ||
57 | goto again; | ||
58 | } | ||
59 | if (!addr) | ||
60 | return NULL; | ||
61 | |||
62 | if (memblock_reserve(addr, size)) | ||
63 | return NULL; | ||
64 | |||
65 | ptr = phys_to_virt(addr); | ||
66 | memset(ptr, 0, size); | ||
67 | /* | ||
68 | * The min_count is set to 0 so that bootmem allocated blocks | ||
69 | * are never reported as leaks. | ||
70 | */ | ||
71 | kmemleak_alloc(ptr, size, 0, 0); | ||
72 | return ptr; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * free_bootmem_late - free bootmem pages directly to page allocator | ||
77 | * @addr: starting address of the range | ||
78 | * @size: size of the range in bytes | ||
79 | * | ||
80 | * This is only useful when the bootmem allocator has already been torn | ||
81 | * down, but we are still initializing the system. Pages are given directly | ||
82 | * to the page allocator, no bootmem metadata is updated because it is gone. | ||
83 | */ | ||
84 | void __init free_bootmem_late(unsigned long addr, unsigned long size) | ||
85 | { | ||
86 | unsigned long cursor, end; | ||
87 | |||
88 | kmemleak_free_part_phys(addr, size); | ||
89 | |||
90 | cursor = PFN_UP(addr); | ||
91 | end = PFN_DOWN(addr + size); | ||
92 | |||
93 | for (; cursor < end; cursor++) { | ||
94 | __free_pages_bootmem(pfn_to_page(cursor), cursor, 0); | ||
95 | totalram_pages++; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | static void __init __free_pages_memory(unsigned long start, unsigned long end) | ||
100 | { | ||
101 | int order; | ||
102 | |||
103 | while (start < end) { | ||
104 | order = min(MAX_ORDER - 1UL, __ffs(start)); | ||
105 | |||
106 | while (start + (1UL << order) > end) | ||
107 | order--; | ||
108 | |||
109 | __free_pages_bootmem(pfn_to_page(start), start, order); | ||
110 | |||
111 | start += (1UL << order); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | static unsigned long __init __free_memory_core(phys_addr_t start, | ||
116 | phys_addr_t end) | ||
117 | { | ||
118 | unsigned long start_pfn = PFN_UP(start); | ||
119 | unsigned long end_pfn = min_t(unsigned long, | ||
120 | PFN_DOWN(end), max_low_pfn); | ||
121 | |||
122 | if (start_pfn >= end_pfn) | ||
123 | return 0; | ||
124 | |||
125 | __free_pages_memory(start_pfn, end_pfn); | ||
126 | |||
127 | return end_pfn - start_pfn; | ||
128 | } | ||
129 | |||
130 | static unsigned long __init free_low_memory_core_early(void) | ||
131 | { | ||
132 | unsigned long count = 0; | ||
133 | phys_addr_t start, end; | ||
134 | u64 i; | ||
135 | |||
136 | memblock_clear_hotplug(0, -1); | ||
137 | |||
138 | for_each_reserved_mem_region(i, &start, &end) | ||
139 | reserve_bootmem_region(start, end); | ||
140 | |||
141 | /* | ||
142 | * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id | ||
143 | * because in some case like Node0 doesn't have RAM installed | ||
144 | * low ram will be on Node1 | ||
145 | */ | ||
146 | for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end, | ||
147 | NULL) | ||
148 | count += __free_memory_core(start, end); | ||
149 | |||
150 | return count; | ||
151 | } | ||
152 | |||
153 | static int reset_managed_pages_done __initdata; | ||
154 | |||
155 | void reset_node_managed_pages(pg_data_t *pgdat) | ||
156 | { | ||
157 | struct zone *z; | ||
158 | |||
159 | for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) | ||
160 | z->managed_pages = 0; | ||
161 | } | ||
162 | |||
163 | void __init reset_all_zones_managed_pages(void) | ||
164 | { | ||
165 | struct pglist_data *pgdat; | ||
166 | |||
167 | if (reset_managed_pages_done) | ||
168 | return; | ||
169 | |||
170 | for_each_online_pgdat(pgdat) | ||
171 | reset_node_managed_pages(pgdat); | ||
172 | |||
173 | reset_managed_pages_done = 1; | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * free_all_bootmem - release free pages to the buddy allocator | ||
178 | * | ||
179 | * Return: the number of pages actually released. | ||
180 | */ | ||
181 | unsigned long __init free_all_bootmem(void) | ||
182 | { | ||
183 | unsigned long pages; | ||
184 | |||
185 | reset_all_zones_managed_pages(); | ||
186 | |||
187 | pages = free_low_memory_core_early(); | ||
188 | totalram_pages += pages; | ||
189 | |||
190 | return pages; | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * free_bootmem_node - mark a page range as usable | ||
195 | * @pgdat: node the range resides on | ||
196 | * @physaddr: starting physical address of the range | ||
197 | * @size: size of the range in bytes | ||
198 | * | ||
199 | * Partial pages will be considered reserved and left as they are. | ||
200 | * | ||
201 | * The range must reside completely on the specified node. | ||
202 | */ | ||
203 | void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, | ||
204 | unsigned long size) | ||
205 | { | ||
206 | memblock_free(physaddr, size); | ||
207 | } | ||
208 | |||
209 | /** | ||
210 | * free_bootmem - mark a page range as usable | ||
211 | * @addr: starting physical address of the range | ||
212 | * @size: size of the range in bytes | ||
213 | * | ||
214 | * Partial pages will be considered reserved and left as they are. | ||
215 | * | ||
216 | * The range must be contiguous but may span node boundaries. | ||
217 | */ | ||
218 | void __init free_bootmem(unsigned long addr, unsigned long size) | ||
219 | { | ||
220 | memblock_free(addr, size); | ||
221 | } | ||
222 | |||
223 | static void * __init ___alloc_bootmem_nopanic(unsigned long size, | ||
224 | unsigned long align, | ||
225 | unsigned long goal, | ||
226 | unsigned long limit) | ||
227 | { | ||
228 | void *ptr; | ||
229 | |||
230 | if (WARN_ON_ONCE(slab_is_available())) | ||
231 | return kzalloc(size, GFP_NOWAIT); | ||
232 | |||
233 | restart: | ||
234 | |||
235 | ptr = __alloc_memory_core_early(NUMA_NO_NODE, size, align, goal, limit); | ||
236 | |||
237 | if (ptr) | ||
238 | return ptr; | ||
239 | |||
240 | if (goal != 0) { | ||
241 | goal = 0; | ||
242 | goto restart; | ||
243 | } | ||
244 | |||
245 | return NULL; | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * __alloc_bootmem_nopanic - allocate boot memory without panicking | ||
250 | * @size: size of the request in bytes | ||
251 | * @align: alignment of the region | ||
252 | * @goal: preferred starting address of the region | ||
253 | * | ||
254 | * The goal is dropped if it can not be satisfied and the allocation will | ||
255 | * fall back to memory below @goal. | ||
256 | * | ||
257 | * Allocation may happen on any node in the system. | ||
258 | * | ||
259 | * Return: address of the allocated region or %NULL on failure. | ||
260 | */ | ||
261 | void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align, | ||
262 | unsigned long goal) | ||
263 | { | ||
264 | unsigned long limit = -1UL; | ||
265 | |||
266 | return ___alloc_bootmem_nopanic(size, align, goal, limit); | ||
267 | } | ||
268 | |||
269 | static void * __init ___alloc_bootmem(unsigned long size, unsigned long align, | ||
270 | unsigned long goal, unsigned long limit) | ||
271 | { | ||
272 | void *mem = ___alloc_bootmem_nopanic(size, align, goal, limit); | ||
273 | |||
274 | if (mem) | ||
275 | return mem; | ||
276 | /* | ||
277 | * Whoops, we cannot satisfy the allocation request. | ||
278 | */ | ||
279 | pr_alert("bootmem alloc of %lu bytes failed!\n", size); | ||
280 | panic("Out of memory"); | ||
281 | return NULL; | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * __alloc_bootmem - allocate boot memory | ||
286 | * @size: size of the request in bytes | ||
287 | * @align: alignment of the region | ||
288 | * @goal: preferred starting address of the region | ||
289 | * | ||
290 | * The goal is dropped if it can not be satisfied and the allocation will | ||
291 | * fall back to memory below @goal. | ||
292 | * | ||
293 | * Allocation may happen on any node in the system. | ||
294 | * | ||
295 | * The function panics if the request can not be satisfied. | ||
296 | * | ||
297 | * Return: address of the allocated region. | ||
298 | */ | ||
299 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, | ||
300 | unsigned long goal) | ||
301 | { | ||
302 | unsigned long limit = -1UL; | ||
303 | |||
304 | return ___alloc_bootmem(size, align, goal, limit); | ||
305 | } | ||
306 | |||
307 | void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat, | ||
308 | unsigned long size, | ||
309 | unsigned long align, | ||
310 | unsigned long goal, | ||
311 | unsigned long limit) | ||
312 | { | ||
313 | void *ptr; | ||
314 | |||
315 | again: | ||
316 | ptr = __alloc_memory_core_early(pgdat->node_id, size, align, | ||
317 | goal, limit); | ||
318 | if (ptr) | ||
319 | return ptr; | ||
320 | |||
321 | ptr = __alloc_memory_core_early(NUMA_NO_NODE, size, align, | ||
322 | goal, limit); | ||
323 | if (ptr) | ||
324 | return ptr; | ||
325 | |||
326 | if (goal) { | ||
327 | goal = 0; | ||
328 | goto again; | ||
329 | } | ||
330 | |||
331 | return NULL; | ||
332 | } | ||
333 | |||
334 | void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size, | ||
335 | unsigned long align, unsigned long goal) | ||
336 | { | ||
337 | if (WARN_ON_ONCE(slab_is_available())) | ||
338 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
339 | |||
340 | return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0); | ||
341 | } | ||
342 | |||
343 | static void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, | ||
344 | unsigned long align, unsigned long goal, | ||
345 | unsigned long limit) | ||
346 | { | ||
347 | void *ptr; | ||
348 | |||
349 | ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, limit); | ||
350 | if (ptr) | ||
351 | return ptr; | ||
352 | |||
353 | pr_alert("bootmem alloc of %lu bytes failed!\n", size); | ||
354 | panic("Out of memory"); | ||
355 | return NULL; | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * __alloc_bootmem_node - allocate boot memory from a specific node | ||
360 | * @pgdat: node to allocate from | ||
361 | * @size: size of the request in bytes | ||
362 | * @align: alignment of the region | ||
363 | * @goal: preferred starting address of the region | ||
364 | * | ||
365 | * The goal is dropped if it can not be satisfied and the allocation will | ||
366 | * fall back to memory below @goal. | ||
367 | * | ||
368 | * Allocation may fall back to any node in the system if the specified node | ||
369 | * can not hold the requested memory. | ||
370 | * | ||
371 | * The function panics if the request can not be satisfied. | ||
372 | * | ||
373 | * Return: address of the allocated region. | ||
374 | */ | ||
375 | void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, | ||
376 | unsigned long align, unsigned long goal) | ||
377 | { | ||
378 | if (WARN_ON_ONCE(slab_is_available())) | ||
379 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
380 | |||
381 | return ___alloc_bootmem_node(pgdat, size, align, goal, 0); | ||
382 | } | ||
383 | |||
384 | void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size, | ||
385 | unsigned long align, unsigned long goal) | ||
386 | { | ||
387 | return __alloc_bootmem_node(pgdat, size, align, goal); | ||
388 | } | ||
389 | |||
390 | |||
391 | /** | ||
392 | * __alloc_bootmem_low - allocate low boot memory | ||
393 | * @size: size of the request in bytes | ||
394 | * @align: alignment of the region | ||
395 | * @goal: preferred starting address of the region | ||
396 | * | ||
397 | * The goal is dropped if it can not be satisfied and the allocation will | ||
398 | * fall back to memory below @goal. | ||
399 | * | ||
400 | * Allocation may happen on any node in the system. | ||
401 | * | ||
402 | * The function panics if the request can not be satisfied. | ||
403 | * | ||
404 | * Return: address of the allocated region. | ||
405 | */ | ||
406 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, | ||
407 | unsigned long goal) | ||
408 | { | ||
409 | return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT); | ||
410 | } | ||
411 | |||
412 | void * __init __alloc_bootmem_low_nopanic(unsigned long size, | ||
413 | unsigned long align, | ||
414 | unsigned long goal) | ||
415 | { | ||
416 | return ___alloc_bootmem_nopanic(size, align, goal, | ||
417 | ARCH_LOW_ADDRESS_LIMIT); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * __alloc_bootmem_low_node - allocate low boot memory from a specific node | ||
422 | * @pgdat: node to allocate from | ||
423 | * @size: size of the request in bytes | ||
424 | * @align: alignment of the region | ||
425 | * @goal: preferred starting address of the region | ||
426 | * | ||
427 | * The goal is dropped if it can not be satisfied and the allocation will | ||
428 | * fall back to memory below @goal. | ||
429 | * | ||
430 | * Allocation may fall back to any node in the system if the specified node | ||
431 | * can not hold the requested memory. | ||
432 | * | ||
433 | * The function panics if the request can not be satisfied. | ||
434 | * | ||
435 | * Return: address of the allocated region. | ||
436 | */ | ||
437 | void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, | ||
438 | unsigned long align, unsigned long goal) | ||
439 | { | ||
440 | if (WARN_ON_ONCE(slab_is_available())) | ||
441 | return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); | ||
442 | |||
443 | return ___alloc_bootmem_node(pgdat, size, align, goal, | ||
444 | ARCH_LOW_ADDRESS_LIMIT); | ||
445 | } | ||
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 863d46da6586..a919ba5cb3c8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/pagemap.h> | 21 | #include <linux/pagemap.h> |
22 | #include <linux/jiffies.h> | 22 | #include <linux/jiffies.h> |
23 | #include <linux/bootmem.h> | ||
24 | #include <linux/memblock.h> | 23 | #include <linux/memblock.h> |
25 | #include <linux/compiler.h> | 24 | #include <linux/compiler.h> |
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -1339,7 +1338,7 @@ meminit_pfn_in_nid(unsigned long pfn, int node, | |||
1339 | #endif | 1338 | #endif |
1340 | 1339 | ||
1341 | 1340 | ||
1342 | void __init __free_pages_bootmem(struct page *page, unsigned long pfn, | 1341 | void __init memblock_free_pages(struct page *page, unsigned long pfn, |
1343 | unsigned int order) | 1342 | unsigned int order) |
1344 | { | 1343 | { |
1345 | if (early_page_uninitialised(pfn)) | 1344 | if (early_page_uninitialised(pfn)) |
@@ -5476,7 +5475,7 @@ overlap_memmap_init(unsigned long zone, unsigned long *pfn) | |||
5476 | 5475 | ||
5477 | /* | 5476 | /* |
5478 | * Initially all pages are reserved - free ones are freed | 5477 | * Initially all pages are reserved - free ones are freed |
5479 | * up by free_all_bootmem() once the early boot process is | 5478 | * up by memblock_free_all() once the early boot process is |
5480 | * done. Non-atomic initialization, single-pass. | 5479 | * done. Non-atomic initialization, single-pass. |
5481 | */ | 5480 | */ |
5482 | void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, | 5481 | void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, |
@@ -6209,7 +6208,7 @@ static void __ref setup_usemap(struct pglist_data *pgdat, | |||
6209 | zone->pageblock_flags = NULL; | 6208 | zone->pageblock_flags = NULL; |
6210 | if (usemapsize) | 6209 | if (usemapsize) |
6211 | zone->pageblock_flags = | 6210 | zone->pageblock_flags = |
6212 | memblock_virt_alloc_node_nopanic(usemapsize, | 6211 | memblock_alloc_node_nopanic(usemapsize, |
6213 | pgdat->node_id); | 6212 | pgdat->node_id); |
6214 | } | 6213 | } |
6215 | #else | 6214 | #else |
@@ -6439,7 +6438,7 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) | |||
6439 | end = pgdat_end_pfn(pgdat); | 6438 | end = pgdat_end_pfn(pgdat); |
6440 | end = ALIGN(end, MAX_ORDER_NR_PAGES); | 6439 | end = ALIGN(end, MAX_ORDER_NR_PAGES); |
6441 | size = (end - start) * sizeof(struct page); | 6440 | size = (end - start) * sizeof(struct page); |
6442 | map = memblock_virt_alloc_node_nopanic(size, pgdat->node_id); | 6441 | map = memblock_alloc_node_nopanic(size, pgdat->node_id); |
6443 | pgdat->node_mem_map = map + offset; | 6442 | pgdat->node_mem_map = map + offset; |
6444 | } | 6443 | } |
6445 | pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n", | 6444 | pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n", |
@@ -6508,8 +6507,7 @@ void __init free_area_init_node(int nid, unsigned long *zones_size, | |||
6508 | free_area_init_core(pgdat); | 6507 | free_area_init_core(pgdat); |
6509 | } | 6508 | } |
6510 | 6509 | ||
6511 | #if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP) | 6510 | #if !defined(CONFIG_FLAT_NODE_MEM_MAP) |
6512 | |||
6513 | /* | 6511 | /* |
6514 | * Zero all valid struct pages in range [spfn, epfn), return number of struct | 6512 | * Zero all valid struct pages in range [spfn, epfn), return number of struct |
6515 | * pages zeroed | 6513 | * pages zeroed |
@@ -6569,7 +6567,7 @@ void __init zero_resv_unavail(void) | |||
6569 | if (pgcnt) | 6567 | if (pgcnt) |
6570 | pr_info("Zeroed struct page in unavailable ranges: %lld pages", pgcnt); | 6568 | pr_info("Zeroed struct page in unavailable ranges: %lld pages", pgcnt); |
6571 | } | 6569 | } |
6572 | #endif /* CONFIG_HAVE_MEMBLOCK && !CONFIG_FLAT_NODE_MEM_MAP */ | 6570 | #endif /* !CONFIG_FLAT_NODE_MEM_MAP */ |
6573 | 6571 | ||
6574 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 6572 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
6575 | 6573 | ||
@@ -7712,9 +7710,11 @@ void *__init alloc_large_system_hash(const char *tablename, | |||
7712 | size = bucketsize << log2qty; | 7710 | size = bucketsize << log2qty; |
7713 | if (flags & HASH_EARLY) { | 7711 | if (flags & HASH_EARLY) { |
7714 | if (flags & HASH_ZERO) | 7712 | if (flags & HASH_ZERO) |
7715 | table = memblock_virt_alloc_nopanic(size, 0); | 7713 | table = memblock_alloc_nopanic(size, |
7714 | SMP_CACHE_BYTES); | ||
7716 | else | 7715 | else |
7717 | table = memblock_virt_alloc_raw(size, 0); | 7716 | table = memblock_alloc_raw(size, |
7717 | SMP_CACHE_BYTES); | ||
7718 | } else if (hashdist) { | 7718 | } else if (hashdist) { |
7719 | table = __vmalloc(size, gfp_flags, PAGE_KERNEL); | 7719 | table = __vmalloc(size, gfp_flags, PAGE_KERNEL); |
7720 | } else { | 7720 | } else { |
diff --git a/mm/page_ext.c b/mm/page_ext.c index a9826da84ccb..ae44f7adbe07 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c | |||
@@ -1,7 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | #include <linux/mm.h> | 2 | #include <linux/mm.h> |
3 | #include <linux/mmzone.h> | 3 | #include <linux/mmzone.h> |
4 | #include <linux/bootmem.h> | 4 | #include <linux/memblock.h> |
5 | #include <linux/page_ext.h> | 5 | #include <linux/page_ext.h> |
6 | #include <linux/memory.h> | 6 | #include <linux/memory.h> |
7 | #include <linux/vmalloc.h> | 7 | #include <linux/vmalloc.h> |
@@ -161,9 +161,9 @@ static int __init alloc_node_page_ext(int nid) | |||
161 | 161 | ||
162 | table_size = get_entry_size() * nr_pages; | 162 | table_size = get_entry_size() * nr_pages; |
163 | 163 | ||
164 | base = memblock_virt_alloc_try_nid_nopanic( | 164 | base = memblock_alloc_try_nid_nopanic( |
165 | table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), | 165 | table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), |
166 | BOOTMEM_ALLOC_ACCESSIBLE, nid); | 166 | MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
167 | if (!base) | 167 | if (!base) |
168 | return -ENOMEM; | 168 | return -ENOMEM; |
169 | NODE_DATA(nid)->node_page_ext = base; | 169 | NODE_DATA(nid)->node_page_ext = base; |
diff --git a/mm/page_idle.c b/mm/page_idle.c index 6302bc62c27d..b9e4b42b33ab 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c | |||
@@ -1,6 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | #include <linux/init.h> | 2 | #include <linux/init.h> |
3 | #include <linux/bootmem.h> | 3 | #include <linux/memblock.h> |
4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
5 | #include <linux/sysfs.h> | 5 | #include <linux/sysfs.h> |
6 | #include <linux/kobject.h> | 6 | #include <linux/kobject.h> |
diff --git a/mm/page_owner.c b/mm/page_owner.c index d80adfe702d3..87bc0dfdb52b 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <linux/mm.h> | 3 | #include <linux/mm.h> |
4 | #include <linux/slab.h> | 4 | #include <linux/slab.h> |
5 | #include <linux/uaccess.h> | 5 | #include <linux/uaccess.h> |
6 | #include <linux/bootmem.h> | 6 | #include <linux/memblock.h> |
7 | #include <linux/stacktrace.h> | 7 | #include <linux/stacktrace.h> |
8 | #include <linux/page_owner.h> | 8 | #include <linux/page_owner.h> |
9 | #include <linux/jump_label.h> | 9 | #include <linux/jump_label.h> |
diff --git a/mm/page_poison.c b/mm/page_poison.c index aa2b3d34e8ea..f7e2a676365a 100644 --- a/mm/page_poison.c +++ b/mm/page_poison.c | |||
@@ -21,7 +21,7 @@ bool page_poisoning_enabled(void) | |||
21 | { | 21 | { |
22 | /* | 22 | /* |
23 | * Assumes that debug_pagealloc_enabled is set before | 23 | * Assumes that debug_pagealloc_enabled is set before |
24 | * free_all_bootmem. | 24 | * memblock_free_all. |
25 | * Page poisoning is debug page alloc for some arches. If | 25 | * Page poisoning is debug page alloc for some arches. If |
26 | * either of those options are enabled, enable poisoning. | 26 | * either of those options are enabled, enable poisoning. |
27 | */ | 27 | */ |
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index ae3c2a35d61b..11df03e71288 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c | |||
@@ -21,7 +21,29 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw) | |||
21 | if (!is_swap_pte(*pvmw->pte)) | 21 | if (!is_swap_pte(*pvmw->pte)) |
22 | return false; | 22 | return false; |
23 | } else { | 23 | } else { |
24 | if (!pte_present(*pvmw->pte)) | 24 | /* |
25 | * We get here when we are trying to unmap a private | ||
26 | * device page from the process address space. Such | ||
27 | * page is not CPU accessible and thus is mapped as | ||
28 | * a special swap entry, nonetheless it still does | ||
29 | * count as a valid regular mapping for the page (and | ||
30 | * is accounted as such in page maps count). | ||
31 | * | ||
32 | * So handle this special case as if it was a normal | ||
33 | * page mapping ie lock CPU page table and returns | ||
34 | * true. | ||
35 | * | ||
36 | * For more details on device private memory see HMM | ||
37 | * (include/linux/hmm.h or mm/hmm.c). | ||
38 | */ | ||
39 | if (is_swap_pte(*pvmw->pte)) { | ||
40 | swp_entry_t entry; | ||
41 | |||
42 | /* Handle un-addressable ZONE_DEVICE memory */ | ||
43 | entry = pte_to_swp_entry(*pvmw->pte); | ||
44 | if (!is_device_private_entry(entry)) | ||
45 | return false; | ||
46 | } else if (!pte_present(*pvmw->pte)) | ||
25 | return false; | 47 | return false; |
26 | } | 48 | } |
27 | } | 49 | } |
diff --git a/mm/percpu.c b/mm/percpu.c index 4b90682623e9..a6b74c6fe0be 100644 --- a/mm/percpu.c +++ b/mm/percpu.c | |||
@@ -65,7 +65,7 @@ | |||
65 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 65 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
66 | 66 | ||
67 | #include <linux/bitmap.h> | 67 | #include <linux/bitmap.h> |
68 | #include <linux/bootmem.h> | 68 | #include <linux/memblock.h> |
69 | #include <linux/err.h> | 69 | #include <linux/err.h> |
70 | #include <linux/lcm.h> | 70 | #include <linux/lcm.h> |
71 | #include <linux/list.h> | 71 | #include <linux/list.h> |
@@ -1101,9 +1101,9 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, | |||
1101 | region_size = ALIGN(start_offset + map_size, lcm_align); | 1101 | region_size = ALIGN(start_offset + map_size, lcm_align); |
1102 | 1102 | ||
1103 | /* allocate chunk */ | 1103 | /* allocate chunk */ |
1104 | chunk = memblock_virt_alloc(sizeof(struct pcpu_chunk) + | 1104 | chunk = memblock_alloc(sizeof(struct pcpu_chunk) + |
1105 | BITS_TO_LONGS(region_size >> PAGE_SHIFT), | 1105 | BITS_TO_LONGS(region_size >> PAGE_SHIFT), |
1106 | 0); | 1106 | SMP_CACHE_BYTES); |
1107 | 1107 | ||
1108 | INIT_LIST_HEAD(&chunk->list); | 1108 | INIT_LIST_HEAD(&chunk->list); |
1109 | 1109 | ||
@@ -1114,12 +1114,12 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, | |||
1114 | chunk->nr_pages = region_size >> PAGE_SHIFT; | 1114 | chunk->nr_pages = region_size >> PAGE_SHIFT; |
1115 | region_bits = pcpu_chunk_map_bits(chunk); | 1115 | region_bits = pcpu_chunk_map_bits(chunk); |
1116 | 1116 | ||
1117 | chunk->alloc_map = memblock_virt_alloc(BITS_TO_LONGS(region_bits) * | 1117 | chunk->alloc_map = memblock_alloc(BITS_TO_LONGS(region_bits) * sizeof(chunk->alloc_map[0]), |
1118 | sizeof(chunk->alloc_map[0]), 0); | 1118 | SMP_CACHE_BYTES); |
1119 | chunk->bound_map = memblock_virt_alloc(BITS_TO_LONGS(region_bits + 1) * | 1119 | chunk->bound_map = memblock_alloc(BITS_TO_LONGS(region_bits + 1) * sizeof(chunk->bound_map[0]), |
1120 | sizeof(chunk->bound_map[0]), 0); | 1120 | SMP_CACHE_BYTES); |
1121 | chunk->md_blocks = memblock_virt_alloc(pcpu_chunk_nr_blocks(chunk) * | 1121 | chunk->md_blocks = memblock_alloc(pcpu_chunk_nr_blocks(chunk) * sizeof(chunk->md_blocks[0]), |
1122 | sizeof(chunk->md_blocks[0]), 0); | 1122 | SMP_CACHE_BYTES); |
1123 | pcpu_init_md_blocks(chunk); | 1123 | pcpu_init_md_blocks(chunk); |
1124 | 1124 | ||
1125 | /* manage populated page bitmap */ | 1125 | /* manage populated page bitmap */ |
@@ -1888,7 +1888,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups, | |||
1888 | __alignof__(ai->groups[0].cpu_map[0])); | 1888 | __alignof__(ai->groups[0].cpu_map[0])); |
1889 | ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]); | 1889 | ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]); |
1890 | 1890 | ||
1891 | ptr = memblock_virt_alloc_nopanic(PFN_ALIGN(ai_size), PAGE_SIZE); | 1891 | ptr = memblock_alloc_nopanic(PFN_ALIGN(ai_size), PAGE_SIZE); |
1892 | if (!ptr) | 1892 | if (!ptr) |
1893 | return NULL; | 1893 | return NULL; |
1894 | ai = ptr; | 1894 | ai = ptr; |
@@ -2075,12 +2075,14 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, | |||
2075 | PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0); | 2075 | PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0); |
2076 | 2076 | ||
2077 | /* process group information and build config tables accordingly */ | 2077 | /* process group information and build config tables accordingly */ |
2078 | group_offsets = memblock_virt_alloc(ai->nr_groups * | 2078 | group_offsets = memblock_alloc(ai->nr_groups * sizeof(group_offsets[0]), |
2079 | sizeof(group_offsets[0]), 0); | 2079 | SMP_CACHE_BYTES); |
2080 | group_sizes = memblock_virt_alloc(ai->nr_groups * | 2080 | group_sizes = memblock_alloc(ai->nr_groups * sizeof(group_sizes[0]), |
2081 | sizeof(group_sizes[0]), 0); | 2081 | SMP_CACHE_BYTES); |
2082 | unit_map = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_map[0]), 0); | 2082 | unit_map = memblock_alloc(nr_cpu_ids * sizeof(unit_map[0]), |
2083 | unit_off = memblock_virt_alloc(nr_cpu_ids * sizeof(unit_off[0]), 0); | 2083 | SMP_CACHE_BYTES); |
2084 | unit_off = memblock_alloc(nr_cpu_ids * sizeof(unit_off[0]), | ||
2085 | SMP_CACHE_BYTES); | ||
2084 | 2086 | ||
2085 | for (cpu = 0; cpu < nr_cpu_ids; cpu++) | 2087 | for (cpu = 0; cpu < nr_cpu_ids; cpu++) |
2086 | unit_map[cpu] = UINT_MAX; | 2088 | unit_map[cpu] = UINT_MAX; |
@@ -2144,8 +2146,8 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, | |||
2144 | * empty chunks. | 2146 | * empty chunks. |
2145 | */ | 2147 | */ |
2146 | pcpu_nr_slots = __pcpu_size_to_slot(pcpu_unit_size) + 2; | 2148 | pcpu_nr_slots = __pcpu_size_to_slot(pcpu_unit_size) + 2; |
2147 | pcpu_slot = memblock_virt_alloc( | 2149 | pcpu_slot = memblock_alloc(pcpu_nr_slots * sizeof(pcpu_slot[0]), |
2148 | pcpu_nr_slots * sizeof(pcpu_slot[0]), 0); | 2150 | SMP_CACHE_BYTES); |
2149 | for (i = 0; i < pcpu_nr_slots; i++) | 2151 | for (i = 0; i < pcpu_nr_slots; i++) |
2150 | INIT_LIST_HEAD(&pcpu_slot[i]); | 2152 | INIT_LIST_HEAD(&pcpu_slot[i]); |
2151 | 2153 | ||
@@ -2458,7 +2460,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size, | |||
2458 | size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; | 2460 | size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; |
2459 | areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *)); | 2461 | areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *)); |
2460 | 2462 | ||
2461 | areas = memblock_virt_alloc_nopanic(areas_size, 0); | 2463 | areas = memblock_alloc_nopanic(areas_size, SMP_CACHE_BYTES); |
2462 | if (!areas) { | 2464 | if (!areas) { |
2463 | rc = -ENOMEM; | 2465 | rc = -ENOMEM; |
2464 | goto out_free; | 2466 | goto out_free; |
@@ -2599,7 +2601,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size, | |||
2599 | /* unaligned allocations can't be freed, round up to page size */ | 2601 | /* unaligned allocations can't be freed, round up to page size */ |
2600 | pages_size = PFN_ALIGN(unit_pages * num_possible_cpus() * | 2602 | pages_size = PFN_ALIGN(unit_pages * num_possible_cpus() * |
2601 | sizeof(pages[0])); | 2603 | sizeof(pages[0])); |
2602 | pages = memblock_virt_alloc(pages_size, 0); | 2604 | pages = memblock_alloc(pages_size, SMP_CACHE_BYTES); |
2603 | 2605 | ||
2604 | /* allocate pages */ | 2606 | /* allocate pages */ |
2605 | j = 0; | 2607 | j = 0; |
@@ -2688,7 +2690,7 @@ EXPORT_SYMBOL(__per_cpu_offset); | |||
2688 | static void * __init pcpu_dfl_fc_alloc(unsigned int cpu, size_t size, | 2690 | static void * __init pcpu_dfl_fc_alloc(unsigned int cpu, size_t size, |
2689 | size_t align) | 2691 | size_t align) |
2690 | { | 2692 | { |
2691 | return memblock_virt_alloc_from_nopanic( | 2693 | return memblock_alloc_from_nopanic( |
2692 | size, align, __pa(MAX_DMA_ADDRESS)); | 2694 | size, align, __pa(MAX_DMA_ADDRESS)); |
2693 | } | 2695 | } |
2694 | 2696 | ||
@@ -2737,7 +2739,7 @@ void __init setup_per_cpu_areas(void) | |||
2737 | void *fc; | 2739 | void *fc; |
2738 | 2740 | ||
2739 | ai = pcpu_alloc_alloc_info(1, 1); | 2741 | ai = pcpu_alloc_alloc_info(1, 1); |
2740 | fc = memblock_virt_alloc_from_nopanic(unit_size, | 2742 | fc = memblock_alloc_from_nopanic(unit_size, |
2741 | PAGE_SIZE, | 2743 | PAGE_SIZE, |
2742 | __pa(MAX_DMA_ADDRESS)); | 2744 | __pa(MAX_DMA_ADDRESS)); |
2743 | if (!ai || !fc) | 2745 | if (!ai || !fc) |
diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index 8301293331a2..7fec05796796 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c | |||
@@ -20,7 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/mmzone.h> | 22 | #include <linux/mmzone.h> |
23 | #include <linux/bootmem.h> | 23 | #include <linux/memblock.h> |
24 | #include <linux/memremap.h> | 24 | #include <linux/memremap.h> |
25 | #include <linux/highmem.h> | 25 | #include <linux/highmem.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
@@ -42,8 +42,8 @@ static void * __ref __earlyonly_bootmem_alloc(int node, | |||
42 | unsigned long align, | 42 | unsigned long align, |
43 | unsigned long goal) | 43 | unsigned long goal) |
44 | { | 44 | { |
45 | return memblock_virt_alloc_try_nid_raw(size, align, goal, | 45 | return memblock_alloc_try_nid_raw(size, align, goal, |
46 | BOOTMEM_ALLOC_ACCESSIBLE, node); | 46 | MEMBLOCK_ALLOC_ACCESSIBLE, node); |
47 | } | 47 | } |
48 | 48 | ||
49 | void * __meminit vmemmap_alloc_block(unsigned long size, int node) | 49 | void * __meminit vmemmap_alloc_block(unsigned long size, int node) |
diff --git a/mm/sparse.c b/mm/sparse.c index 67ad061f7fb8..33307fc05c4d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/mm.h> | 5 | #include <linux/mm.h> |
6 | #include <linux/slab.h> | 6 | #include <linux/slab.h> |
7 | #include <linux/mmzone.h> | 7 | #include <linux/mmzone.h> |
8 | #include <linux/bootmem.h> | 8 | #include <linux/memblock.h> |
9 | #include <linux/compiler.h> | 9 | #include <linux/compiler.h> |
10 | #include <linux/highmem.h> | 10 | #include <linux/highmem.h> |
11 | #include <linux/export.h> | 11 | #include <linux/export.h> |
@@ -68,7 +68,8 @@ static noinline struct mem_section __ref *sparse_index_alloc(int nid) | |||
68 | if (slab_is_available()) | 68 | if (slab_is_available()) |
69 | section = kzalloc_node(array_size, GFP_KERNEL, nid); | 69 | section = kzalloc_node(array_size, GFP_KERNEL, nid); |
70 | else | 70 | else |
71 | section = memblock_virt_alloc_node(array_size, nid); | 71 | section = memblock_alloc_node(array_size, SMP_CACHE_BYTES, |
72 | nid); | ||
72 | 73 | ||
73 | return section; | 74 | return section; |
74 | } | 75 | } |
@@ -216,7 +217,7 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) | |||
216 | 217 | ||
217 | size = sizeof(struct mem_section*) * NR_SECTION_ROOTS; | 218 | size = sizeof(struct mem_section*) * NR_SECTION_ROOTS; |
218 | align = 1 << (INTERNODE_CACHE_SHIFT); | 219 | align = 1 << (INTERNODE_CACHE_SHIFT); |
219 | mem_section = memblock_virt_alloc(size, align); | 220 | mem_section = memblock_alloc(size, align); |
220 | } | 221 | } |
221 | #endif | 222 | #endif |
222 | 223 | ||
@@ -306,7 +307,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, | |||
306 | limit = goal + (1UL << PA_SECTION_SHIFT); | 307 | limit = goal + (1UL << PA_SECTION_SHIFT); |
307 | nid = early_pfn_to_nid(goal >> PAGE_SHIFT); | 308 | nid = early_pfn_to_nid(goal >> PAGE_SHIFT); |
308 | again: | 309 | again: |
309 | p = memblock_virt_alloc_try_nid_nopanic(size, | 310 | p = memblock_alloc_try_nid_nopanic(size, |
310 | SMP_CACHE_BYTES, goal, limit, | 311 | SMP_CACHE_BYTES, goal, limit, |
311 | nid); | 312 | nid); |
312 | if (!p && limit) { | 313 | if (!p && limit) { |
@@ -362,7 +363,7 @@ static unsigned long * __init | |||
362 | sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, | 363 | sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, |
363 | unsigned long size) | 364 | unsigned long size) |
364 | { | 365 | { |
365 | return memblock_virt_alloc_node_nopanic(size, pgdat->node_id); | 366 | return memblock_alloc_node_nopanic(size, pgdat->node_id); |
366 | } | 367 | } |
367 | 368 | ||
368 | static void __init check_usemap_section_nr(int nid, unsigned long *usemap) | 369 | static void __init check_usemap_section_nr(int nid, unsigned long *usemap) |
@@ -391,9 +392,9 @@ struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid, | |||
391 | if (map) | 392 | if (map) |
392 | return map; | 393 | return map; |
393 | 394 | ||
394 | map = memblock_virt_alloc_try_nid(size, | 395 | map = memblock_alloc_try_nid(size, |
395 | PAGE_SIZE, __pa(MAX_DMA_ADDRESS), | 396 | PAGE_SIZE, __pa(MAX_DMA_ADDRESS), |
396 | BOOTMEM_ALLOC_ACCESSIBLE, nid); | 397 | MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
397 | return map; | 398 | return map; |
398 | } | 399 | } |
399 | #endif /* !CONFIG_SPARSEMEM_VMEMMAP */ | 400 | #endif /* !CONFIG_SPARSEMEM_VMEMMAP */ |
@@ -405,9 +406,9 @@ static void __init sparse_buffer_init(unsigned long size, int nid) | |||
405 | { | 406 | { |
406 | WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */ | 407 | WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */ |
407 | sparsemap_buf = | 408 | sparsemap_buf = |
408 | memblock_virt_alloc_try_nid_raw(size, PAGE_SIZE, | 409 | memblock_alloc_try_nid_raw(size, PAGE_SIZE, |
409 | __pa(MAX_DMA_ADDRESS), | 410 | __pa(MAX_DMA_ADDRESS), |
410 | BOOTMEM_ALLOC_ACCESSIBLE, nid); | 411 | MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
411 | sparsemap_buf_end = sparsemap_buf + size; | 412 | sparsemap_buf_end = sparsemap_buf + size; |
412 | } | 413 | } |
413 | 414 | ||
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index f5c9ef2586de..411dd7a90046 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/wait.h> | 20 | #include <linux/wait.h> |
21 | #include <linux/vmalloc.h> | 21 | #include <linux/vmalloc.h> |
22 | #include <linux/bootmem.h> | 22 | #include <linux/memblock.h> |
23 | 23 | ||
24 | #include <net/addrconf.h> | 24 | #include <net/addrconf.h> |
25 | #include <net/inet_connection_sock.h> | 25 | #include <net/inet_connection_sock.h> |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1834818ed07b..9e6bc4d6daa7 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -262,7 +262,7 @@ | |||
262 | #include <linux/net.h> | 262 | #include <linux/net.h> |
263 | #include <linux/socket.h> | 263 | #include <linux/socket.h> |
264 | #include <linux/random.h> | 264 | #include <linux/random.h> |
265 | #include <linux/bootmem.h> | 265 | #include <linux/memblock.h> |
266 | #include <linux/highmem.h> | 266 | #include <linux/highmem.h> |
267 | #include <linux/swap.h> | 267 | #include <linux/swap.h> |
268 | #include <linux/cache.h> | 268 | #include <linux/cache.h> |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index ca3ed931f2a9..1976fddb9e00 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -81,7 +81,7 @@ | |||
81 | 81 | ||
82 | #include <linux/uaccess.h> | 82 | #include <linux/uaccess.h> |
83 | #include <asm/ioctls.h> | 83 | #include <asm/ioctls.h> |
84 | #include <linux/bootmem.h> | 84 | #include <linux/memblock.h> |
85 | #include <linux/highmem.h> | 85 | #include <linux/highmem.h> |
86 | #include <linux/swap.h> | 86 | #include <linux/swap.h> |
87 | #include <linux/types.h> | 87 | #include <linux/types.h> |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index e948db29ab53..9b277bd36d1a 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/netdevice.h> | 46 | #include <linux/netdevice.h> |
47 | #include <linux/inetdevice.h> | 47 | #include <linux/inetdevice.h> |
48 | #include <linux/seq_file.h> | 48 | #include <linux/seq_file.h> |
49 | #include <linux/bootmem.h> | 49 | #include <linux/memblock.h> |
50 | #include <linux/highmem.h> | 50 | #include <linux/highmem.h> |
51 | #include <linux/swap.h> | 51 | #include <linux/swap.h> |
52 | #include <linux/slab.h> | 52 | #include <linux/slab.h> |
diff --git a/net/xfrm/xfrm_hash.c b/net/xfrm/xfrm_hash.c index 2ad33ce1ea17..eca8d84d99bf 100644 --- a/net/xfrm/xfrm_hash.c +++ b/net/xfrm/xfrm_hash.c | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
9 | #include <linux/bootmem.h> | 9 | #include <linux/memblock.h> |
10 | #include <linux/vmalloc.h> | 10 | #include <linux/vmalloc.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/xfrm.h> | 12 | #include <linux/xfrm.h> |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 161b0224d6ae..c883ec55654f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -4934,17 +4934,6 @@ sub process { | |||
4934 | while ($line =~ m{($Constant|$Lval)}g) { | 4934 | while ($line =~ m{($Constant|$Lval)}g) { |
4935 | my $var = $1; | 4935 | my $var = $1; |
4936 | 4936 | ||
4937 | #gcc binary extension | ||
4938 | if ($var =~ /^$Binary$/) { | ||
4939 | if (WARN("GCC_BINARY_CONSTANT", | ||
4940 | "Avoid gcc v4.3+ binary constant extension: <$var>\n" . $herecurr) && | ||
4941 | $fix) { | ||
4942 | my $hexval = sprintf("0x%x", oct($var)); | ||
4943 | $fixed[$fixlinenr] =~ | ||
4944 | s/\b$var\b/$hexval/; | ||
4945 | } | ||
4946 | } | ||
4947 | |||
4948 | #CamelCase | 4937 | #CamelCase |
4949 | if ($var !~ /^$Constant$/ && | 4938 | if ($var !~ /^$Constant$/ && |
4950 | $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && | 4939 | $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && |