summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rapoport <rppt@linux.vnet.ibm.com>2018-10-30 18:09:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-31 11:54:16 -0400
commit2a5bda5a624d6471d25e953b9adba5182ab1b51f (patch)
tree79b8c439780895dd7e35ce368d97e4756eef56f1
parent4fc4a09e4cc1126c4e8a86c293425cffa2a2eb3c (diff)
memblock: replace alloc_bootmem with memblock_alloc
The alloc_bootmem(size) is a shortcut for allocation of SMP_CACHE_BYTES aligned memory. When the align parameter of memblock_alloc() is 0, the alignment is implicitly set to SMP_CACHE_BYTES and thus alloc_bootmem(size) and memblock_alloc(size, 0) are equivalent. The conversion is done using the following semantic patch: @@ expression size; @@ - alloc_bootmem(size) + memblock_alloc(size, 0) Link: http://lkml.kernel.org/r/1536927045-23536-22-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Jonas Bonn <jonas@southpole.se> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ley Foon Tan <lftan@altera.com> Cc: Mark Salter <msalter@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@suse.com> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Serge Semin <fancer.lancer@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/alpha/kernel/core_marvel.c4
-rw-r--r--arch/alpha/kernel/pci-noop.c4
-rw-r--r--arch/alpha/kernel/pci.c4
-rw-r--r--arch/alpha/kernel/pci_iommu.c4
-rw-r--r--arch/ia64/kernel/mca.c4
-rw-r--r--arch/ia64/mm/tlb.c4
-rw-r--r--arch/m68k/sun3/sun3dvma.c3
-rw-r--r--arch/microblaze/mm/init.c2
-rw-r--r--arch/mips/kernel/setup.c2
-rw-r--r--arch/um/drivers/net_kern.c2
-rw-r--r--arch/um/drivers/vector_kern.c2
-rw-r--r--arch/um/kernel/initrd.c2
-rw-r--r--arch/x86/kernel/acpi/boot.c3
-rw-r--r--arch/x86/kernel/apic/io_apic.c2
-rw-r--r--arch/x86/kernel/e820.c2
-rw-r--r--arch/x86/platform/olpc/olpc_dt.c2
-rw-r--r--arch/xtensa/platforms/iss/network.c2
-rw-r--r--drivers/macintosh/smu.c2
-rw-r--r--init/main.c4
19 files changed, 28 insertions, 26 deletions
diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
index bdebb8c206f1..1f00c9433b10 100644
--- a/arch/alpha/kernel/core_marvel.c
+++ b/arch/alpha/kernel/core_marvel.c
@@ -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, 0);
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), 0);
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/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index c7c5879869d3..59cbfc2bf2c5 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -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), 0);
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)
44struct resource * __init 44struct resource * __init
45alloc_resource(void) 45alloc_resource(void)
46{ 46{
47 return alloc_bootmem(sizeof(struct resource)); 47 return memblock_alloc(sizeof(struct resource), 0);
48} 48}
49 49
50SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus, 50SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c668c3b7a167..4cc3eb92f55b 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -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), 0);
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)
403struct resource * __init 403struct resource * __init
404alloc_resource(void) 404alloc_resource(void)
405{ 405{
406 return alloc_bootmem(sizeof(struct resource)); 406 return memblock_alloc(sizeof(struct resource), 0);
407} 407}
408 408
409 409
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 0c05493e6495..5d178c7ba5b2 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -79,7 +79,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
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), 0);
83 } 83 }
84 84
85 arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid); 85 arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid);
@@ -92,7 +92,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
92 92
93#else /* CONFIG_DISCONTIGMEM */ 93#else /* CONFIG_DISCONTIGMEM */
94 94
95 arena = alloc_bootmem(sizeof(*arena)); 95 arena = memblock_alloc(sizeof(*arena), 0);
96 arena->ptes = memblock_alloc_from(mem_size, align, 0); 96 arena->ptes = memblock_alloc_from(mem_size, align, 0);
97 97
98#endif /* CONFIG_DISCONTIGMEM */ 98#endif /* CONFIG_DISCONTIGMEM */
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 5586926dd85d..71209766c47f 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -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, 0); \
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, 0);}
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)
diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c
index acf10eb9da15..5554863b4c9b 100644
--- a/arch/ia64/mm/tlb.c
+++ b/arch/ia64/mm/tlb.c
@@ -59,8 +59,8 @@ struct ia64_tr_entry *ia64_idtrs[NR_CPUS];
59void __init 59void __init
60mmu_context_init (void) 60mmu_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, 0);
63 ia64_ctx.flushmap = alloc_bootmem((ia64_ctx.max_ctx+1)>>3); 63 ia64_ctx.flushmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, 0);
64} 64}
65 65
66/* 66/*
diff --git a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c
index 8546922adb47..72d94585b52e 100644
--- a/arch/m68k/sun3/sun3dvma.c
+++ b/arch/m68k/sun3/sun3dvma.c
@@ -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 0);
271 272
272 dvma_unmap_iommu(DVMA_START, DVMA_SIZE); 273 dvma_unmap_iommu(DVMA_START, DVMA_SIZE);
273 274
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index df6de7ccdc2e..8c7f074ec20f 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -377,7 +377,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
377 if (mem_init_done) 377 if (mem_init_done)
378 p = kzalloc(size, mask); 378 p = kzalloc(size, mask);
379 else { 379 else {
380 p = alloc_bootmem(size); 380 p = memblock_alloc(size, 0);
381 if (p) 381 if (p)
382 memset(p, 0, size); 382 memset(p, 0, size);
383 } 383 }
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 0c997645e8f0..c1f95359d298 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -917,7 +917,7 @@ static void __init resource_init(void)
917 if (end >= HIGHMEM_START) 917 if (end >= HIGHMEM_START)
918 end = HIGHMEM_START - 1; 918 end = HIGHMEM_START - 1;
919 919
920 res = alloc_bootmem(sizeof(struct resource)); 920 res = memblock_alloc(sizeof(struct resource), 0);
921 921
922 res->start = start; 922 res->start = start;
923 res->end = end; 923 res->end = end;
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 3ef1b48e064a..ef19a391214f 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -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), 0);
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..20442d20bd09 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -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), 0);
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..844056cf313e 100644
--- a/arch/um/kernel/initrd.c
+++ b/arch/um/kernel/initrd.c
@@ -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, 0);
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/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index e8fea7ffa306..f5ea6415b778 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -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 0);
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/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index e25118f8a726..8c7450900e0e 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -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, 0);
2582 res = (void *)mem; 2582 res = (void *)mem;
2583 2583
2584 mem += sizeof(struct resource) * nr_ioapics; 2584 mem += sizeof(struct resource) * nr_ioapics;
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index d1f25c831447..a0ec4c37265a 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1094,7 +1094,7 @@ void __init e820__reserve_resources(void)
1094 struct resource *res; 1094 struct resource *res;
1095 u64 end; 1095 u64 end;
1096 1096
1097 res = alloc_bootmem(sizeof(*res) * e820_table->nr_entries); 1097 res = memblock_alloc(sizeof(*res) * e820_table->nr_entries, 0);
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/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
index d6ee92986920..140cd76ee897 100644
--- a/arch/x86/platform/olpc/olpc_dt.c
+++ b/arch/x86/platform/olpc/olpc_dt.c
@@ -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, 0);
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/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c
index d027dddc41ca..206b9d4591e8 100644
--- a/arch/xtensa/platforms/iss/network.c
+++ b/arch/xtensa/platforms/iss/network.c
@@ -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), 0);
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/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index e8ae2e54151c..332fcca30944 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -493,7 +493,7 @@ int __init smu_init (void)
493 goto fail_np; 493 goto fail_np;
494 } 494 }
495 495
496 smu = alloc_bootmem(sizeof(struct smu_device)); 496 smu = memblock_alloc(sizeof(struct smu_device), 0);
497 497
498 spin_lock_init(&smu->lock); 498 spin_lock_init(&smu->lock);
499 INIT_LIST_HEAD(&smu->cmd_list); 499 INIT_LIST_HEAD(&smu->cmd_list);
diff --git a/init/main.c b/init/main.c
index 86b59cf3bec7..8cef69c61389 100644
--- a/init/main.c
+++ b/init/main.c
@@ -773,8 +773,8 @@ static int __init initcall_blacklist(char *str)
773 str_entry = strsep(&str, ","); 773 str_entry = strsep(&str, ",");
774 if (str_entry) { 774 if (str_entry) {
775 pr_debug("blacklisting initcall %s\n", str_entry); 775 pr_debug("blacklisting initcall %s\n", str_entry);
776 entry = alloc_bootmem(sizeof(*entry)); 776 entry = memblock_alloc(sizeof(*entry), 0);
777 entry->buf = alloc_bootmem(strlen(str_entry) + 1); 777 entry->buf = memblock_alloc(strlen(str_entry) + 1, 0);
778 strcpy(entry->buf, str_entry); 778 strcpy(entry->buf, str_entry);
779 list_add(&entry->next, &blacklisted_initcalls); 779 list_add(&entry->next, &blacklisted_initcalls);
780 } 780 }