kernel: Update MGLRU patchset
[openwrt/staging/dedeckeh.git] / target / linux / generic / backport-5.15 / 020-v6.1-17-mm-add-dummy-pmd_young-for-architectures-not-having-.patch
1 From c5ec455ebd2b488d91de9d8915a0c8036a2a04dd Mon Sep 17 00:00:00 2001
2 From: Juergen Gross <jgross@suse.com>
3 Date: Wed, 30 Nov 2022 14:49:41 -0800
4 Subject: [PATCH 17/29] mm: add dummy pmd_young() for architectures not having
5 it
6
7 In order to avoid #ifdeffery add a dummy pmd_young() implementation as a
8 fallback. This is required for the later patch "mm: introduce
9 arch_has_hw_nonleaf_pmd_young()".
10
11 Link: https://lkml.kernel.org/r/fd3ac3cd-7349-6bbd-890a-71a9454ca0b3@suse.com
12 Signed-off-by: Juergen Gross <jgross@suse.com>
13 Acked-by: Yu Zhao <yuzhao@google.com>
14 Cc: Borislav Petkov <bp@alien8.de>
15 Cc: Dave Hansen <dave.hansen@linux.intel.com>
16 Cc: Geert Uytterhoeven <geert@linux-m68k.org>
17 Cc: "H. Peter Anvin" <hpa@zytor.com>
18 Cc: Ingo Molnar <mingo@redhat.com>
19 Cc: Sander Eikelenboom <linux@eikelenboom.it>
20 Cc: Thomas Gleixner <tglx@linutronix.de>
21 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
22 ---
23 arch/mips/include/asm/pgtable.h | 1 +
24 arch/riscv/include/asm/pgtable.h | 1 +
25 arch/s390/include/asm/pgtable.h | 1 +
26 arch/sparc/include/asm/pgtable_64.h | 1 +
27 arch/x86/include/asm/pgtable.h | 1 +
28 include/linux/pgtable.h | 7 +++++++
29 6 files changed, 12 insertions(+)
30
31 diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
32 index 804889b70965..89ab8b4cf971 100644
33 --- a/arch/mips/include/asm/pgtable.h
34 +++ b/arch/mips/include/asm/pgtable.h
35 @@ -632,6 +632,7 @@ static inline pmd_t pmd_mkdirty(pmd_t pmd)
36 return pmd;
37 }
38
39 +#define pmd_young pmd_young
40 static inline int pmd_young(pmd_t pmd)
41 {
42 return !!(pmd_val(pmd) & _PAGE_ACCESSED);
43 diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
44 index 39b550310ec6..4a64e03dcdd4 100644
45 --- a/arch/riscv/include/asm/pgtable.h
46 +++ b/arch/riscv/include/asm/pgtable.h
47 @@ -531,6 +531,7 @@ static inline int pmd_dirty(pmd_t pmd)
48 return pte_dirty(pmd_pte(pmd));
49 }
50
51 +#define pmd_young pmd_young
52 static inline int pmd_young(pmd_t pmd)
53 {
54 return pte_young(pmd_pte(pmd));
55 diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
56 index b61426c9ef17..55ff4f22da2d 100644
57 --- a/arch/s390/include/asm/pgtable.h
58 +++ b/arch/s390/include/asm/pgtable.h
59 @@ -748,6 +748,7 @@ static inline int pmd_dirty(pmd_t pmd)
60 return (pmd_val(pmd) & _SEGMENT_ENTRY_DIRTY) != 0;
61 }
62
63 +#define pmd_young pmd_young
64 static inline int pmd_young(pmd_t pmd)
65 {
66 return (pmd_val(pmd) & _SEGMENT_ENTRY_YOUNG) != 0;
67 diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
68 index 4679e45c8348..bfd10179c137 100644
69 --- a/arch/sparc/include/asm/pgtable_64.h
70 +++ b/arch/sparc/include/asm/pgtable_64.h
71 @@ -712,6 +712,7 @@ static inline unsigned long pmd_dirty(pmd_t pmd)
72 return pte_dirty(pte);
73 }
74
75 +#define pmd_young pmd_young
76 static inline unsigned long pmd_young(pmd_t pmd)
77 {
78 pte_t pte = __pte(pmd_val(pmd));
79 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
80 index 01a1763123ff..c4b64ee357fd 100644
81 --- a/arch/x86/include/asm/pgtable.h
82 +++ b/arch/x86/include/asm/pgtable.h
83 @@ -136,6 +136,7 @@ static inline int pmd_dirty(pmd_t pmd)
84 return pmd_flags(pmd) & _PAGE_DIRTY;
85 }
86
87 +#define pmd_young pmd_young
88 static inline int pmd_young(pmd_t pmd)
89 {
90 return pmd_flags(pmd) & _PAGE_ACCESSED;
91 diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
92 index e6889556e0bf..dec3d890e814 100644
93 --- a/include/linux/pgtable.h
94 +++ b/include/linux/pgtable.h
95 @@ -164,6 +164,13 @@ static inline pte_t *virt_to_kpte(unsigned long vaddr)
96 return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
97 }
98
99 +#ifndef pmd_young
100 +static inline int pmd_young(pmd_t pmd)
101 +{
102 + return 0;
103 +}
104 +#endif
105 +
106 #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
107 extern int ptep_set_access_flags(struct vm_area_struct *vma,
108 unsigned long address, pte_t *ptep,
109 --
110 2.40.0
111