lkml.org 
[lkml]   [2020]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v7 05/15] mm/bootmem_info: Introduce {free,prepare}_vmemmap_page()
From
Date
On 30.11.20 16:18, Muchun Song wrote:
> In the later patch, we can use the free_vmemmap_page() to free the
> unused vmemmap pages and initialize a page for vmemmap page using
> via prepare_vmemmap_page().
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
> include/linux/bootmem_info.h | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h
> index 4ed6dee1adc9..239e3cc8f86c 100644
> --- a/include/linux/bootmem_info.h
> +++ b/include/linux/bootmem_info.h
> @@ -3,6 +3,7 @@
> #define __LINUX_BOOTMEM_INFO_H
>
> #include <linux/mmzone.h>
> +#include <linux/mm.h>
>
> /*
> * Types for free bootmem stored in page->lru.next. These have to be in
> @@ -22,6 +23,29 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
> void get_page_bootmem(unsigned long info, struct page *page,
> unsigned long type);
> void put_page_bootmem(struct page *page);
> +
> +static inline void free_vmemmap_page(struct page *page)
> +{
> + VM_WARN_ON(!PageReserved(page) || page_ref_count(page) != 2);
> +
> + /* bootmem page has reserved flag in the reserve_bootmem_region */
> + if (PageReserved(page)) {
> + unsigned long magic = (unsigned long)page->freelist;
> +
> + if (magic == SECTION_INFO || magic == MIX_SECTION_INFO)
> + put_page_bootmem(page);
> + else
> + WARN_ON(1);
> + }
> +}
> +
> +static inline void prepare_vmemmap_page(struct page *page)
> +{
> + unsigned long section_nr = pfn_to_section_nr(page_to_pfn(page));
> +
> + get_page_bootmem(section_nr, page, SECTION_INFO);
> + mark_page_reserved(page);
> +}

Can you clarify in the description when exactly these functions are
called and on which type of pages?

Would indicating "bootmem" in the function names make it clearer what we
are dealing with?

E.g., any memory allocated via the memblock allocator and not via the
buddy will be makred reserved already in the memmap. It's unclear to me
why we need the mark_page_reserved() here - can you enlighten me? :)

--
Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2020-12-07 13:43    [W:0.222 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site