From: Andrew Morton <akpm@linux-foundation.org>
To: "Li Zhe" <lizhe.67@bytedance.com>
Cc: <david@kernel.org>, <muchun.song@linux.dev>, <osalvador@suse.de>,
<aiqi.i7@bytedance.com>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>
Subject: Re: [PATCH v2] mm/hugetlb: fix overbroad MMU notifiers for unshared PMDs
Date: Tue, 22 Sep 2026 19:00:41 -0700 [thread overview]
Message-ID: <20260922190041.d5d983ba6fb1475e40568eea@linux-foundation.org> (raw)
In-Reply-To: <20260922090749.24905-1-lizhe.67@bytedance.com>
On Tue, 22 Sep 2026 17:07:49 +0800 "Li Zhe" <lizhe.67@bytedance.com> wrote:
> Hugetlb currently expands MMU notifier ranges to PUD boundaries whenever
> PMD sharing is possible. That is only needed when huge_pmd_unshare()
> actually detaches a shared PMD page table, because clearing the PUD
> invalidates the whole PUD-sized virtual address range.
>
> For hugetlbfs hole punch, and similarly for other hugetlb unmap paths,
> a shared mapping can pass the "PMD sharing is possible" range test in
> adjust_range_if_pmd_sharing_possible() even when the hugetlbfs file has
> never actually had any shared PMD page tables. KVM then receives a 1G
> invalidation for a 2M operation and zaps unrelated secondary mappings,
> so the guest has to fault them back in.
>
> Avoid this by remembering, per hugetlbfs inode, whether PMD sharing was
> ever established for the file. Set the flag when huge_pmd_share()
> successfully populates a shared PMD table. For the hugetlb unmap paths,
> skip the conservative PUD-sized notifier expansion while the file has
> never seen PMD sharing.
>
> The state is intentionally sticky and file-wide. Once PMD sharing has
> ever happened for the file, the unmap paths keep the existing
> conservative expansion. This avoids the no-sharing case without adding a
> page-table walk to every unmap.
Oh. It's not feasible to figure out when PMD sharing has ended and go
back to never-seen-sharing state?
> On a Redis-in-VM workload that punches cold 2M hugetlb pages, this patch
> improves P99 QPS stability while punching pages, reducing the QPS
> degradation ratio from 7.09% to 1.45%.
How realistic is this test? IOW, how much benefit can people expect to
see in real-world usage?
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -921,6 +921,9 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
> simple_inode_init_ts(inode);
> info->resv_map = resv_map;
> info->seals = F_SEAL_SEAL;
> +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
> + info->pmd_sharing_seen = false;
> +#endif
This could use a slightly modified hugetlbfs_set_pmd_sharing_seen() and
remove the ifdefs.
hugetlbfs_set_pmd_sharing_seen(inode, false);
Not very important.
next prev parent reply other threads:[~2026-09-23 2:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 9:07 Li Zhe
2026-09-23 2:00 ` Andrew Morton [this message]
2026-09-23 7:36 ` Li Zhe
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=20260922190041.d5d983ba6fb1475e40568eea@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aiqi.i7@bytedance.com \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizhe.67@bytedance.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
/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
all inboxes | Powered by JetHome®