From: Ryan Roberts <ryan.roberts@arm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
Helge Deller <deller@gmx.de>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Naveen N Rao <naveen@kernel.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
"David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>,
Arnd Bergmann <arnd@arndb.de>,
Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Uladzislau Rezki <urezki@gmail.com>,
Christoph Hellwig <hch@infradead.org>,
David Hildenbrand <david@redhat.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Mark Rutland <mark.rutland@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Dev Jain <dev.jain@arm.com>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Alexandre Ghiti <alexghiti@rivosinc.com>,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/4] mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear()
Date: Tue, 25 Feb 2025 15:43:04 +0000 [thread overview]
Message-ID: <290f858c-07d4-4690-998c-2aefac664d7b@arm.com> (raw)
In-Reply-To: <Z73Szw4rSHSyfpoy@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com>
On 25/02/2025 14:25, Alexander Gordeev wrote:
> On Mon, Feb 17, 2025 at 02:04:14PM +0000, Ryan Roberts wrote:
>
> Hi Ryan,
>
>> In order to fix a bug, arm64 needs to be told the size of the huge page
>> for which the huge_pte is being set in huge_ptep_get_and_clear().
>> Provide for this by adding an `unsigned long sz` parameter to the
>> function. This follows the same pattern as huge_pte_clear() and
>> set_huge_pte_at().
>>
>> This commit makes the required interface modifications to the core mm as
>> well as all arches that implement this function (arm64, loongarch, mips,
>> parisc, powerpc, riscv, s390, sparc). The actual arm64 bug will be fixed
>> in a separate commit.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 66b3923a1a0f ("arm64: hugetlb: add support for PTE contiguous bit")
>> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>> ---
> ...
>> diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
>> index 7c52acaf9f82..420c74306779 100644
>> --- a/arch/s390/include/asm/hugetlb.h
>> +++ b/arch/s390/include/asm/hugetlb.h
>> @@ -26,7 +26,11 @@ void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
>> pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
>>
>> #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
>> -pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
>> +pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
>> + unsigned long addr, pte_t *ptep,
>> + unsigned long sz);
>
> Please, format parameters similarily to set_huge_pte_at() few lines above.
Appologies. I've fixed this for the next version.
>
>> +pte_t __huge_ptep_get_and_clear(struct mm_struct *mm,
>> + unsigned long addr, pte_t *ptep);
>
> The formatting is broken, but please see below.
Formatting fixed here too.
>
>> static inline void arch_clear_hugetlb_flags(struct folio *folio)
>> {
>> @@ -48,7 +52,7 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
>> static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
>> unsigned long address, pte_t *ptep)
>> {
>> - return huge_ptep_get_and_clear(vma->vm_mm, address, ptep);
>> + return __huge_ptep_get_and_clear(vma->vm_mm, address, ptep);
>> }
>>
>> #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
>> @@ -59,7 +63,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
>> int changed = !pte_same(huge_ptep_get(vma->vm_mm, addr, ptep), pte);
>>
>> if (changed) {
>> - huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
>> + __huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
>> __set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
>> }
>> return changed;
>> @@ -69,7 +73,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
>> static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
>> unsigned long addr, pte_t *ptep)
>> {
>> - pte_t pte = huge_ptep_get_and_clear(mm, addr, ptep);
>> + pte_t pte = __huge_ptep_get_and_clear(mm, addr, ptep);
>>
>> __set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte));
>> }
>> diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
>> index d9ce199953de..52ee8e854195 100644
>> --- a/arch/s390/mm/hugetlbpage.c
>> +++ b/arch/s390/mm/hugetlbpage.c
>> @@ -188,8 +188,8 @@ pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
>> return __rste_to_pte(pte_val(*ptep));
>> }
>>
>> -pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
>> - unsigned long addr, pte_t *ptep)
>> +pte_t __huge_ptep_get_and_clear(struct mm_struct *mm,
>> + unsigned long addr, pte_t *ptep)
>> {
>> pte_t pte = huge_ptep_get(mm, addr, ptep);
>> pmd_t *pmdp = (pmd_t *) ptep;
>> @@ -202,6 +202,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
>> return pte;
>> }
>>
>> +pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
>> + unsigned long addr, pte_t *ptep, unsigned long sz)
>> +{
>> + return __huge_ptep_get_and_clear(mm, addr, ptep);
>> +}
>
> Is there a reason why this is not a header inline, as other callers of
> __huge_ptep_get_and_clear()?
I was trying to make the change as uninvasive as possible, so didn't want to
change the linkage in case I accidentally broke something. Happy to make this an
inline in the header though, if you prefer?
Thanks,
Ryan
>
>> pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
>> unsigned long addr, unsigned long sz)
>> {
> ...
>
> Thanks!
next prev parent reply other threads:[~2025-02-25 15:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 14:04 [PATCH v2 0/4] Fixes for hugetlb and vmalloc on arm64 Ryan Roberts
2025-02-17 14:04 ` [PATCH v2 1/4] mm: hugetlb: Add huge page size param to huge_ptep_get_and_clear() Ryan Roberts
2025-02-19 8:28 ` Anshuman Khandual
2025-02-19 19:00 ` Catalin Marinas
2025-02-20 9:46 ` David Hildenbrand
2025-02-24 10:49 ` Alexandre Ghiti
2025-02-25 14:25 ` Alexander Gordeev
2025-02-25 15:43 ` Ryan Roberts [this message]
2025-02-26 7:16 ` Alexander Gordeev
2025-02-26 7:37 ` Christophe Leroy
2025-02-17 14:04 ` [PATCH v2 2/4] arm64: hugetlb: Fix huge_ptep_get_and_clear() for non-present ptes Ryan Roberts
2025-02-19 8:45 ` Anshuman Khandual
2025-02-19 8:58 ` Ryan Roberts
2025-02-20 6:37 ` Anshuman Khandual
2025-02-21 9:55 ` Catalin Marinas
2025-02-21 10:26 ` Ryan Roberts
2025-02-19 19:03 ` Catalin Marinas
2025-02-21 15:31 ` Will Deacon
2025-02-24 12:11 ` Ryan Roberts
2025-02-25 22:18 ` Will Deacon
2025-02-26 8:09 ` Ryan Roberts
2025-02-24 11:27 ` Alexandre Ghiti
2025-02-17 14:04 ` [PATCH v2 3/4] arm64: hugetlb: Fix flush_hugetlb_tlb_range() invalidation level Ryan Roberts
2025-02-19 8:56 ` Anshuman Khandual
2025-02-19 19:04 ` Catalin Marinas
2025-02-17 14:04 ` [PATCH v2 4/4] mm: Don't skip arch_sync_kernel_mappings() in error paths Ryan Roberts
2025-02-19 19:07 ` Catalin Marinas
2025-02-19 19:10 ` [PATCH v2 0/4] Fixes for hugetlb and vmalloc on arm64 Catalin Marinas
2025-02-21 15:35 ` Will Deacon
2025-02-24 12:13 ` 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=290f858c-07d4-4690-998c-2aefac664d7b@arm.com \
--to=ryan.roberts@arm.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=alexghiti@rivosinc.com \
--cc=andreas@gaisler.com \
--cc=anshuman.khandual@arm.com \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=david@redhat.com \
--cc=deller@gmx.de \
--cc=dev.jain@arm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@infradead.org \
--cc=kernel@xen0n.name \
--cc=kevin.brodsky@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maddy@linux.ibm.com \
--cc=mark.rutland@arm.com \
--cc=mpe@ellerman.id.au \
--cc=muchun.song@linux.dev \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=stable@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=tsbogend@alpha.franken.de \
--cc=urezki@gmail.com \
--cc=will@kernel.org \
--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