Skip to content

Commit a9252aa

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm: Move hugetlb and THP related pmd accessors to pgtable.h
Here we create pgtable-64/4k.h and move pmd accessors that are common between hash and radix there. We can't do much sharing with 4K Linux page size because 4K Linux page size with hash config doesn't support THP. So for now it is empty. In later patches we will add functions that does conditional hash/radix accessors there. Signed-off-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent ac94ac7 commit a9252aa

File tree

4 files changed

+108
-83
lines changed

4 files changed

+108
-83
lines changed

arch/powerpc/include/asm/book3s/64/hash-64k.h

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -118,57 +118,6 @@ static inline int remap_4k_pfn(struct vm_area_struct *vma, unsigned long addr,
118118
#define H_PUD_TABLE_SIZE (sizeof(pud_t) << PUD_INDEX_SIZE)
119119
#define H_PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
120120

121-
#ifdef CONFIG_HUGETLB_PAGE
122-
/*
123-
* We have PGD_INDEX_SIZ = 12 and PTE_INDEX_SIZE = 8, so that we can have
124-
* 16GB hugepage pte in PGD and 16MB hugepage pte at PMD;
125-
*
126-
* Defined in such a way that we can optimize away code block at build time
127-
* if CONFIG_HUGETLB_PAGE=n.
128-
*/
129-
static inline int pmd_huge(pmd_t pmd)
130-
{
131-
/*
132-
* leaf pte for huge page
133-
*/
134-
return !!(pmd_val(pmd) & _PAGE_PTE);
135-
}
136-
137-
static inline int pud_huge(pud_t pud)
138-
{
139-
/*
140-
* leaf pte for huge page
141-
*/
142-
return !!(pud_val(pud) & _PAGE_PTE);
143-
}
144-
145-
static inline int pgd_huge(pgd_t pgd)
146-
{
147-
/*
148-
* leaf pte for huge page
149-
*/
150-
return !!(pgd_val(pgd) & _PAGE_PTE);
151-
}
152-
#define pgd_huge pgd_huge
153-
154-
#ifdef CONFIG_DEBUG_VM
155-
extern int hugepd_ok(hugepd_t hpd);
156-
#define is_hugepd(hpd) (hugepd_ok(hpd))
157-
#else
158-
/*
159-
* With 64k page size, we have hugepage ptes in the pgd and pmd entries. We don't
160-
* need to setup hugepage directory for them. Our pte and page directory format
161-
* enable us to have this enabled.
162-
*/
163-
static inline int hugepd_ok(hugepd_t hpd)
164-
{
165-
return 0;
166-
}
167-
#define is_hugepd(pdep) 0
168-
#endif /* CONFIG_DEBUG_VM */
169-
170-
#endif /* CONFIG_HUGETLB_PAGE */
171-
172121
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
173122
extern unsigned long pmd_hugepage_update(struct mm_struct *mm,
174123
unsigned long addr,
@@ -239,44 +188,12 @@ static inline int pmd_trans_huge(pmd_t pmd)
239188
(_PAGE_PTE | H_PAGE_THP_HUGE));
240189
}
241190

242-
static inline int pmd_large(pmd_t pmd)
243-
{
244-
return !!(pmd_val(pmd) & _PAGE_PTE);
245-
}
246-
247-
static inline pmd_t pmd_mknotpresent(pmd_t pmd)
248-
{
249-
return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT);
250-
}
251-
252191
#define __HAVE_ARCH_PMD_SAME
253192
static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
254193
{
255194
return (((pmd_raw(pmd_a) ^ pmd_raw(pmd_b)) & ~cpu_to_be64(_PAGE_HPTEFLAGS)) == 0);
256195
}
257196

258-
static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
259-
unsigned long addr, pmd_t *pmdp)
260-
{
261-
unsigned long old;
262-
263-
if ((pmd_val(*pmdp) & (_PAGE_ACCESSED | H_PAGE_HASHPTE)) == 0)
264-
return 0;
265-
old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED, 0);
266-
return ((old & _PAGE_ACCESSED) != 0);
267-
}
268-
269-
#define __HAVE_ARCH_PMDP_SET_WRPROTECT
270-
static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
271-
pmd_t *pmdp)
272-
{
273-
274-
if ((pmd_val(*pmdp) & _PAGE_WRITE) == 0)
275-
return;
276-
277-
pmd_hugepage_update(mm, addr, pmdp, _PAGE_WRITE, 0);
278-
}
279-
280197
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
281198
#endif /* __ASSEMBLY__ */
282199

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef _ASM_POWERPC_BOOK3S_64_PGTABLE_4K_H
2+
#define _ASM_POWERPC_BOOK3S_64_PGTABLE_4K_H
3+
/*
4+
* hash 4k can't share hugetlb and also doesn't support THP
5+
*/
6+
7+
#endif /*_ASM_POWERPC_BOOK3S_64_PGTABLE_4K_H */
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#ifndef _ASM_POWERPC_BOOK3S_64_PGTABLE_64K_H
2+
#define _ASM_POWERPC_BOOK3S_64_PGTABLE_64K_H
3+
4+
#ifndef __ASSEMBLY__
5+
#ifdef CONFIG_HUGETLB_PAGE
6+
/*
7+
* We have PGD_INDEX_SIZ = 12 and PTE_INDEX_SIZE = 8, so that we can have
8+
* 16GB hugepage pte in PGD and 16MB hugepage pte at PMD;
9+
*
10+
* Defined in such a way that we can optimize away code block at build time
11+
* if CONFIG_HUGETLB_PAGE=n.
12+
*/
13+
static inline int pmd_huge(pmd_t pmd)
14+
{
15+
/*
16+
* leaf pte for huge page
17+
*/
18+
return !!(pmd_val(pmd) & _PAGE_PTE);
19+
}
20+
21+
static inline int pud_huge(pud_t pud)
22+
{
23+
/*
24+
* leaf pte for huge page
25+
*/
26+
return !!(pud_val(pud) & _PAGE_PTE);
27+
}
28+
29+
static inline int pgd_huge(pgd_t pgd)
30+
{
31+
/*
32+
* leaf pte for huge page
33+
*/
34+
return !!(pgd_val(pgd) & _PAGE_PTE);
35+
}
36+
#define pgd_huge pgd_huge
37+
38+
#ifdef CONFIG_DEBUG_VM
39+
extern int hugepd_ok(hugepd_t hpd);
40+
#define is_hugepd(hpd) (hugepd_ok(hpd))
41+
#else
42+
/*
43+
* With 64k page size, we have hugepage ptes in the pgd and pmd entries. We don't
44+
* need to setup hugepage directory for them. Our pte and page directory format
45+
* enable us to have this enabled.
46+
*/
47+
static inline int hugepd_ok(hugepd_t hpd)
48+
{
49+
return 0;
50+
}
51+
#define is_hugepd(pdep) 0
52+
#endif /* CONFIG_DEBUG_VM */
53+
54+
#endif /* CONFIG_HUGETLB_PAGE */
55+
56+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
57+
static inline int pmd_large(pmd_t pmd)
58+
{
59+
return !!(pmd_val(pmd) & _PAGE_PTE);
60+
}
61+
62+
static inline pmd_t pmd_mknotpresent(pmd_t pmd)
63+
{
64+
return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT);
65+
}
66+
/*
67+
* For radix we should always find H_PAGE_HASHPTE zero. Hence
68+
* the below will work for radix too
69+
*/
70+
static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
71+
unsigned long addr, pmd_t *pmdp)
72+
{
73+
unsigned long old;
74+
75+
if ((pmd_val(*pmdp) & (_PAGE_ACCESSED | H_PAGE_HASHPTE)) == 0)
76+
return 0;
77+
old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED, 0);
78+
return ((old & _PAGE_ACCESSED) != 0);
79+
}
80+
81+
#define __HAVE_ARCH_PMDP_SET_WRPROTECT
82+
static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
83+
pmd_t *pmdp)
84+
{
85+
86+
if ((pmd_val(*pmdp) & _PAGE_WRITE) == 0)
87+
return;
88+
89+
pmd_hugepage_update(mm, addr, pmdp, _PAGE_WRITE, 0);
90+
}
91+
92+
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
93+
#endif /* __ASSEMBLY__ */
94+
#endif /*_ASM_POWERPC_BOOK3S_64_PGTABLE_64K_H */

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ extern unsigned long __pgd_table_size;
206206

207207
#include <asm/book3s/64/hash.h>
208208
#include <asm/book3s/64/radix.h>
209+
210+
#ifdef CONFIG_PPC_64K_PAGES
211+
#include <asm/book3s/64/pgtable-64k.h>
212+
#else
213+
#include <asm/book3s/64/pgtable-4k.h>
214+
#endif
215+
209216
#include <asm/barrier.h>
210217

211218
/*

0 commit comments

Comments
 (0)