mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
bootmem: stop using page->index
Encode the type into the bottom four bits of page->private and the info into the remaining bits. Also turn the bootmem type into a named enum. [arnd@arndb.de: bootmem: add bootmem_type stub function] Link: https://lkml.kernel.org/r/20241015143802.577613-1-arnd@kernel.org [akpm@linux-foundation.org: fix build with !CONFIG_HAVE_BOOTMEM_INFO_NODE] Link: https://lore.kernel.org/oe-kbuild-all/202410090311.eaqcL7IZ-lkp@intel.com/ Link: https://lkml.kernel.org/r/20241005200121.3231142-6-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: kernel test robot <lkp@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
68158bfa3d
commit
0386aaa6e9
@ -985,22 +985,32 @@ int arch_add_memory(int nid, u64 start, u64 size,
|
|||||||
return add_pages(nid, start_pfn, nr_pages, params);
|
return add_pages(nid, start_pfn, nr_pages, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_reserved_pages(struct page *page, unsigned long nr_pages)
|
||||||
|
{
|
||||||
|
while (nr_pages--)
|
||||||
|
free_reserved_page(page++);
|
||||||
|
}
|
||||||
|
|
||||||
static void __meminit free_pagetable(struct page *page, int order)
|
static void __meminit free_pagetable(struct page *page, int order)
|
||||||
{
|
{
|
||||||
unsigned long magic;
|
|
||||||
unsigned int nr_pages = 1 << order;
|
|
||||||
|
|
||||||
/* bootmem page has reserved flag */
|
/* bootmem page has reserved flag */
|
||||||
if (PageReserved(page)) {
|
if (PageReserved(page)) {
|
||||||
magic = page->index;
|
unsigned long nr_pages = 1 << order;
|
||||||
if (magic == SECTION_INFO || magic == MIX_SECTION_INFO) {
|
#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
|
||||||
|
enum bootmem_type type = bootmem_type(page);
|
||||||
|
|
||||||
|
if (type == SECTION_INFO || type == MIX_SECTION_INFO) {
|
||||||
while (nr_pages--)
|
while (nr_pages--)
|
||||||
put_page_bootmem(page++);
|
put_page_bootmem(page++);
|
||||||
} else
|
} else {
|
||||||
while (nr_pages--)
|
free_reserved_pages(page, nr_pages);
|
||||||
free_reserved_page(page++);
|
}
|
||||||
} else
|
#else
|
||||||
|
free_reserved_pages(page, nr_pages);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
free_pages((unsigned long)page_address(page), order);
|
free_pages((unsigned long)page_address(page), order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __meminit free_hugepage_table(struct page *page,
|
static void __meminit free_hugepage_table(struct page *page,
|
||||||
|
@ -6,11 +6,10 @@
|
|||||||
#include <linux/kmemleak.h>
|
#include <linux/kmemleak.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Types for free bootmem stored in page->lru.next. These have to be in
|
* Types for free bootmem stored in the low bits of page->private.
|
||||||
* some random range in unsigned long space for debugging purposes.
|
|
||||||
*/
|
*/
|
||||||
enum {
|
enum bootmem_type {
|
||||||
MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 12,
|
MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 1,
|
||||||
SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
|
SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
|
||||||
MIX_SECTION_INFO,
|
MIX_SECTION_INFO,
|
||||||
NODE_INFO,
|
NODE_INFO,
|
||||||
@ -21,9 +20,19 @@ enum {
|
|||||||
void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
|
void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
|
||||||
|
|
||||||
void get_page_bootmem(unsigned long info, struct page *page,
|
void get_page_bootmem(unsigned long info, struct page *page,
|
||||||
unsigned long type);
|
enum bootmem_type type);
|
||||||
void put_page_bootmem(struct page *page);
|
void put_page_bootmem(struct page *page);
|
||||||
|
|
||||||
|
static inline enum bootmem_type bootmem_type(const struct page *page)
|
||||||
|
{
|
||||||
|
return (unsigned long)page->private & 0xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long bootmem_info(const struct page *page)
|
||||||
|
{
|
||||||
|
return (unsigned long)page->private >> 4;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Any memory allocated via the memblock allocator and not via the
|
* Any memory allocated via the memblock allocator and not via the
|
||||||
* buddy will be marked reserved already in the memmap. For those
|
* buddy will be marked reserved already in the memmap. For those
|
||||||
@ -31,7 +40,7 @@ void put_page_bootmem(struct page *page);
|
|||||||
*/
|
*/
|
||||||
static inline void free_bootmem_page(struct page *page)
|
static inline void free_bootmem_page(struct page *page)
|
||||||
{
|
{
|
||||||
unsigned long magic = page->index;
|
enum bootmem_type type = bootmem_type(page);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The reserve_bootmem_region sets the reserved flag on bootmem
|
* The reserve_bootmem_region sets the reserved flag on bootmem
|
||||||
@ -39,7 +48,7 @@ static inline void free_bootmem_page(struct page *page)
|
|||||||
*/
|
*/
|
||||||
VM_BUG_ON_PAGE(page_ref_count(page) != 2, page);
|
VM_BUG_ON_PAGE(page_ref_count(page) != 2, page);
|
||||||
|
|
||||||
if (magic == SECTION_INFO || magic == MIX_SECTION_INFO)
|
if (type == SECTION_INFO || type == MIX_SECTION_INFO)
|
||||||
put_page_bootmem(page);
|
put_page_bootmem(page);
|
||||||
else
|
else
|
||||||
VM_BUG_ON_PAGE(1, page);
|
VM_BUG_ON_PAGE(1, page);
|
||||||
@ -53,8 +62,18 @@ static inline void put_page_bootmem(struct page *page)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline enum bootmem_type bootmem_type(const struct page *page)
|
||||||
|
{
|
||||||
|
return SECTION_INFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long bootmem_info(const struct page *page)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void get_page_bootmem(unsigned long info, struct page *page,
|
static inline void get_page_bootmem(unsigned long info, struct page *page,
|
||||||
unsigned long type)
|
enum bootmem_type type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,23 +14,24 @@
|
|||||||
#include <linux/memory_hotplug.h>
|
#include <linux/memory_hotplug.h>
|
||||||
#include <linux/kmemleak.h>
|
#include <linux/kmemleak.h>
|
||||||
|
|
||||||
void get_page_bootmem(unsigned long info, struct page *page, unsigned long type)
|
void get_page_bootmem(unsigned long info, struct page *page,
|
||||||
|
enum bootmem_type type)
|
||||||
{
|
{
|
||||||
page->index = type;
|
BUG_ON(type > 0xf);
|
||||||
|
BUG_ON(info > (ULONG_MAX >> 4));
|
||||||
SetPagePrivate(page);
|
SetPagePrivate(page);
|
||||||
set_page_private(page, info);
|
set_page_private(page, info << 4 | type);
|
||||||
page_ref_inc(page);
|
page_ref_inc(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void put_page_bootmem(struct page *page)
|
void put_page_bootmem(struct page *page)
|
||||||
{
|
{
|
||||||
unsigned long type = page->index;
|
enum bootmem_type type = bootmem_type(page);
|
||||||
|
|
||||||
BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
|
BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
|
||||||
type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE);
|
type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE);
|
||||||
|
|
||||||
if (page_ref_dec_return(page) == 1) {
|
if (page_ref_dec_return(page) == 1) {
|
||||||
page->index = 0;
|
|
||||||
ClearPagePrivate(page);
|
ClearPagePrivate(page);
|
||||||
set_page_private(page, 0);
|
set_page_private(page, 0);
|
||||||
INIT_LIST_HEAD(&page->lru);
|
INIT_LIST_HEAD(&page->lru);
|
||||||
|
@ -720,19 +720,19 @@ static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages,
|
|||||||
static void free_map_bootmem(struct page *memmap)
|
static void free_map_bootmem(struct page *memmap)
|
||||||
{
|
{
|
||||||
unsigned long maps_section_nr, removing_section_nr, i;
|
unsigned long maps_section_nr, removing_section_nr, i;
|
||||||
unsigned long magic, nr_pages;
|
unsigned long type, nr_pages;
|
||||||
struct page *page = virt_to_page(memmap);
|
struct page *page = virt_to_page(memmap);
|
||||||
|
|
||||||
nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))
|
nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))
|
||||||
>> PAGE_SHIFT;
|
>> PAGE_SHIFT;
|
||||||
|
|
||||||
for (i = 0; i < nr_pages; i++, page++) {
|
for (i = 0; i < nr_pages; i++, page++) {
|
||||||
magic = page->index;
|
type = bootmem_type(page);
|
||||||
|
|
||||||
BUG_ON(magic == NODE_INFO);
|
BUG_ON(type == NODE_INFO);
|
||||||
|
|
||||||
maps_section_nr = pfn_to_section_nr(page_to_pfn(page));
|
maps_section_nr = pfn_to_section_nr(page_to_pfn(page));
|
||||||
removing_section_nr = page_private(page);
|
removing_section_nr = bootmem_info(page);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When this function is called, the removing section is
|
* When this function is called, the removing section is
|
||||||
|
Loading…
Reference in New Issue
Block a user