From: "David Hildenbrand (Arm)" <david@kernel.org>
To: jane.chu@oracle.com, Andrew Morton <akpm@linux-foundation.org>,
Jianhui Zhou <jianhuizzzzz@gmail.com>,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
SeongJae Park <sj@kernel.org>, Hugh Dickins <hughd@google.com>,
Sidhartha Kumar <sidhartha.kumar@oracle.com>,
Jonas Zhou <jonaszhou@zhaoxin.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
syzbot+f525fd79634858f478e7@syzkaller.appspotmail.com
Subject: Re: [PATCH v4] mm/userfaultfd: fix hugetlb fault mutex hash calculation
Date: Thu, 26 Mar 2026 10:18:09 +0100 [thread overview]
Message-ID: <9ec9edd1-0f4c-4da2-ae78-0e7b251a9e25@kernel.org> (raw)
In-Reply-To: <67287b4a-7b93-4061-af4d-65e4a163c61c@oracle.com>
On 3/26/26 00:46, jane.chu@oracle.com wrote:
> Hi, David,
>
> On 3/25/2026 1:49 AM, David Hildenbrand (Arm) wrote:
> [..]
[...]
>>
>> But it raises the question:
>>
>> (1) should be convert all that to just operate on the ordinary index,
>> such that we don't even need hugetlb_linear_page_index()? That would be
>> an addon patch.
>>
>
> Do you mean to convert all callers of hugetlb_linear_page_index() and
> vma_hugepcache_offset() to use index and huge_page_order(h) ?
> May I add, to improve readability, rename the huge-page-granularity
> 'idx' to huge_idx or hidx ?
What I meant is that we change all hugetlb code to use the ordinary idx.
It's a bigger rework.
For example, we'd be getting rid of filemap_lock_hugetlb_folio() completely and
simply use filemap_lock_folio. As one example:
@@ -657,10 +657,9 @@ static void hugetlbfs_zero_partial_page(struct hstate *h,
loff_t start,
loff_t end)
{
- pgoff_t idx = start >> huge_page_shift(h);
struct folio *folio;
- folio = filemap_lock_hugetlb_folio(h, mapping, idx);
+ folio = filemap_lock_folio(mapping, start >> PAGE_SHIFT);
if (IS_ERR(folio))
return;
Other parts are more tricky, as we have to make sure that we get
an idx that points at the start of the folio.
Likely such a conversion could be done incrementally. But it's a bit of work.
We'd be getting rid of some more hugetlb special casing.
An alternative is passing in an address into hugetlb_linear_page_index(),
just letting it do the calculation itself (it can get the hstate from the mapping).
>
>> (2) Alternatively, could we replace all users of vma_hugecache_offset()
>> by the much cleaner hugetlb_linear_page_index() ?
>>
>
> The difference between the two helpers is hstate_vma() in the latter
> that is about 5 pointer de-references, not sure of any performance
> implication though.
hstate_vma() is really just hstate_file(vma->vm_file)->
hstate_inode(file_inode(f))->HUGETLBFS_SB(i->i_sb)->hstate;
So some pointer chasing.
hard to believe that this would matter in any of this code :)
> At minimum, we could have
> hugetlb_linear_page_index(vma, addr)
> -> __hugetlb_linear_page_index(h, vma, addr)
> basically renaming vma_hugecache_offset().
I would only do that if it's really required for performance.
--
Cheers,
David
next prev parent reply other threads:[~2026-03-26 9:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 14:03 [PATCH] mm/userfaultfd: fix hugetlb fault mutex hash calculation Jianhui Zhou
2026-03-06 16:53 ` Peter Xu
2026-03-07 13:37 ` 周建辉
2026-03-07 13:59 ` Jianhui Zhou
2026-03-07 3:27 ` SeongJae Park
2026-03-08 13:41 ` Jianhui Zhou
2026-03-08 22:57 ` SeongJae Park
2026-03-07 14:35 ` [PATCH v2] " Jianhui Zhou
2026-03-09 2:08 ` Hugh Dickins
2026-03-09 3:08 ` Jianhui Zhou
2026-03-09 16:47 ` David Hildenbrand (Arm)
2026-03-10 10:24 ` Jianhui Zhou
2026-03-09 3:30 ` [PATCH v3] " Jianhui Zhou
2026-03-10 11:05 ` [PATCH v4] " Jianhui Zhou
2026-03-10 19:47 ` jane.chu
2026-03-11 10:54 ` Jianhui Zhou
2026-03-25 0:03 ` Andrew Morton
2026-03-25 1:06 ` SeongJae Park
2026-03-25 6:07 ` Jianhui Zhou
2026-03-25 8:49 ` David Hildenbrand (Arm)
2026-03-25 19:08 ` Mike Rapoport
2026-03-25 8:49 ` David Hildenbrand (Arm)
2026-03-25 19:02 ` Mike Rapoport
2026-03-25 23:46 ` jane.chu
2026-03-26 9:18 ` David Hildenbrand (Arm) [this message]
2026-03-25 19:10 ` Mike Rapoport
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=9ec9edd1-0f4c-4da2-ae78-0e7b251a9e25@kernel.org \
--to=david@kernel.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=jane.chu@oracle.com \
--cc=jianhuizzzzz@gmail.com \
--cc=jonaszhou@zhaoxin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=sidhartha.kumar@oracle.com \
--cc=sj@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+f525fd79634858f478e7@syzkaller.appspotmail.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