From: Matthew Wilcox <willy@infradead.org>
To: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Muchun Song <muchun.song@linux.dev>,
David Hildenbrand <david@redhat.com>,
linux-mm@kvack.org
Subject: Re: [PATCH 1/2] mm: convert clear_huge_page() to clear_large_folio()
Date: Thu, 13 Jun 2024 15:51:58 +0100 [thread overview]
Message-ID: <ZmsHjv4boc3uHC3J@casper.infradead.org> (raw)
In-Reply-To: <20240613105344.2876119-1-wangkefeng.wang@huawei.com>
On Thu, Jun 13, 2024 at 06:53:43PM +0800, Kefeng Wang wrote:
> +++ b/include/linux/mm.h
> @@ -4071,9 +4071,7 @@ enum mf_action_page_type {
> };
>
> #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
> -extern void clear_huge_page(struct page *page,
> - unsigned long addr_hint,
> - unsigned int pages_per_huge_page);
> +void clear_large_folio(struct folio *folio, unsigned long addr_hint);
I think this is properly called
void folio_zero_user(struct folio *folio, unsigned long user_addr);
> -void clear_huge_page(struct page *page,
> - unsigned long addr_hint, unsigned int pages_per_huge_page)
> +void clear_large_folio(struct folio *folio, unsigned long addr_hint)
> {
> + unsigned int pages_per_huge_page = folio_nr_pages(folio);
I think it's worth renaming to nr_pages here.
> unsigned long addr = addr_hint &
> ~(((unsigned long)pages_per_huge_page << PAGE_SHIFT) - 1);
This can just be:
unsigned long addr = user_addr & ~(folio_size(folio) - 1);
Umm. Except this assumes that the folio is always mapped to userspace
at its natural alignment. And that's true for hugetlb, but not true
for THP. So I think this needs to be moved into the callers for which
it is true, and we need documentation that user_addr is expected to be
the base address that the folio is mapped at.
next prev parent reply other threads:[~2024-06-13 14:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 10:53 Kefeng Wang
2024-06-13 10:53 ` [PATCH 2/2] mm: memory: use folio in struct copy_subpage_arg Kefeng Wang
2024-06-14 12:26 ` David Hildenbrand
2024-06-13 14:51 ` Matthew Wilcox [this message]
2024-06-14 5:29 ` [PATCH 1/2] mm: convert clear_huge_page() to clear_large_folio() Kefeng 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=ZmsHjv4boc3uHC3J@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=wangkefeng.wang@huawei.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