Thread (19 messages) 19 messages, 2 authors, 2024-03-15

Re: [PATCH v10 09/12] powerpc: mm: Add common pud_pfn stub for all platforms

From: LTC IMAP <hidden>
Date: 2024-03-14 00:18:57
Also in: linux-arm-kernel, linux-mm, linux-riscv

On Wed, 2024-03-13 at 11:08 +0000, Christophe Leroy wrote:

Le 13/03/2024 à 05:21, Rohan McLure a écrit :
quoted
Prior to this commit, pud_pfn was implemented with BUILD_BUG as the
inline
function for 64-bit Book3S systems but is never included, as its
invocations in generic code are guarded by calls to pud_devmap
which return
zero on such systems. A future patch will provide support for page
table
checks, the generic code for which depends on a pud_pfn stub being
implemented, even while the patch will not interact with puds
directly.

Remove the 64-bit Book3S stub and define pud_pfn to warn on all
platforms. pud_pfn may be defined properly on a per-platform basis
should it grow real usages in future.
Apologies, I don't actually remove the 64-bit, Book3S stub, as it
currently correctly reflects how transparent hugepages should work.

Also the stub that was previously implemented for all platforms has
been removed in commit 27af67f35631 ("powerpc/book3s64/mm: enable
transparent pud hugepage").
Can you please re-explain why that's needed ? I remember we discussed
it 
already in the past, but I checked again today and can't see the
need:

In mm/page_table_check.c, the call to pud_pfn() is gated by a call to
pud_user_accessible_page(pud). If I look into arm64 version of 
pud_user_accessible_page(), it depends on pud_leaf(). When pud_leaf()
is 
constant 0, pud_user_accessible_page() is always false and the call
to 
pud_pfn() should be folded away.
As it will be folded away on non 64-bit Book3S platforms, I could
even replace the WARN_ONCE with a BUILD_BUG for your stated reason.
The __page_table_check_pud_set() function will still be included in the
build and references this routine so a fallback stub is still
necessary.
quoted
Signed-off-by: Rohan McLure <redacted>
---
  arch/powerpc/include/asm/pgtable.h | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/include/asm/pgtable.h
b/arch/powerpc/include/asm/pgtable.h
index 0c0ffbe7a3b5..13f661831333 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -213,6 +213,20 @@ static inline bool
arch_supports_memmap_on_memory(unsigned long vmemmap_size)
  
  #endif /* CONFIG_PPC64 */
  
+/*
+ * Currently only consumed by page_table_check_pud_{set,clear}.
Since clears
+ * and sets to page table entries at any level are done through
+ * page_table_check_pte_{set,clear}, provide stub implementation.
+ */
+#ifndef pud_pfn
+#define pud_pfn pud_pfn
+static inline int pud_pfn(pud_t pud)
+{
+	WARN_ONCE(1, "pud: platform does not use pud entries
directly");
+	return 0;
+}
+#endif
+
  #endif /* __ASSEMBLY__ */
  
  #endif /* _ASM_POWERPC_PGTABLE_H */
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help