aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/include
diff options
context:
space:
mode:
authorAnton Ivanov <anton.ivanov@cambridgegreys.com>2018-12-05 07:37:41 -0500
committerRichard Weinberger <richard@nod.at>2018-12-27 16:48:34 -0500
commit8892d8545f2d0342b9c550defbfb165db237044b (patch)
tree0b48c4df948da4a350321e4d8067cf243562a37b /arch/um/include
parent38e3cbd9b82c815006c505ad2995013a61af143e (diff)
um: Avoid marking pages with "changed protection"
Changing protection is a very high cost operation in UML because in addition to an extra syscall it also interrupts mmap merge sequences generated by the tlb. While the condition is not particularly common it is worth avoiding. Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/include')
-rw-r--r--arch/um/include/asm/pgtable.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
index 7485398d0737..9c04562310b3 100644
--- a/arch/um/include/asm/pgtable.h
+++ b/arch/um/include/asm/pgtable.h
@@ -197,12 +197,17 @@ static inline pte_t pte_mkold(pte_t pte)
197 197
198static inline pte_t pte_wrprotect(pte_t pte) 198static inline pte_t pte_wrprotect(pte_t pte)
199{ 199{
200 pte_clear_bits(pte, _PAGE_RW); 200 if (likely(pte_get_bits(pte, _PAGE_RW)))
201 pte_clear_bits(pte, _PAGE_RW);
202 else
203 return pte;
201 return(pte_mknewprot(pte)); 204 return(pte_mknewprot(pte));
202} 205}
203 206
204static inline pte_t pte_mkread(pte_t pte) 207static inline pte_t pte_mkread(pte_t pte)
205{ 208{
209 if (unlikely(pte_get_bits(pte, _PAGE_USER)))
210 return pte;
206 pte_set_bits(pte, _PAGE_USER); 211 pte_set_bits(pte, _PAGE_USER);
207 return(pte_mknewprot(pte)); 212 return(pte_mknewprot(pte));
208} 213}
@@ -221,6 +226,8 @@ static inline pte_t pte_mkyoung(pte_t pte)
221 226
222static inline pte_t pte_mkwrite(pte_t pte) 227static inline pte_t pte_mkwrite(pte_t pte)
223{ 228{
229 if (unlikely(pte_get_bits(pte, _PAGE_RW)))
230 return pte;
224 pte_set_bits(pte, _PAGE_RW); 231 pte_set_bits(pte, _PAGE_RW);
225 return(pte_mknewprot(pte)); 232 return(pte_mknewprot(pte));
226} 233}