From: David Hildenbrand <david@redhat.com>
To: peterx@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Huacai Chen <chenhuacai@kernel.org>,
Jason Gunthorpe <jgg@nvidia.com>,
Nathan Chancellor <nathan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
WANG Xuerui <kernel@xen0n.name>,
Ryan Roberts <ryan.roberts@arm.com>,
loongarch@lists.linux.dev
Subject: Re: [PATCH 1/3] mm: Allow anon exclusive check over hugetlb tail pages
Date: Wed, 3 Apr 2024 09:37:03 +0200 [thread overview]
Message-ID: <57f238d0-632a-4bc9-8d82-fbf1c51c14ff@redhat.com> (raw)
In-Reply-To: <20240403013249.1418299-2-peterx@redhat.com>
On 03.04.24 03:32, peterx@redhat.com wrote:
> From: Peter Xu <peterx@redhat.com>
>
> PageAnonExclusive() used to forbid tail pages for hugetlbfs, as that used
> to be called mostly in hugetlb specific paths and the head page was
> guaranteed.
>
> As we move forward towards merging hugetlb paths into generic mm, we may
> start to pass in tail hugetlb pages (when with cont-pte/cont-pmd huge
> pages) for such check. Allow it to properly fetch the head, in which case
> the anon-exclusiveness of the head will always represents the tail page.
>
> There's already a sign of it when we look at the fast-gup which already
"GUP-fast" ;)
> contain the hugetlb processing altogether: we used to have a specific
> commit 5805192c7b72 ("mm/gup: handle cont-PTE hugetlb pages correctly in
> gup_must_unshare() via GUP-fast") covering that area. Now with this more
> generic change, that can also go away.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> include/linux/page-flags.h | 8 +++++++-
> mm/internal.h | 10 ----------
> 2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 888353c209c0..225357f48a79 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -1095,7 +1095,13 @@ PAGEFLAG(Isolated, isolated, PF_ANY);
> static __always_inline int PageAnonExclusive(const struct page *page)
> {
> VM_BUG_ON_PGFLAGS(!PageAnon(page), page);
> - VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page);
> + /*
> + * Allow the anon-exclusive check to work on hugetlb tail pages.
> + * Here hugetlb pages will always guarantee the anon-exclusiveness
> + * of the head page represents the tail pages.
> + */
> + if (PageHuge(page) && !PageHead(page))
> + page = compound_head(page);
> return test_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags);
> }
>
> diff --git a/mm/internal.h b/mm/internal.h
> index 9512de7398d5..87f6e4fd56a5 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -1259,16 +1259,6 @@ static inline bool gup_must_unshare(struct vm_area_struct *vma,
> if (IS_ENABLED(CONFIG_HAVE_FAST_GUP))
> smp_rmb();
>
> - /*
> - * During GUP-fast we might not get called on the head page for a
> - * hugetlb page that is mapped using cont-PTE, because GUP-fast does
> - * not work with the abstracted hugetlb PTEs that always point at the
> - * head page. For hugetlb, PageAnonExclusive only applies on the head
> - * page (as it cannot be partially COW-shared), so lookup the head page.
> - */
> - if (unlikely(!PageHead(page) && PageHuge(page)))
> - page = compound_head(page);
> -
> /*
> * Note that PageKsm() pages cannot be exclusive, and consequently,
> * cannot get pinned.
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-03 7:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 1:32 [PATCH 0/3] mm/gup: fixups for hugetlb gup rework series peterx
2024-04-03 1:32 ` [PATCH 1/3] mm: Allow anon exclusive check over hugetlb tail pages peterx
2024-04-03 7:37 ` David Hildenbrand [this message]
2024-04-04 0:05 ` Matthew Wilcox
2024-04-04 13:45 ` Peter Xu
2024-04-04 14:06 ` Matthew Wilcox
2024-04-04 14:21 ` Peter Xu
2024-04-04 20:31 ` Andrew Morton
2024-04-04 20:36 ` Peter Xu
2024-04-03 1:32 ` [PATCH 2/3] fixup! mm/gup: handle huge pmd for follow_pmd_mask() peterx
2024-04-03 1:32 ` [PATCH 3/3] fixup! mm/arch: provide pud_pfn() fallback peterx
2024-04-03 11:06 ` [PATCH 0/3] mm/gup: fixups for hugetlb gup rework series Ryan Roberts
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=57f238d0-632a-4bc9-8d82-fbf1c51c14ff@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chenhuacai@kernel.org \
--cc=jgg@nvidia.com \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=loongarch@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=peterx@redhat.com \
--cc=ryan.roberts@arm.com \
--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