Skip to content

Commit 2a5bda5

Browse files
rppttorvalds
authored andcommitted
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>
1 parent 4fc4a09 commit 2a5bda5

File tree

19 files changed

+28
-26
lines changed

19 files changed

+28
-26
lines changed

arch/alpha/kernel/core_marvel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mk_resource_name(int pe, int port, char *str)
8282
char *name;
8383

8484
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);
8686
strcpy(name, tmp);
8787

8888
return name;
@@ -117,7 +117,7 @@ alloc_io7(unsigned int pe)
117117
return NULL;
118118
}
119119

120-
io7 = alloc_bootmem(sizeof(*io7));
120+
io7 = memblock_alloc(sizeof(*io7), 0);
121121
io7->pe = pe;
122122
raw_spin_lock_init(&io7->irq_lock);
123123

arch/alpha/kernel/pci-noop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ alloc_pci_controller(void)
3333
{
3434
struct pci_controller *hose;
3535

36-
hose = alloc_bootmem(sizeof(*hose));
36+
hose = memblock_alloc(sizeof(*hose), 0);
3737

3838
*hose_tail = hose;
3939
hose_tail = &hose->next;
@@ -44,7 +44,7 @@ alloc_pci_controller(void)
4444
struct resource * __init
4545
alloc_resource(void)
4646
{
47-
return alloc_bootmem(sizeof(struct resource));
47+
return memblock_alloc(sizeof(struct resource), 0);
4848
}
4949

5050
SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,

arch/alpha/kernel/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ alloc_pci_controller(void)
392392
{
393393
struct pci_controller *hose;
394394

395-
hose = alloc_bootmem(sizeof(*hose));
395+
hose = memblock_alloc(sizeof(*hose), 0);
396396

397397
*hose_tail = hose;
398398
hose_tail = &hose->next;
@@ -403,7 +403,7 @@ alloc_pci_controller(void)
403403
struct resource * __init
404404
alloc_resource(void)
405405
{
406-
return alloc_bootmem(sizeof(struct resource));
406+
return memblock_alloc(sizeof(struct resource), 0);
407407
}
408408

409409

arch/alpha/kernel/pci_iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
7979
printk("%s: couldn't allocate arena from node %d\n"
8080
" falling back to system-wide allocation\n",
8181
__func__, nid);
82-
arena = alloc_bootmem(sizeof(*arena));
82+
arena = memblock_alloc(sizeof(*arena), 0);
8383
}
8484

8585
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,
9292

9393
#else /* CONFIG_DISCONTIGMEM */
9494

95-
arena = alloc_bootmem(sizeof(*arena));
95+
arena = memblock_alloc(sizeof(*arena), 0);
9696
arena->ptes = memblock_alloc_from(mem_size, align, 0);
9797

9898
#endif /* CONFIG_DISCONTIGMEM */

arch/ia64/kernel/mca.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
361361

362362
#define IA64_LOG_ALLOCATE(it, size) \
363363
{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); \
365365
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);}
367367
#define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock)
368368
#define IA64_LOG_LOCK(it) spin_lock_irqsave(&ia64_state_log[it].isl_lock, s)
369369
#define IA64_LOG_UNLOCK(it) spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s)

arch/ia64/mm/tlb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ struct ia64_tr_entry *ia64_idtrs[NR_CPUS];
5959
void __init
6060
mmu_context_init (void)
6161
{
62-
ia64_ctx.bitmap = alloc_bootmem((ia64_ctx.max_ctx+1)>>3);
63-
ia64_ctx.flushmap = 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 = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, 0);
6464
}
6565

6666
/*

arch/m68k/sun3/sun3dvma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ void __init dvma_init(void)
267267

268268
list_add(&(hole->list), &hole_list);
269269

270-
iommu_use = alloc_bootmem(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long));
270+
iommu_use = memblock_alloc(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long),
271+
0);
271272

272273
dvma_unmap_iommu(DVMA_START, DVMA_SIZE);
273274

arch/microblaze/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
377377
if (mem_init_done)
378378
p = kzalloc(size, mask);
379379
else {
380-
p = alloc_bootmem(size);
380+
p = memblock_alloc(size, 0);
381381
if (p)
382382
memset(p, 0, size);
383383
}

arch/mips/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ static void __init resource_init(void)
917917
if (end >= HIGHMEM_START)
918918
end = HIGHMEM_START - 1;
919919

920-
res = alloc_bootmem(sizeof(struct resource));
920+
res = memblock_alloc(sizeof(struct resource), 0);
921921

922922
res->start = start;
923923
res->end = end;

arch/um/drivers/net_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ static int __init eth_setup(char *str)
650650
return 1;
651651
}
652652

653-
new = alloc_bootmem(sizeof(*new));
653+
new = memblock_alloc(sizeof(*new), 0);
654654

655655
INIT_LIST_HEAD(&new->list);
656656
new->index = n;

arch/um/drivers/vector_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ static int __init vector_setup(char *str)
15801580
str, error);
15811581
return 1;
15821582
}
1583-
new = alloc_bootmem(sizeof(*new));
1583+
new = memblock_alloc(sizeof(*new), 0);
15841584
INIT_LIST_HEAD(&new->list);
15851585
new->unit = n;
15861586
new->arguments = str;

arch/um/kernel/initrd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int __init read_initrd(void)
3636
return 0;
3737
}
3838

39-
area = alloc_bootmem(size);
39+
area = memblock_alloc(size, 0);
4040

4141
if (load_initrd(initrd, area, size) == -1)
4242
return 0;

arch/x86/kernel/acpi/boot.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
933933
* the resource tree during the lateinit timeframe.
934934
*/
935935
#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);
937938

938939
hpet_res->name = (void *)&hpet_res[1];
939940
hpet_res->flags = IORESOURCE_MEM;

arch/x86/kernel/apic/io_apic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ static struct resource * __init ioapic_setup_resources(void)
25782578
n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
25792579
n *= nr_ioapics;
25802580

2581-
mem = alloc_bootmem(n);
2581+
mem = memblock_alloc(n, 0);
25822582
res = (void *)mem;
25832583

25842584
mem += sizeof(struct resource) * nr_ioapics;

arch/x86/kernel/e820.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ void __init e820__reserve_resources(void)
10941094
struct resource *res;
10951095
u64 end;
10961096

1097-
res = alloc_bootmem(sizeof(*res) * e820_table->nr_entries);
1097+
res = memblock_alloc(sizeof(*res) * e820_table->nr_entries, 0);
10981098
e820_res = res;
10991099

11001100
for (i = 0; i < e820_table->nr_entries; i++) {

arch/x86/platform/olpc/olpc_dt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void * __init prom_early_alloc(unsigned long size)
141141
* fast enough on the platforms we care about while minimizing
142142
* wasted bootmem) and hand off chunks of it to callers.
143143
*/
144-
res = alloc_bootmem(chunk_size);
144+
res = memblock_alloc(chunk_size, 0);
145145
BUG_ON(!res);
146146
prom_early_allocated += chunk_size;
147147
memset(res, 0, chunk_size);

arch/xtensa/platforms/iss/network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static int __init iss_net_setup(char *str)
646646
return 1;
647647
}
648648

649-
new = alloc_bootmem(sizeof(*new));
649+
new = memblock_alloc(sizeof(*new), 0);
650650
if (new == NULL) {
651651
pr_err("Alloc_bootmem failed\n");
652652
return 1;

drivers/macintosh/smu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ int __init smu_init (void)
493493
goto fail_np;
494494
}
495495

496-
smu = alloc_bootmem(sizeof(struct smu_device));
496+
smu = memblock_alloc(sizeof(struct smu_device), 0);
497497

498498
spin_lock_init(&smu->lock);
499499
INIT_LIST_HEAD(&smu->cmd_list);

init/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,8 @@ static int __init initcall_blacklist(char *str)
773773
str_entry = strsep(&str, ",");
774774
if (str_entry) {
775775
pr_debug("blacklisting initcall %s\n", str_entry);
776-
entry = alloc_bootmem(sizeof(*entry));
777-
entry->buf = alloc_bootmem(strlen(str_entry) + 1);
776+
entry = memblock_alloc(sizeof(*entry), 0);
777+
entry->buf = memblock_alloc(strlen(str_entry) + 1, 0);
778778
strcpy(entry->buf, str_entry);
779779
list_add(&entry->next, &blacklisted_initcalls);
780780
}

0 commit comments

Comments
 (0)