From: Mike Rapoport <rppt@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-arm-kernel@lists.infradead.org, x86@kernel.org,
linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org,
linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.de>, Peter Xu <peterx@redhat.com>,
Muchun Song <muchun.song@linux.dev>,
Russell King <linux@armlinux.org.uk>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
Juergen Gross <jgross@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH v1 2/3] mm/hugetlb: enforce that PMD PT sharing has split PMD PT locks
Date: Sun, 28 Jul 2024 15:47:19 +0300 [thread overview]
Message-ID: <ZqY918UEsmkbIGOn@kernel.org> (raw)
In-Reply-To: <20240726150728.3159964-3-david@redhat.com>
On Fri, Jul 26, 2024 at 05:07:27PM +0200, David Hildenbrand wrote:
> Sharing page tables between processes but falling back to per-MM page
> table locks cannot possibly work.
>
> So, let's make sure that we do have split PMD locks by adding a new
> Kconfig option and letting that depend on CONFIG_SPLIT_PMD_PTLOCKS.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> fs/Kconfig | 4 ++++
> include/linux/hugetlb.h | 5 ++---
> mm/hugetlb.c | 8 ++++----
> 3 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/fs/Kconfig b/fs/Kconfig
> index a46b0cbc4d8f6..0e4efec1d92e6 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -288,6 +288,10 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP
> depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
> depends on SPARSEMEM_VMEMMAP
>
> +config HUGETLB_PMD_PAGE_TABLE_SHARING
> + def_bool HUGETLB_PAGE
> + depends on ARCH_WANT_HUGE_PMD_SHARE && SPLIT_PMD_PTLOCKS
> +
> config ARCH_HAS_GIGANTIC_PAGE
> bool
>
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index da800e56fe590..4d2f3224ff027 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -1243,7 +1243,7 @@ static inline __init void hugetlb_cma_reserve(int order)
> }
> #endif
>
> -#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
> +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
> static inline bool hugetlb_pmd_shared(pte_t *pte)
> {
> return page_count(virt_to_page(pte)) > 1;
> @@ -1279,8 +1279,7 @@ bool __vma_private_lock(struct vm_area_struct *vma);
> static inline pte_t *
> hugetlb_walk(struct vm_area_struct *vma, unsigned long addr, unsigned long sz)
> {
> -#if defined(CONFIG_HUGETLB_PAGE) && \
> - defined(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && defined(CONFIG_LOCKDEP)
> +#if defined(CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING) && defined(CONFIG_LOCKDEP)
> struct hugetlb_vma_lock *vma_lock = vma->vm_private_data;
>
> /*
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 0858a18272073..c4d94e122c41f 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -7211,7 +7211,7 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
> return 0;
> }
>
> -#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
> +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
> static unsigned long page_table_shareable(struct vm_area_struct *svma,
> struct vm_area_struct *vma,
> unsigned long addr, pgoff_t idx)
> @@ -7373,7 +7373,7 @@ int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,
> return 1;
> }
>
> -#else /* !CONFIG_ARCH_WANT_HUGE_PMD_SHARE */
> +#else /* !CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING */
>
> pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma,
> unsigned long addr, pud_t *pud)
> @@ -7396,7 +7396,7 @@ bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr)
> {
> return false;
> }
> -#endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */
> +#endif /* CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING */
>
> #ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB
> pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
> @@ -7494,7 +7494,7 @@ unsigned long hugetlb_mask_last_page(struct hstate *h)
> /* See description above. Architectures can provide their own version. */
> __weak unsigned long hugetlb_mask_last_page(struct hstate *h)
> {
> -#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
> +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
> if (huge_page_size(h) == PMD_SIZE)
> return PUD_SIZE - PMD_SIZE;
> #endif
> --
> 2.45.2
>
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2024-07-28 12:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 15:07 [PATCH v1 0/3] mm: split PTE/PMD PT table Kconfig cleanups+clarifications David Hildenbrand
2024-07-26 15:07 ` [PATCH v1 1/3] mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options David Hildenbrand
2024-07-28 12:45 ` Mike Rapoport
2024-07-29 7:56 ` Qi Zheng
2024-07-29 11:33 ` Russell King (Oracle)
2024-07-26 15:07 ` [PATCH v1 2/3] mm/hugetlb: enforce that PMD PT sharing has split PMD PT locks David Hildenbrand
2024-07-28 12:47 ` Mike Rapoport [this message]
2024-07-26 15:07 ` [PATCH v1 3/3] powerpc/8xx: document and enforce that split PT locks are not used David Hildenbrand
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=ZqY918UEsmkbIGOn@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=muchun.song@linux.dev \
--cc=naveen.n.rao@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).