nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Joao Martins <joao.m.martins@oracle.com>
To: Mike Kravetz <mike.kravetz@oracle.com>, linux-mm@kvack.org
Cc: Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Naoya Horiguchi <naoya.horiguchi@nec.com>,
	Matthew Wilcox <willy@infradead.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>,
	Jane Chu <jane.chu@oracle.com>,
	Muchun Song <songmuchun@bytedance.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	nvdimm@lists.linux.dev, linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 02/14] mm/page_alloc: split prep_compound_page into head and tail subparts
Date: Tue, 13 Jul 2021 02:11:08 +0100	[thread overview]
Message-ID: <eade29c5-14df-3afd-7dfe-fe17c512a6e3@oracle.com> (raw)
In-Reply-To: <caa531ab-3a87-fdb2-6498-34349f66e475@oracle.com>



On 7/13/21 1:02 AM, Mike Kravetz wrote:
> 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@oracle.com>
>> ---
>>  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.
> 
/me nods

>> +	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@oracle.com>
> 
Thanks!

  reply	other threads:[~2021-07-13  1:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 18:44 [PATCH v2 00/14] mm, sparse-vmemmap: Introduce compound pagemaps Joao Martins
2021-06-17 18:44 ` [PATCH v2 01/14] memory-failure: fetch compound_head after pgmap_pfn_valid() Joao Martins
2021-06-20 23:56   ` HORIGUCHI NAOYA(堀口 直也)
2021-06-21 13:50     ` Joao Martins
2021-06-17 18:44 ` [PATCH v2 02/14] mm/page_alloc: split prep_compound_page into head and tail subparts Joao Martins
2021-07-13  0:02   ` Mike Kravetz
2021-07-13  1:11     ` Joao Martins [this message]
2021-06-17 18:44 ` [PATCH v2 03/14] mm/page_alloc: refactor memmap_init_zone_device() page init Joao Martins
2021-06-17 18:44 ` [PATCH v2 04/14] mm/memremap: add ZONE_DEVICE support for compound pages Joao Martins
2021-06-17 18:44 ` [PATCH v2 05/14] mm/sparse-vmemmap: add a pgmap argument to section activation Joao Martins
2021-06-17 18:44 ` [PATCH v2 06/14] mm/sparse-vmemmap: refactor core of vmemmap_populate_basepages() to helper Joao Martins
2021-06-17 18:45 ` [PATCH v2 07/14] mm/hugetlb_vmemmap: move comment block to Documentation/vm Joao Martins
2021-06-21 13:12   ` [External] " Muchun Song
2021-06-21 13:42     ` Joao Martins
2021-07-13  0:14       ` Mike Kravetz
2021-07-13  1:11         ` Joao Martins
2021-06-17 18:45 ` [PATCH v2 08/14] mm/sparse-vmemmap: populate compound pagemaps Joao Martins
2021-06-17 18:45 ` [PATCH v2 09/14] mm/page_alloc: reuse tail struct pages for " Joao Martins
2021-06-17 18:45 ` [PATCH v2 10/14] device-dax: use ALIGN() for determining pgoff Joao Martins
2021-06-17 18:45 ` [PATCH v2 11/14] device-dax: ensure dev_dax->pgmap is valid for dynamic devices Joao Martins
2021-06-17 18:45 ` [PATCH v2 12/14] device-dax: compound pagemap support Joao Martins
2021-06-17 18:45 ` [PATCH v2 13/14] mm/gup: grab head page refcount once for group of subpages Joao Martins
2021-06-17 18:45 ` [PATCH v2 14/14] mm/sparse-vmemmap: improve memory savings for compound pud geometry Joao Martins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eade29c5-14df-3afd-7dfe-fe17c512a6e3@oracle.com \
    --to=joao.m.martins@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=jane.chu@oracle.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=naoya.horiguchi@nec.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=songmuchun@bytedance.com \
    --cc=vishal.l.verma@intel.com \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH v2 02/14] mm/page_alloc: split prep_compound_page into head and tail subparts' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).