linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/7] mm: Store compound_nr as well as compound_order
Date: Mon, 29 Jun 2020 09:22:27 -0700	[thread overview]
Message-ID: <20200629162227.GF2454695@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20200629151959.15779-2-willy@infradead.org>

On Mon, Jun 29, 2020 at 04:19:53PM +0100, Matthew Wilcox wrote:
> This removes a few instructions from functions which need to know how many
> pages are in a compound page.  The storage used is either page->mapping
> on 64-bit or page->index on 32-bit.  Both of these are fine to overlay
> on tail pages.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  include/linux/mm.h       | 5 ++++-
>  include/linux/mm_types.h | 1 +
>  mm/page_alloc.c          | 5 +++--
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index dc7b87310c10..af0305ad090f 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -911,12 +911,15 @@ static inline int compound_pincount(struct page *page)
>  static inline void set_compound_order(struct page *page, unsigned int order)
>  {
>  	page[1].compound_order = order;
> +	page[1].compound_nr = 1U << order;
                              ^^^
			      1UL?

Ira

>  }
>  
>  /* Returns the number of pages in this potentially compound page. */
>  static inline unsigned long compound_nr(struct page *page)
>  {
> -	return 1UL << compound_order(page);
> +	if (!PageHead(page))
> +		return 1;
> +	return page[1].compound_nr;
>  }
>  
>  /* Returns the number of bytes in this potentially compound page. */
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 64ede5f150dc..561ed987ab44 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -134,6 +134,7 @@ struct page {
>  			unsigned char compound_dtor;
>  			unsigned char compound_order;
>  			atomic_t compound_mapcount;
> +			unsigned int compound_nr; /* 1 << compound_order */
>  		};
>  		struct {	/* Second tail page of compound page */
>  			unsigned long _compound_pad_1;	/* compound_head */
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 48eb0f1410d4..c7beb5f13193 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -673,8 +673,6 @@ void prep_compound_page(struct page *page, unsigned int order)
>  	int i;
>  	int nr_pages = 1 << order;
>  
> -	set_compound_page_dtor(page, COMPOUND_PAGE_DTOR);
> -	set_compound_order(page, order);
>  	__SetPageHead(page);
>  	for (i = 1; i < nr_pages; i++) {
>  		struct page *p = page + i;
> @@ -682,6 +680,9 @@ void prep_compound_page(struct page *page, unsigned int order)
>  		p->mapping = TAIL_MAPPING;
>  		set_compound_head(p, page);
>  	}
> +
> +	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);
> -- 
> 2.27.0
> 
> 

  reply	other threads:[~2020-06-29 18:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 15:19 [PATCH 0/7] THP prep patches Matthew Wilcox (Oracle)
2020-06-29 15:19 ` [PATCH 1/7] mm: Store compound_nr as well as compound_order Matthew Wilcox (Oracle)
2020-06-29 16:22   ` Ira Weiny [this message]
2020-06-29 16:24     ` Matthew Wilcox
2020-07-06 10:29   ` Kirill A. Shutemov
2020-08-11 22:53     ` Matthew Wilcox
2020-06-29 15:19 ` [PATCH 2/7] mm: Move page-flags include to top of file Matthew Wilcox (Oracle)
2020-06-29 15:19 ` [PATCH 3/7] mm: Add thp_order Matthew Wilcox (Oracle)
2020-06-29 15:19 ` [PATCH 4/7] mm: Add thp_size Matthew Wilcox (Oracle)
2020-06-29 15:19 ` [PATCH 5/7] mm: Replace hpage_nr_pages with thp_nr_pages Matthew Wilcox (Oracle)
2020-06-29 17:40   ` Mike Kravetz
2020-06-29 18:14     ` Matthew Wilcox
2020-06-29 18:32       ` Matthew Wilcox
2020-07-01  1:33         ` Andrew Morton
2020-06-29 15:19 ` [PATCH 6/7] mm: Add thp_head Matthew Wilcox (Oracle)
2020-06-29 15:19 ` [PATCH 7/7] mm: Introduce offset_in_thp Matthew Wilcox (Oracle)
2020-06-29 17:11 ` [PATCH 0/7] THP prep patches William Kucharski
2020-06-29 18:13 ` Zi Yan

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=20200629162227.GF2454695@iweiny-DESK2.sc.intel.com \
    --to=ira.weiny@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).