Skip to content

Commit 92923ca

Browse files
Nathan Zimmertorvalds
authored andcommitted
mm: meminit: only set page reserved in the memblock region
Currently each page struct is set as reserved upon initialization. This patch leaves the reserved bit clear and only sets the reserved bit when it is known the memory was allocated by the bootmem allocator. This makes it easier to distinguish between uninitialised struct pages and reserved struct pages in later patches. Signed-off-by: Robin Holt <[email protected]> Signed-off-by: Nathan Zimmer <[email protected]> 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: 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]>
1 parent 1e8ce83 commit 92923ca

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

include/linux/mm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,8 @@ extern void free_highmem_page(struct page *page);
16351635
extern void adjust_managed_page_count(struct page *page, long count);
16361636
extern void mem_init_print_info(const char *str);
16371637

1638+
extern void reserve_bootmem_region(unsigned long start, unsigned long end);
1639+
16381640
/* Free the reserved page into the buddy system, so it gets managed. */
16391641
static inline void __free_reserved_page(struct page *page)
16401642
{

mm/nobootmem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ static unsigned long __init free_low_memory_core_early(void)
130130

131131
memblock_clear_hotplug(0, -1);
132132

133+
for_each_reserved_mem_region(i, &start, &end)
134+
reserve_bootmem_region(start, end);
135+
133136
for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end,
134137
NULL)
135138
count += __free_memory_core(start, end);

mm/page_alloc.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,6 @@ static void __meminit __init_single_page(struct page *page, unsigned long pfn,
774774
init_page_count(page);
775775
page_mapcount_reset(page);
776776
page_cpupid_reset_last(page);
777-
SetPageReserved(page);
778777

779778
/*
780779
* Mark the block movable so that blocks are reserved for
@@ -809,6 +808,22 @@ static void __meminit __init_single_pfn(unsigned long pfn, unsigned long zone,
809808
return __init_single_page(pfn_to_page(pfn), pfn, zone, nid);
810809
}
811810

811+
/*
812+
* Initialised pages do not have PageReserved set. This function is
813+
* called for each range allocated by the bootmem allocator and
814+
* marks the pages PageReserved. The remaining valid pages are later
815+
* sent to the buddy page allocator.
816+
*/
817+
void reserve_bootmem_region(unsigned long start, unsigned long end)
818+
{
819+
unsigned long start_pfn = PFN_DOWN(start);
820+
unsigned long end_pfn = PFN_UP(end);
821+
822+
for (; start_pfn < end_pfn; start_pfn++)
823+
if (pfn_valid(start_pfn))
824+
SetPageReserved(pfn_to_page(start_pfn));
825+
}
826+
812827
static bool free_pages_prepare(struct page *page, unsigned int order)
813828
{
814829
bool compound = PageCompound(page);

0 commit comments

Comments
 (0)