mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 14:23:49 +01:00
We never free the ms->usage data for boot memory sections (see section_deactivate()). And to identify whether ms->usage was allocated from memblock, we simply identify it by looking at PG_reserved. Consequently, there is no need to mark ms->usage as MIX_SECTION_INFO. Let's just stop doing that. Link: https://lore.kernel.org/[email protected] Signed-off-by: David Hildenbrand (Arm) <[email protected]> Acked-by: Oscar Salvador <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Mike Rapoport (Microsoft) <[email protected]> Reviewed-by: Lance Yang <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Andreas Larsson <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: David S. Miller <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Ritesh Harjani (IBM) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
73 lines
1.8 KiB
C
73 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Bootmem core functions.
|
|
*
|
|
* Copyright (c) 2020, Bytedance.
|
|
*
|
|
* Author: Muchun Song <[email protected]>
|
|
*
|
|
*/
|
|
#include <linux/mm.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/memblock.h>
|
|
#include <linux/bootmem_info.h>
|
|
#include <linux/memory_hotplug.h>
|
|
#include <linux/kmemleak.h>
|
|
|
|
void get_page_bootmem(unsigned long info, struct page *page,
|
|
enum bootmem_type type)
|
|
{
|
|
BUG_ON(type > 0xf);
|
|
BUG_ON(info > (ULONG_MAX >> 4));
|
|
set_page_private(page, info << 4 | type);
|
|
page_ref_inc(page);
|
|
}
|
|
|
|
void put_page_bootmem(struct page *page)
|
|
{
|
|
enum bootmem_type type = bootmem_type(page);
|
|
|
|
BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
|
|
type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE);
|
|
|
|
if (page_ref_dec_return(page) == 1) {
|
|
set_page_private(page, 0);
|
|
free_reserved_page(page);
|
|
}
|
|
}
|
|
|
|
static void __init register_page_bootmem_info_section(unsigned long start_pfn)
|
|
{
|
|
unsigned long section_nr;
|
|
struct mem_section *ms;
|
|
|
|
start_pfn = SECTION_ALIGN_DOWN(start_pfn);
|
|
section_nr = pfn_to_section_nr(start_pfn);
|
|
ms = __nr_to_section(section_nr);
|
|
|
|
if (!preinited_vmemmap_section(ms))
|
|
register_page_bootmem_memmap(section_nr, pfn_to_page(start_pfn),
|
|
PAGES_PER_SECTION);
|
|
}
|
|
|
|
void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
|
|
{
|
|
unsigned long pfn, end_pfn;
|
|
int node = pgdat->node_id;
|
|
|
|
pfn = pgdat->node_start_pfn;
|
|
end_pfn = pgdat_end_pfn(pgdat);
|
|
|
|
/* register section info */
|
|
for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
|
|
/*
|
|
* Some platforms can assign the same pfn to multiple nodes - on
|
|
* node0 as well as nodeN. To avoid registering a pfn against
|
|
* multiple nodes we check that this pfn does not already
|
|
* reside in some other nodes.
|
|
*/
|
|
if (pfn_valid(pfn) && (early_pfn_to_nid(pfn) == node))
|
|
register_page_bootmem_info_section(pfn);
|
|
}
|
|
}
|