loongarch-mm-support-__have_arch_pte_swp_exclusive.patch removed from -mm tree
The quilt patch titled
Subject: loongarch/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE
has been removed from the -mm tree. Its filename was
loongarch-mm-support-__have_arch_pte_swp_exclusive.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: David Hildenbrand <[email protected]>
Subject: loongarch/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE
Date: Fri, 13 Jan 2023 18:10:08 +0100
Let's support __HAVE_ARCH_PTE_SWP_EXCLUSIVE by stealing one bit from the type. Generic MM currently only uses 5 bits for the type (MAX_SWAPFILES_SHIFT), so the stolen bit is effectively unused.
While at it, also mask the type in mk_swap_pte().
Note that this bit does not conflict with swap PMDs and could also be used in swap PMD context later.
---
arch/loongarch/include/asm/pgtable-bits.h renamed from arch/loongarch/include/asm/pgtable-bits.h~loongarch-mm-support-__have_arch_pte_swp_exclusive +4 -0
@@ -20,6 +20,7 @@#define _PAGE_SPECIAL_SHIFT 11#define _PAGE_HGLOBAL_SHIFT 12/* HGlobal is a PMD bit */ #define _PAGE_PFN_SHIFT 12 +#define _PAGE_SWP_EXCLUSIVE_SHIFT 23#define _PAGE_PFN_END_SHIFT 48#define _PAGE_NO_READ_SHIFT 61#define _PAGE_NO_EXEC_SHIFT 62
@@ -33,6 +34,9 @@#define _PAGE_PROTNONE (_ULCAST_(1) << _PAGE_PROTNONE_SHIFT)#define _PAGE_SPECIAL (_ULCAST_(1) << _PAGE_SPECIAL_SHIFT) +/* We borrow bit 23 to store the exclusive marker in swap PTEs. */ +#define _PAGE_SWP_EXCLUSIVE (_ULCAST_(1) << _PAGE_SWP_EXCLUSIVE_SHIFT) +/* Used by TLB hardware (placed in EntryLo*) */ #define _PAGE_VALID (_ULCAST_(1) << _PAGE_VALID_SHIFT)#define _PAGE_DIRTY (_ULCAST_(1) << _PAGE_DIRTY_SHIFT)
arch/loongarch/include/asm/pgtable.h renamed from arch/loongarch/include/asm/pgtable.h~loongarch-mm-support-__have_arch_pte_swp_exclusive +35 -4
@@ -249,13 +249,26 @@ extern void pud_init(void *addr);extern void pmd_init (void *addr);/* -* Non-present pages: high 40 bits are offset, next 8 bits type, -* low 16 bits zero. +* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that +* are !pte_none() && !pte_present(). +* +* Format of swap PTEs: +* +* 6 6 6 6 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 +* 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 +* <--------------------------- offset --------------------------- +* +* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +* --------------> E <--- type ---> <---------- zeroes ----------> +* +* E is the exclusive marker that is not stored in swap entries. +* The zero'ed bits include _PAGE_PRESENT and _PAGE_PROTNONE. */ static inline pte_t mk_swap_pte (unsigned long type,unsigned long offset) -{pte_t pte;pte_val (pte) = (type <<16 ) | (offset <<24 );return pte; } +{pte_t pte;pte_val (pte) = ((type &0x7f ) <<16 ) | (offset <<24 );return pte; } -#define __swp_type (x) (((x).val >> 16) & 0xff) +#define __swp_type (x) (((x).val >> 16) & 0x7f)#define __swp_offset (x) ((x).val >> 24)#define __swp_entry (type, offset) ((swp_entry_t) { pte_val(mk_swap_pte((type), (offset))) })#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) })
@@ -263,6 +276,24 @@ static inline pte_t mk_swap_pte(unsigned#define __pmd_to_swp_entry (pmd) ((swp_entry_t) { pmd_val(pmd) })#define __swp_entry_to_pmd (x) ((pmd_t) { (x).val | _PAGE_HUGE }) +#define __HAVE_ARCH_PTE_SWP_EXCLUSIVE +static inline int pte_swp_exclusive (pte_t pte) +{ +return pte_val (pte) & _PAGE_SWP_EXCLUSIVE; +} + +static inline pte_t pte_swp_mkexclusive (pte_t pte) +{ +pte_val (pte) |= _PAGE_SWP_EXCLUSIVE; +return pte; +} + +static inline pte_t pte_swp_clear_exclusive (pte_t pte) +{ +pte_val (pte) &= ~_PAGE_SWP_EXCLUSIVE; +return pte; +} +extern void paging_init (void );#define pte_none (pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
_
Patches currently in -mm which might be from [email protected] are