Commit 15c3c114 authored by Mike Rapoport's avatar Mike Rapoport Committed by Linus Torvalds

memblock: replace alloc_bootmem_pages with memblock_alloc

The alloc_bootmem_pages() function allocates PAGE_SIZE aligned memory.
memblock_alloc() with alignment set to PAGE_SIZE does exactly the same
thing.

The conversion is done using the following semantic patch:

@@
expression e;
@@
- alloc_bootmem_pages(e)
+ memblock_alloc(e, PAGE_SIZE)

Link: http://lkml.kernel.org/r/1536927045-23536-20-git-send-email-rppt@linux.vnet.ibm.comSigned-off-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Serge Semin <fancer.lancer@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e8625dce
...@@ -38,7 +38,8 @@ void __init paging_init(void) ...@@ -38,7 +38,8 @@ void __init paging_init(void)
struct pglist_data *pgdat = NODE_DATA(0); struct pglist_data *pgdat = NODE_DATA(0);
unsigned long zones_size[MAX_NR_ZONES] = {0, }; unsigned long zones_size[MAX_NR_ZONES] = {0, };
empty_zero_page = (unsigned long) alloc_bootmem_pages(PAGE_SIZE); empty_zero_page = (unsigned long) memblock_alloc(PAGE_SIZE,
PAGE_SIZE);
memset((void *)empty_zero_page, 0, PAGE_SIZE); memset((void *)empty_zero_page, 0, PAGE_SIZE);
/* /*
......
...@@ -67,7 +67,7 @@ void __init paging_init(void) ...@@ -67,7 +67,7 @@ void __init paging_init(void)
* Initialize the bad page table and bad page to point * Initialize the bad page table and bad page to point
* to a couple of allocated pages. * to a couple of allocated pages.
*/ */
empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); empty_zero_page = (unsigned long)memblock_alloc(PAGE_SIZE, PAGE_SIZE);
memset((void *)empty_zero_page, 0, PAGE_SIZE); memset((void *)empty_zero_page, 0, PAGE_SIZE);
/* /*
......
...@@ -93,7 +93,7 @@ void __init paging_init(void) ...@@ -93,7 +93,7 @@ void __init paging_init(void)
high_memory = (void *) end_mem; high_memory = (void *) end_mem;
empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
/* /*
* Set up SFC/DFC registers (user data space). * Set up SFC/DFC registers (user data space).
......
...@@ -44,7 +44,7 @@ void __init paging_init(void) ...@@ -44,7 +44,7 @@ void __init paging_init(void)
enum zone_type zone; enum zone_type zone;
int i; int i;
empty_zero_page = (void *) alloc_bootmem_pages(PAGE_SIZE); empty_zero_page = (void *) memblock_alloc(PAGE_SIZE, PAGE_SIZE);
memset((void *) empty_zero_page, 0, PAGE_SIZE); memset((void *) empty_zero_page, 0, PAGE_SIZE);
pg_dir = swapper_pg_dir; pg_dir = swapper_pg_dir;
...@@ -52,7 +52,7 @@ void __init paging_init(void) ...@@ -52,7 +52,7 @@ void __init paging_init(void)
size = num_pages * sizeof(pte_t); size = num_pages * sizeof(pte_t);
size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1); size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
next_pgtable = (unsigned long) alloc_bootmem_pages(size); next_pgtable = (unsigned long) memblock_alloc(size, PAGE_SIZE);
bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK; bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
pg_dir += PAGE_OFFSET >> PGDIR_SHIFT; pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
......
...@@ -276,7 +276,7 @@ void __init paging_init(void) ...@@ -276,7 +276,7 @@ void __init paging_init(void)
* initialize the bad page table and bad page to point * initialize the bad page table and bad page to point
* to a couple of allocated pages * to a couple of allocated pages
*/ */
empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
/* /*
* Set up SFC/DFC registers * Set up SFC/DFC registers
......
...@@ -45,7 +45,7 @@ void __init paging_init(void) ...@@ -45,7 +45,7 @@ void __init paging_init(void)
unsigned long zones_size[MAX_NR_ZONES] = { 0, }; unsigned long zones_size[MAX_NR_ZONES] = { 0, };
unsigned long size; unsigned long size;
empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
address = PAGE_OFFSET; address = PAGE_OFFSET;
pg_dir = swapper_pg_dir; pg_dir = swapper_pg_dir;
...@@ -55,7 +55,7 @@ void __init paging_init(void) ...@@ -55,7 +55,7 @@ void __init paging_init(void)
size = num_pages * sizeof(pte_t); size = num_pages * sizeof(pte_t);
size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1); size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
next_pgtable = (unsigned long)alloc_bootmem_pages(size); next_pgtable = (unsigned long)memblock_alloc(size, PAGE_SIZE);
bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK; bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
/* Map whole memory from PAGE_OFFSET (0x0E000000) */ /* Map whole memory from PAGE_OFFSET (0x0E000000) */
......
...@@ -128,7 +128,7 @@ static pmd_t * __init one_md_table_init(pud_t *pud) ...@@ -128,7 +128,7 @@ static pmd_t * __init one_md_table_init(pud_t *pud)
if (pud_none(*pud)) { if (pud_none(*pud)) {
pmd_t *pmd; pmd_t *pmd;
pmd = alloc_bootmem_pages(PAGE_SIZE); pmd = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
pud_populate(&init_mm, pud, pmd); pud_populate(&init_mm, pud, pmd);
BUG_ON(pmd != pmd_offset(pud, 0)); BUG_ON(pmd != pmd_offset(pud, 0));
} }
...@@ -141,7 +141,7 @@ static pte_t * __init one_page_table_init(pmd_t *pmd) ...@@ -141,7 +141,7 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
if (pmd_none(*pmd)) { if (pmd_none(*pmd)) {
pte_t *pte; pte_t *pte;
pte = alloc_bootmem_pages(PAGE_SIZE); pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
pmd_populate_kernel(&init_mm, pmd, pte); pmd_populate_kernel(&init_mm, pmd, pte);
BUG_ON(pte != pte_offset_kernel(pmd, 0)); BUG_ON(pte != pte_offset_kernel(pmd, 0));
} }
......
...@@ -2621,7 +2621,8 @@ void __init io_apic_init_mappings(void) ...@@ -2621,7 +2621,8 @@ void __init io_apic_init_mappings(void)
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
fake_ioapic_page: fake_ioapic_page:
#endif #endif
ioapic_phys = (unsigned long)alloc_bootmem_pages(PAGE_SIZE); ioapic_phys = (unsigned long)memblock_alloc(PAGE_SIZE,
PAGE_SIZE);
ioapic_phys = __pa(ioapic_phys); ioapic_phys = __pa(ioapic_phys);
} }
set_fixmap_nocache(idx, ioapic_phys); set_fixmap_nocache(idx, ioapic_phys);
......
...@@ -197,7 +197,7 @@ static __ref void *spp_getpage(void) ...@@ -197,7 +197,7 @@ static __ref void *spp_getpage(void)
if (after_bootmem) if (after_bootmem)
ptr = (void *) get_zeroed_page(GFP_ATOMIC); ptr = (void *) get_zeroed_page(GFP_ATOMIC);
else else
ptr = alloc_bootmem_pages(PAGE_SIZE); ptr = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) { if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) {
panic("set_pte_phys: cannot allocate page data %s\n", panic("set_pte_phys: cannot allocate page data %s\n",
......
...@@ -217,7 +217,8 @@ int __ref xen_swiotlb_init(int verbose, bool early) ...@@ -217,7 +217,8 @@ int __ref xen_swiotlb_init(int verbose, bool early)
* Get IO TLB memory from any location. * Get IO TLB memory from any location.
*/ */
if (early) if (early)
xen_io_tlb_start = alloc_bootmem_pages(PAGE_ALIGN(bytes)); xen_io_tlb_start = memblock_alloc(PAGE_ALIGN(bytes),
PAGE_SIZE);
else { else {
#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment