From: Mike Kravetz <mike.kravetz@oracle.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>, akpm@linux-foundation.org
Cc: willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: migrate: Simplify the refcount validation when migrating hugetlb mapping
Date: Thu, 14 Apr 2022 15:07:16 -0700 [thread overview]
Message-ID: <b30e9ae6-86b4-57f8-8484-d437996510bb@oracle.com> (raw)
In-Reply-To: <eb2fbbeaef2b1714097b9dec457426d682ee0635.1649676424.git.baolin.wang@linux.alibaba.com>
On 4/11/22 04:34, Baolin Wang wrote:
> There is no need to validate the hugetlb page's refcount before trying
> to freeze the hugetlb page's expected refcount, instead we can just
> rely on the page_ref_freeze() to simplify the validation.
>
> Moreover we are always under the page lock when migrating the hugetlb
> page mapping, which means nowhere else can remove it from the page cache,
> so we can remove the xas_load() validation under the i_pages lock.
I agree with the reasoning here.
>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> ---
> mm/migrate.c | 5 -----
> 1 file changed, 5 deletions(-)
Matthew added that extra xas_load() and check both here and in
migrate_page_move_mapping. However, migrate_page_move_mapping has been
converted to folio and does not appear to have the same check.
Ideally we will convert hugetlbfs to folio someday and rewrite
migrate_huge_page_move_mapping as well.
Would be good to get Matthew's opinion.
Acked-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index a3d8c2b..b267827 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -477,11 +477,6 @@ int migrate_huge_page_move_mapping(struct address_space *mapping,
>
> xas_lock_irq(&xas);
> expected_count = 2 + page_has_private(page);
> - if (page_count(page) != expected_count || xas_load(&xas) != page) {
> - xas_unlock_irq(&xas);
> - return -EAGAIN;
> - }
> -
> if (!page_ref_freeze(page, expected_count)) {
> xas_unlock_irq(&xas);
> return -EAGAIN;
prev parent reply other threads:[~2022-04-14 22:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 11:34 Baolin Wang
2022-04-14 22:07 ` Mike Kravetz [this message]
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=b30e9ae6-86b4-57f8-8484-d437996510bb@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=linux-kernel@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