Blame view
mm/pgtable-generic.c
4.77 KB
e2cda3226 thp: add pmd mang... |
1 2 3 4 5 6 7 |
/* * mm/pgtable-generic.c * * Generic pgtable methods declared in asm-generic/pgtable.h * * Copyright (C) 2010 Linus Torvalds */ |
f95ba941d mm/pgtable-generi... |
8 |
#include <linux/pagemap.h> |
e2cda3226 thp: add pmd mang... |
9 10 |
#include <asm/tlb.h> #include <asm-generic/pgtable.h> |
bc4b4448d mm: move pgtable ... |
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/* * If a p?d_bad entry is found while walking page tables, report * the error, before resetting entry to p?d_none. Usually (but * very seldom) called out from the p?d_none_or_clear_bad macros. */ void pgd_clear_bad(pgd_t *pgd) { pgd_ERROR(*pgd); pgd_clear(pgd); } void pud_clear_bad(pud_t *pud) { pud_ERROR(*pud); pud_clear(pud); } void pmd_clear_bad(pmd_t *pmd) { pmd_ERROR(*pmd); pmd_clear(pmd); } |
e2cda3226 thp: add pmd mang... |
34 35 |
#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS /* |
cef23d9db mm,generic: only ... |
36 37 |
* Only sets the access flags (dirty, accessed), as well as write * permission. Furthermore, we know it always gets set to a "more |
e2cda3226 thp: add pmd mang... |
38 39 40 41 42 43 44 45 46 47 48 49 50 |
* permissive" setting, which allows most architectures to optimize * this. We return whether the PTE actually changed, which in turn * instructs the caller to do things like update__mmu_cache. This * used to be done in the caller, but sparc needs minor faults to * force that call on sun4c so we changed this macro slightly */ int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address, pte_t *ptep, pte_t entry, int dirty) { int changed = !pte_same(*ptep, entry); if (changed) { set_pte_at(vma->vm_mm, address, ptep, entry); |
cef23d9db mm,generic: only ... |
51 |
flush_tlb_fix_spurious_fault(vma, address); |
e2cda3226 thp: add pmd mang... |
52 53 54 55 |
} return changed; } #endif |
52585bcc2 mm: group pte rel... |
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
#ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { int young; young = ptep_test_and_clear_young(vma, address, ptep); if (young) flush_tlb_page(vma, address); return young; } #endif #ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { struct mm_struct *mm = (vma)->vm_mm; pte_t pte; pte = ptep_get_and_clear(mm, address, ptep); if (pte_accessible(mm, pte)) flush_tlb_page(vma, address); return pte; } #endif |
bd5e88ad7 mm,thp: reduce if... |
80 |
#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
e2cda3226 thp: add pmd mang... |
81 82 83 84 85 |
#ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t entry, int dirty) { |
e2cda3226 thp: add pmd mang... |
86 87 88 89 |
int changed = !pmd_same(*pmdp, entry); VM_BUG_ON(address & ~HPAGE_PMD_MASK); if (changed) { set_pmd_at(vma->vm_mm, address, pmdp, entry); |
12ebc1581 mm,thp: introduce... |
90 |
flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
e2cda3226 thp: add pmd mang... |
91 92 |
} return changed; |
e2cda3226 thp: add pmd mang... |
93 94 |
} #endif |
e2cda3226 thp: add pmd mang... |
95 96 97 98 99 |
#ifndef __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH int pmdp_clear_flush_young(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { int young; |
d8c37c480 thp: add HPAGE_PM... |
100 |
VM_BUG_ON(address & ~HPAGE_PMD_MASK); |
e2cda3226 thp: add pmd mang... |
101 102 |
young = pmdp_test_and_clear_young(vma, address, pmdp); if (young) |
12ebc1581 mm,thp: introduce... |
103 |
flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
e2cda3226 thp: add pmd mang... |
104 105 106 |
return young; } #endif |
8809aa2d2 mm: clarify that ... |
107 |
#ifndef __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH |
8809aa2d2 mm: clarify that ... |
108 109 |
pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) |
e2cda3226 thp: add pmd mang... |
110 111 |
{ pmd_t pmd; |
e2cda3226 thp: add pmd mang... |
112 |
VM_BUG_ON(address & ~HPAGE_PMD_MASK); |
5c7fb56e5 mm, dax: dax-pmd ... |
113 |
VM_BUG_ON(!pmd_trans_huge(*pmdp) && !pmd_devmap(*pmdp)); |
8809aa2d2 mm: clarify that ... |
114 |
pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp); |
12ebc1581 mm,thp: introduce... |
115 |
flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
e2cda3226 thp: add pmd mang... |
116 117 118 |
return pmd; } #endif |
e3ebcf643 thp: remove assum... |
119 |
#ifndef __HAVE_ARCH_PGTABLE_DEPOSIT |
6b0b50b06 mm/THP: add pmd a... |
120 121 |
void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, pgtable_t pgtable) |
e3ebcf643 thp: remove assum... |
122 |
{ |
c4088ebdc mm: convert the r... |
123 |
assert_spin_locked(pmd_lockptr(mm, pmdp)); |
e3ebcf643 thp: remove assum... |
124 125 |
/* FIFO */ |
c389a250a mm, thp: do not a... |
126 |
if (!pmd_huge_pte(mm, pmdp)) |
e3ebcf643 thp: remove assum... |
127 128 |
INIT_LIST_HEAD(&pgtable->lru); else |
c389a250a mm, thp: do not a... |
129 130 |
list_add(&pgtable->lru, &pmd_huge_pte(mm, pmdp)->lru); pmd_huge_pte(mm, pmdp) = pgtable; |
e3ebcf643 thp: remove assum... |
131 |
} |
e3ebcf643 thp: remove assum... |
132 133 134 |
#endif #ifndef __HAVE_ARCH_PGTABLE_WITHDRAW |
e3ebcf643 thp: remove assum... |
135 |
/* no "address" argument so destroys page coloring of some arch */ |
6b0b50b06 mm/THP: add pmd a... |
136 |
pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) |
e3ebcf643 thp: remove assum... |
137 138 |
{ pgtable_t pgtable; |
c4088ebdc mm: convert the r... |
139 |
assert_spin_locked(pmd_lockptr(mm, pmdp)); |
e3ebcf643 thp: remove assum... |
140 141 |
/* FIFO */ |
c389a250a mm, thp: do not a... |
142 |
pgtable = pmd_huge_pte(mm, pmdp); |
146693471 mm, thp: use list... |
143 144 145 |
pmd_huge_pte(mm, pmdp) = list_first_entry_or_null(&pgtable->lru, struct page, lru); if (pmd_huge_pte(mm, pmdp)) |
e3ebcf643 thp: remove assum... |
146 |
list_del(&pgtable->lru); |
e3ebcf643 thp: remove assum... |
147 148 |
return pgtable; } |
e3ebcf643 thp: remove assum... |
149 |
#endif |
46dcde735 thp: introduce pm... |
150 151 |
#ifndef __HAVE_ARCH_PMDP_INVALIDATE |
46dcde735 thp: introduce pm... |
152 153 154 |
void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { |
67f87463d mm: clear pmd_num... |
155 |
pmd_t entry = *pmdp; |
ce8369bcb mm: actually clea... |
156 |
set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry)); |
12ebc1581 mm,thp: introduce... |
157 |
flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
46dcde735 thp: introduce pm... |
158 |
} |
46dcde735 thp: introduce pm... |
159 |
#endif |
f28b6ff8c powerpc/mm: use g... |
160 161 |
#ifndef pmdp_collapse_flush |
f28b6ff8c powerpc/mm: use g... |
162 163 164 |
pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { |
8809aa2d2 mm: clarify that ... |
165 166 167 168 |
/* * pmd and hugepage pte format are same. So we could * use the same function. */ |
f28b6ff8c powerpc/mm: use g... |
169 170 171 172 |
pmd_t pmd; VM_BUG_ON(address & ~HPAGE_PMD_MASK); VM_BUG_ON(pmd_trans_huge(*pmdp)); |
8809aa2d2 mm: clarify that ... |
173 |
pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp); |
6a6ac72fd mm,thp: khugepage... |
174 175 176 |
/* collapse entails shooting down ptes not pmd */ flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
f28b6ff8c powerpc/mm: use g... |
177 178 |
return pmd; } |
f28b6ff8c powerpc/mm: use g... |
179 |
#endif |
bd5e88ad7 mm,thp: reduce if... |
180 |
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |