Skip to content

Commit daf7bf5

Browse files
xzpetertorvalds
authored andcommitted
mm/nds32: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened. Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem. Signed-off-by: Peter Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Greentime Hu <[email protected]> Cc: Nick Hu <[email protected]> Cc: Vincent Chen <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2558fd7 commit daf7bf5

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

arch/nds32/mm/fault.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ void do_page_fault(unsigned long entry, unsigned long addr,
121121
if (unlikely(faulthandler_disabled() || !mm))
122122
goto no_context;
123123

124+
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
125+
124126
/*
125127
* As per x86, we may deadlock here. However, since the kernel only
126128
* validly references user space from well defined areas of the code,
@@ -206,7 +208,7 @@ void do_page_fault(unsigned long entry, unsigned long addr,
206208
* the fault.
207209
*/
208210

209-
fault = handle_mm_fault(vma, addr, flags, NULL);
211+
fault = handle_mm_fault(vma, addr, flags, regs);
210212

211213
/*
212214
* If we need to retry but a fatal signal is pending, handle the
@@ -228,22 +230,7 @@ void do_page_fault(unsigned long entry, unsigned long addr,
228230
goto bad_area;
229231
}
230232

231-
/*
232-
* Major/minor page fault accounting is only done on the initial
233-
* attempt. If we go through a retry, it is extremely likely that the
234-
* page will be found in page cache at that point.
235-
*/
236-
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
237233
if (flags & FAULT_FLAG_ALLOW_RETRY) {
238-
if (fault & VM_FAULT_MAJOR) {
239-
tsk->maj_flt++;
240-
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,
241-
1, regs, addr);
242-
} else {
243-
tsk->min_flt++;
244-
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
245-
1, regs, addr);
246-
}
247234
if (fault & VM_FAULT_RETRY) {
248235
flags |= FAULT_FLAG_TRIED;
249236

0 commit comments

Comments
 (0)