Skip to content

Commit

Permalink
memblock: replace alloc_bootmem_pages with memblock_alloc
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Mike Rapoport <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Greentime Hu <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Guan Xuetao <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Ley Foon Tan <[email protected]>
Cc: Mark Salter <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: Richard Kuo <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Russell King <[email protected]>
Cc: Serge Semin <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Vineet Gupta <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rppt authored and torvalds committed Oct 31, 2018
1 parent e8625dc commit 15c3c11
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion arch/c6x/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void __init paging_init(void)
struct pglist_data *pgdat = NODE_DATA(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);

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/h8300/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void __init paging_init(void)
* Initialize the bad page table and bad page to point
* 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);

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void __init paging_init(void)

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).
Expand Down
4 changes: 2 additions & 2 deletions arch/m68k/mm/mcfmmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ void __init paging_init(void)
enum zone_type zone;
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);

pg_dir = swapper_pg_dir;
memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir));

size = num_pages * sizeof(pte_t);
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;
pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/mm/motorola.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void __init paging_init(void)
* initialize the bad page table and bad page to point
* 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
Expand Down
4 changes: 2 additions & 2 deletions arch/m68k/mm/sun3mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void __init paging_init(void)
unsigned long zones_size[MAX_NR_ZONES] = { 0, };
unsigned long size;

empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);

address = PAGE_OFFSET;
pg_dir = swapper_pg_dir;
Expand All @@ -55,7 +55,7 @@ void __init paging_init(void)
size = num_pages * sizeof(pte_t);
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;

/* Map whole memory from PAGE_OFFSET (0x0E000000) */
Expand Down
4 changes: 2 additions & 2 deletions arch/sh/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static pmd_t * __init one_md_table_init(pud_t *pud)
if (pud_none(*pud)) {
pmd_t *pmd;

pmd = alloc_bootmem_pages(PAGE_SIZE);
pmd = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
pud_populate(&init_mm, pud, pmd);
BUG_ON(pmd != pmd_offset(pud, 0));
}
Expand All @@ -141,7 +141,7 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
if (pmd_none(*pmd)) {
pte_t *pte;

pte = alloc_bootmem_pages(PAGE_SIZE);
pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
pmd_populate_kernel(&init_mm, pmd, pte);
BUG_ON(pte != pte_offset_kernel(pmd, 0));
}
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/kernel/apic/io_apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2621,7 +2621,8 @@ void __init io_apic_init_mappings(void)
#ifdef CONFIG_X86_32
fake_ioapic_page:
#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);
}
set_fixmap_nocache(idx, ioapic_phys);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static __ref void *spp_getpage(void)
if (after_bootmem)
ptr = (void *) get_zeroed_page(GFP_ATOMIC);
else
ptr = alloc_bootmem_pages(PAGE_SIZE);
ptr = memblock_alloc(PAGE_SIZE, PAGE_SIZE);

if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) {
panic("set_pte_phys: cannot allocate page data %s\n",
Expand Down
3 changes: 2 additions & 1 deletion drivers/xen/swiotlb-xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ int __ref xen_swiotlb_init(int verbose, bool early)
* Get IO TLB memory from any location.
*/
if (early)
xen_io_tlb_start = alloc_bootmem_pages(PAGE_ALIGN(bytes));
xen_io_tlb_start = memblock_alloc(PAGE_ALIGN(bytes),
PAGE_SIZE);
else {
#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
Expand Down

0 comments on commit 15c3c11

Please sign in to comment.