linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	willy@infradead.org, jgowans@amazon.com, yuzhao@google.com
Subject: Re: [PATCH -next v2 1/2] mm: compaction: convert to use a folio in isolate_migratepages_block()
Date: Wed, 21 Jun 2023 14:20:13 +0800	[thread overview]
Message-ID: <ccab6877-7b48-e5c2-5264-67b8148849da@linux.alibaba.com> (raw)
In-Reply-To: <20230619110718.65679-1-wangkefeng.wang@huawei.com>

Hi

On 6/19/2023 7:07 PM, Kefeng Wang wrote:
> Directly use a folio instead of page_folio() when page successfully
> isolated (hugepage and movable page) and after folio_get_nontail_page(),
> which removes several calls to compound_head().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> v2:
> - update comments and use node_stat_mod_folio, per Matthew Wilcox
> - add missed PageLRU conversion and rebase on next-20230619
> 
>   mm/compaction.c | 84 ++++++++++++++++++++++++++-----------------------
>   1 file changed, 44 insertions(+), 40 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 6149a2d324be..0334eefe4bfa 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -795,6 +795,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>   	struct lruvec *lruvec;
>   	unsigned long flags = 0;
>   	struct lruvec *locked = NULL;
> +	struct folio *folio = NULL;
>   	struct page *page = NULL, *valid_page = NULL;
>   	struct address_space *mapping;
>   	unsigned long start_pfn = low_pfn;
> @@ -891,7 +892,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>   		if (!valid_page && pageblock_aligned(low_pfn)) {
>   			if (!isolation_suitable(cc, page)) {
>   				low_pfn = end_pfn;
> -				page = NULL;
> +				folio = NULL;
>   				goto isolate_abort;
>   			}
>   			valid_page = page;
> @@ -923,7 +924,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>   				 * Hugepage was successfully isolated and placed
>   				 * on the cc->migratepages list.
>   				 */
> -				low_pfn += compound_nr(page) - 1;
> +				folio = page_folio(page);
> +				low_pfn += folio_nr_pages(folio) - 1;
>   				goto isolate_success_no_list;
>   			}
>   
> @@ -991,8 +993,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>   					locked = NULL;
>   				}
>   
> -				if (isolate_movable_page(page, mode))
> +				if (isolate_movable_page(page, mode)) {
> +					folio = page_folio(page);
>   					goto isolate_success;
> +				}
>   			}
>   
>   			goto isolate_fail;
> @@ -1003,7 +1007,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>   		 * sure the page is not being freed elsewhere -- the
>   		 * page release code relies on it.
>   		 */
> -		if (unlikely(!get_page_unless_zero(page)))
> +		folio = folio_get_nontail_page(page);

I'm just curious, how can you make sure the 'page' is not a tail page? 
Since the validation is lockless.


  parent reply	other threads:[~2023-06-21  6:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 11:07 Kefeng Wang
2023-06-19 11:07 ` [PATCH -next v2 2/2] mm: kill [add|del]_page_to_lru_list() Kefeng Wang
2023-06-21  6:20 ` Baolin Wang [this message]
2023-06-21  8:36   ` [PATCH -next v2 1/2] mm: compaction: convert to use a folio in isolate_migratepages_block() Kefeng Wang
2023-06-21  9:11     ` Baolin Wang

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=ccab6877-7b48-e5c2-5264-67b8148849da@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=jgowans@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.com \
    /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