diff mbox series

[v2,05/14] mm/sparc: Change pXd_huge() behavior to exclude swap entries

Message ID 20240318200404.448346-6-peterx@redhat.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series mm/treewide: Remove pXd_huge() API | expand

Commit Message

Peter Xu March 18, 2024, 8:03 p.m. UTC
From: Peter Xu <peterx@redhat.com>

Please refer to the previous patch on the reasoning for x86.  Now sparc is
the only architecture that will allow swap entries to be reported as
pXd_huge().  After this patch, all architectures should forbid swap entries
in pXd_huge().

Cc: David S. Miller <davem@davemloft.net>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 arch/sparc/mm/hugetlbpage.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Muchun Song March 19, 2024, 4:25 a.m. UTC | #1
> On Mar 19, 2024, at 04:03, peterx@redhat.com wrote:
> 
> From: Peter Xu <peterx@redhat.com>
> 
> Please refer to the previous patch on the reasoning for x86.  Now sparc is
> the only architecture that will allow swap entries to be reported as
> pXd_huge().  After this patch, all architectures should forbid swap entries
> in pXd_huge().
> 
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Andreas Larsson <andreas@gaisler.com>
> Cc: sparclinux@vger.kernel.org
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> arch/sparc/mm/hugetlbpage.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
> index b432500c13a5..d31c2cec35c9 100644
> --- a/arch/sparc/mm/hugetlbpage.c
> +++ b/arch/sparc/mm/hugetlbpage.c
> @@ -409,14 +409,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
> 
> int pmd_huge(pmd_t pmd)
> {
> - 	return !pmd_none(pmd) &&
> - 	(pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID;
> + 	return pmd_leaf(pmd);;

There is a redundant semicolon in the end.

Thanks.

> }
> 
> int pud_huge(pud_t pud)
> {
> - 	return !pud_none(pud) &&
> - 	(pud_val(pud) & (_PAGE_VALID|_PAGE_PUD_HUGE)) != _PAGE_VALID;
> + 	return pud_leaf(pud);
> }
> 
> static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd,
> -- 
> 2.44.0
>
Peter Xu March 19, 2024, 2:04 p.m. UTC | #2
On Tue, Mar 19, 2024 at 12:25:39PM +0800, Muchun Song wrote:
> > @@ -409,14 +409,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
> > 
> > int pmd_huge(pmd_t pmd)
> > {
> > - 	return !pmd_none(pmd) &&
> > - 	(pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID;
> > + 	return pmd_leaf(pmd);;
> 
> There is a redundant semicolon in the end.

Will touch it up, thanks.  PS: This will be dropped as a whole in patch 12.
diff mbox series

Patch

diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
index b432500c13a5..d31c2cec35c9 100644
--- a/arch/sparc/mm/hugetlbpage.c
+++ b/arch/sparc/mm/hugetlbpage.c
@@ -409,14 +409,12 @@  pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
 
 int pmd_huge(pmd_t pmd)
 {
-	return !pmd_none(pmd) &&
-		(pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID;
+	return pmd_leaf(pmd);;
 }
 
 int pud_huge(pud_t pud)
 {
-	return !pud_none(pud) &&
-		(pud_val(pud) & (_PAGE_VALID|_PAGE_PUD_HUGE)) != _PAGE_VALID;
+	return pud_leaf(pud);
 }
 
 static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd,