Skip to content

Commit

Permalink
mm: page_alloc: pass PFN to __free_pages_bootmem
Browse files Browse the repository at this point in the history
__free_pages_bootmem prepares a page for release to the buddy allocator
and assumes that the struct page is initialised.  Parallel initialisation
of struct pages defers initialisation and __free_pages_bootmem can be
called for struct pages that cannot yet map struct page to PFN.  This
patch passes PFN to __free_pages_bootmem with no other functional change.

Signed-off-by: Mel Gorman <[email protected]>
Tested-by: Nate Zimmer <[email protected]>
Tested-by: Waiman Long <[email protected]>
Tested-by: Daniel J Blueman <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
Cc: Robin Holt <[email protected]>
Cc: Nate Zimmer <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Scott Norton <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Mel Gorman authored and torvalds committed Jul 1, 2015
1 parent 92923ca commit d70ddd7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
13 changes: 7 additions & 6 deletions mm/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ void __init free_bootmem_late(unsigned long physaddr, unsigned long size)
end = PFN_DOWN(physaddr + size);

for (; cursor < end; cursor++) {
__free_pages_bootmem(pfn_to_page(cursor), 0);
__free_pages_bootmem(pfn_to_page(cursor), cursor, 0);
totalram_pages++;
}
}

static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
{
struct page *page;
unsigned long *map, start, end, pages, count = 0;
unsigned long *map, start, end, pages, cur, count = 0;

if (!bdata->node_bootmem_map)
return 0;
Expand Down Expand Up @@ -210,17 +210,17 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
if (IS_ALIGNED(start, BITS_PER_LONG) && vec == ~0UL) {
int order = ilog2(BITS_PER_LONG);

__free_pages_bootmem(pfn_to_page(start), order);
__free_pages_bootmem(pfn_to_page(start), start, order);
count += BITS_PER_LONG;
start += BITS_PER_LONG;
} else {
unsigned long cur = start;
cur = start;

start = ALIGN(start + 1, BITS_PER_LONG);
while (vec && cur != start) {
if (vec & 1) {
page = pfn_to_page(cur);
__free_pages_bootmem(page, 0);
__free_pages_bootmem(page, cur, 0);
count++;
}
vec >>= 1;
Expand All @@ -229,12 +229,13 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
}
}

cur = bdata->node_min_pfn;
page = virt_to_page(bdata->node_bootmem_map);
pages = bdata->node_low_pfn - bdata->node_min_pfn;
pages = bootmem_bootmap_pages(pages);
count += pages;
while (pages--)
__free_pages_bootmem(page++, 0);
__free_pages_bootmem(page++, cur++, 0);

bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);

Expand Down
3 changes: 2 additions & 1 deletion mm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ __find_buddy_index(unsigned long page_idx, unsigned int order)
}

extern int __isolate_free_page(struct page *page, unsigned int order);
extern void __free_pages_bootmem(struct page *page, unsigned int order);
extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
unsigned int order);
extern void prep_compound_page(struct page *page, unsigned long order);
#ifdef CONFIG_MEMORY_FAILURE
extern bool is_free_buddy_page(struct page *page);
Expand Down
2 changes: 1 addition & 1 deletion mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ void __init __memblock_free_late(phys_addr_t base, phys_addr_t size)
end = PFN_DOWN(base + size);

for (; cursor < end; cursor++) {
__free_pages_bootmem(pfn_to_page(cursor), 0);
__free_pages_bootmem(pfn_to_page(cursor), cursor, 0);
totalram_pages++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions mm/nobootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void __init free_bootmem_late(unsigned long addr, unsigned long size)
end = PFN_DOWN(addr + size);

for (; cursor < end; cursor++) {
__free_pages_bootmem(pfn_to_page(cursor), 0);
__free_pages_bootmem(pfn_to_page(cursor), cursor, 0);
totalram_pages++;
}
}
Expand All @@ -101,7 +101,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
while (start + (1UL << order) > end)
order--;

__free_pages_bootmem(pfn_to_page(start), order);
__free_pages_bootmem(pfn_to_page(start), start, order);

start += (1UL << order);
}
Expand Down
3 changes: 2 additions & 1 deletion mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,8 @@ static void __free_pages_ok(struct page *page, unsigned int order)
local_irq_restore(flags);
}

void __init __free_pages_bootmem(struct page *page, unsigned int order)
void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
unsigned int order)
{
unsigned int nr_pages = 1 << order;
struct page *p = page;
Expand Down

0 comments on commit d70ddd7

Please sign in to comment.