Re: [PATCH] arm/mm: Drop [PTE|PMD]_TYPE_FAULT

From: Russell King - ARM Linux admin
Date: Thu May 13 2021 - 06:52:51 EST


On Thu, May 13, 2021 at 09:03:53AM +0100, Russell King - ARM Linux admin wrote:
> On Thu, May 13, 2021 at 11:21:53AM +0530, Anshuman Khandual wrote:
> > Drop these unused symbols i.e PTE_TYPE_FAULT and PMD_TYPE_FAULT.
>
> They're documentation, although PTE_TYPE_FAULT ought to be used by
> __swp_entry() to show that better.

So really, we should be doing something like this:

diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index c02f24400369..c43e07d6046d 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -303,7 +303,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })

#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
-#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val })
+#define __swp_entry_to_pte(swp) __pte((swp).val | PTE_TYPE_FAULT)

/*
* It is an error for the kernel to have more swap files than we can

Since that is really what is going on here. It is by design that the
swp_entry_t is layed out to be correct, and of course because
PTE_TYPE_FAULT has the value of zero, the above merely adds to the
"documentation" rather than having any functional effect.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!