Skip to content

Commit 45cac65

Browse files
Shaohua Litorvalds
authored andcommitted
readahead: fault retry breaks mmap file read random detection
.fault now can retry. The retry can break state machine of .fault. In filemap_fault, if page is miss, ra->mmap_miss is increased. In the second try, since the page is in page cache now, ra->mmap_miss is decreased. And these are done in one fault, so we can't detect random mmap file access. Add a new flag to indicate .fault is tried once. In the second try, skip ra->mmap_miss decreasing. The filemap_fault state machine is ok with it. I only tested x86, didn't test other archs, but looks the change for other archs is obvious, but who knows :) Signed-off-by: Shaohua Li <shaohua.li@fusionio.com> Cc: Rik van Riel <riel@redhat.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e79bee2 commit 45cac65

20 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎arch/arm/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
336336
/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
337337
* of starvation. */
338338
flags &= ~FAULT_FLAG_ALLOW_RETRY;
339+
flags |= FAULT_FLAG_TRIED;
339340
goto retry;
340341
}
341342
}

‎arch/avr32/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
152152
tsk->min_flt++;
153153
if (fault & VM_FAULT_RETRY) {
154154
flags &= ~FAULT_FLAG_ALLOW_RETRY;
155+
flags |= FAULT_FLAG_TRIED;
155156

156157
/*
157158
* No need to up_read(&mm->mmap_sem) as we would have

‎arch/cris/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
186186
tsk->min_flt++;
187187
if (fault & VM_FAULT_RETRY) {
188188
flags &= ~FAULT_FLAG_ALLOW_RETRY;
189+
flags |= FAULT_FLAG_TRIED;
189190

190191
/*
191192
* No need to up_read(&mm->mmap_sem) as we would

‎arch/hexagon/mm/vm_fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)
113113
current->min_flt++;
114114
if (fault & VM_FAULT_RETRY) {
115115
flags &= ~FAULT_FLAG_ALLOW_RETRY;
116+
flags |= FAULT_FLAG_TRIED;
116117
goto retry;
117118
}
118119
}

‎arch/ia64/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
184184
current->min_flt++;
185185
if (fault & VM_FAULT_RETRY) {
186186
flags &= ~FAULT_FLAG_ALLOW_RETRY;
187+
flags |= FAULT_FLAG_TRIED;
187188

188189
/* No need to up_read(&mm->mmap_sem) as we would
189190
* have already released it in __lock_page_or_retry

‎arch/m68k/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
170170
/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
171171
* of starvation. */
172172
flags &= ~FAULT_FLAG_ALLOW_RETRY;
173+
flags |= FAULT_FLAG_TRIED;
173174

174175
/*
175176
* No need to up_read(&mm->mmap_sem) as we would

‎arch/microblaze/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
233233
current->min_flt++;
234234
if (fault & VM_FAULT_RETRY) {
235235
flags &= ~FAULT_FLAG_ALLOW_RETRY;
236+
flags |= FAULT_FLAG_TRIED;
236237

237238
/*
238239
* No need to up_read(&mm->mmap_sem) as we would

‎arch/mips/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, unsigned long writ
171171
}
172172
if (fault & VM_FAULT_RETRY) {
173173
flags &= ~FAULT_FLAG_ALLOW_RETRY;
174+
flags |= FAULT_FLAG_TRIED;
174175

175176
/*
176177
* No need to up_read(&mm->mmap_sem) as we would

‎arch/openrisc/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
183183
tsk->min_flt++;
184184
if (fault & VM_FAULT_RETRY) {
185185
flags &= ~FAULT_FLAG_ALLOW_RETRY;
186+
flags |= FAULT_FLAG_TRIED;
186187

187188
/* No need to up_read(&mm->mmap_sem) as we would
188189
* have already released it in __lock_page_or_retry

‎arch/powerpc/mm/fault.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
451451
/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
452452
* of starvation. */
453453
flags &= ~FAULT_FLAG_ALLOW_RETRY;
454+
flags |= FAULT_FLAG_TRIED;
454455
goto retry;
455456
}
456457
}

0 commit comments

Comments
 (0)