On 9/22/26 19:12, Muhammad Usama Anjum wrote:
> The non-MMU stub receives hw_pte_t but returns a software PTE value. It
> has no attached PTE that requires ptep_get(), so convert only the stored
> entry through __pte_from_hw().
>
> Signed-off-by: Muhammad Usama Anjum <[email protected]>
> ---
> Changes since v1:
> - Explain why the NOMMU stub does not use ptep_get().
> - Use software PTE value terminology.
> ---
> include/linux/hugetlb.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 0d2101facaa50..637fc863d3687 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -1278,7 +1278,8 @@ static inline pte_t huge_ptep_clear_flush(struct
> vm_area_struct *vma,
> #ifdef CONFIG_MMU
> return ptep_get(ptep);
> #else
> - return *ptep;
> + /* No attached PTE that requires ptep_get(). */
> + return __pte_from_hw(*ptep);
> #endif
> }
>
>
Okay, that looks quite odd. No NOMMU code should ever be calling this helper. I
can understand that some NOMMU code might, for some odd reason, end up including
hguetlb.h where we have !CONFIG_HUGETLB_PAGE.
But let's see who actually calls huge_ptep_clear_flush():
arch/arm64/mm/hugetlbpage.c: only with CONFIG_HUGETLB_PAGE
mm/hugetlb.c: only with CONFIG_HUGETLB_PAGE
mm/rmap.c: only after checking folio_test_hugetlb().
I suspect we can simply do:
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 80a5a03e9cee..8642c863c1b7 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -1268,15 +1268,8 @@ static inline void hugetlb_count_sub(long l, struct
mm_struct *mm)
pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
unsigned long huge_pte_dirty(pte_t pte);
-static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
- unsigned long addr, pte_t *ptep)
-{
-#ifdef CONFIG_MMU
- return ptep_get(ptep);
-#else
- return *ptep;
-#endif
-}
+pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr,
+ pte_t *ptep);
static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, pte_t pte, unsigned long sz)
--
Cheers,
David