Re: [PATCH v2 02/14] mm/page_alloc: split prep_compound_page into head and tail subparts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/17/21 11:44 AM, Joao Martins wrote:
> Split the utility function prep_compound_page() into head and tail
> counterparts, and use them accordingly.
> 
> This is in preparation for sharing the storage for / deduplicating
> compound page metadata.
> 
> Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
> ---
>  mm/page_alloc.c | 32 +++++++++++++++++++++-----------
>  1 file changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 8836e54721ae..95967ce55829 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -741,24 +741,34 @@ void free_compound_page(struct page *page)
>  	free_the_page(page, compound_order(page));
>  }
>  
> +static void prep_compound_head(struct page *page, unsigned int order)
> +{
> +	set_compound_page_dtor(page, COMPOUND_PAGE_DTOR);
> +	set_compound_order(page, order);
> +	atomic_set(compound_mapcount_ptr(page), -1);
> +	if (hpage_pincount_available(page))
> +		atomic_set(compound_pincount_ptr(page), 0);
> +}
> +
> +static void prep_compound_tail(struct page *head, int tail_idx)
> +{
> +	struct page *p = head + tail_idx;
> +
> +	set_page_count(p, 0);

When you rebase, you should notice this has been removed from
prep_compound_page as all tail pages should have zero ref count.

> +	p->mapping = TAIL_MAPPING;
> +	set_compound_head(p, head);
> +}
> +
>  void prep_compound_page(struct page *page, unsigned int order)
>  {
>  	int i;
>  	int nr_pages = 1 << order;
>  
>  	__SetPageHead(page);
> -	for (i = 1; i < nr_pages; i++) {
> -		struct page *p = page + i;
> -		set_page_count(p, 0);
> -		p->mapping = TAIL_MAPPING;
> -		set_compound_head(p, page);
> -	}
> +	for (i = 1; i < nr_pages; i++)
> +		prep_compound_tail(page, i);
>  
> -	set_compound_page_dtor(page, COMPOUND_PAGE_DTOR);
> -	set_compound_order(page, order);
> -	atomic_set(compound_mapcount_ptr(page), -1);
> -	if (hpage_pincount_available(page))
> -		atomic_set(compound_pincount_ptr(page), 0);
> +	prep_compound_head(page, order);
>  }
>  
>  #ifdef CONFIG_DEBUG_PAGEALLOC
> 

I'll need something like this for demote hugetlb page fuinctionality
when the pages being demoted have been optimized for minimal vmemmap
usage.

Acked-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
-- 
Mike Kravetz



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux