Skip to contentSkip to conversation

mm/x86: Use general page fault accounting

PATCH Superseded Peter Xu 2 participants 3 messages Jun 30, 2020 – Jul 3, 2020

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH v4 23/26 mm/x86: Use general page fault accounting

Use the general page fault accounting by passing regs into handle_mm_fault().

CC Dave Hansen <[email protected]>
CC Andy Lutomirski <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Ingo Molnar <[email protected]>
CC Borislav Petkov <[email protected]>
CC H. Peter Anvin <[email protected]>
---
 arch/x86/mm/fault.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
arch/x86/mm/fault.c +2 -15
index fe3ca00eb121..9ac80bb87781 100644
@@ -1140,7 +1140,7 @@ void do_user_addr_fault(struct pt_regs *regs,
 	struct vm_area_struct *vma;
 	struct task_struct *tsk;
 	struct mm_struct *mm;
-	vm_fault_t fault, major = 0;
+	vm_fault_t fault;
 	unsigned int flags = FAULT_FLAG_DEFAULT;
 
 	tsk = current;
@@ -1292,8 +1292,7 @@ void do_user_addr_fault(struct pt_regs *regs,
 	 * userland). The return to userland is identified whenever
 	 * FAULT_FLAG_USER|FAULT_FLAG_KILLABLE are both set in flags.
 	 */
-	fault = handle_mm_fault(vma, address, flags, NULL);
-	major |= fault & VM_FAULT_MAJOR;
+	fault = handle_mm_fault(vma, address, flags, regs);
 
 	/* Quick path to respond to signals */
 	if (fault_signal_pending(fault, regs)) {
@@ -1320,18 +1319,6 @@ void do_user_addr_fault(struct pt_regs *regs,
 		return;
 	}
 
-	/*
-	 * Major/minor page fault accounting. If any of the events
-	 * returned VM_FAULT_MAJOR, we account it as a major fault.
-	 */
-	if (major) {
-		tsk->maj_flt++;
-		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
-	} else {
-		tsk->min_flt++;
-		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
-	}
-
 	check_v8086_mode(regs, address, tsk);
 }
 NOKPROBE_SYMBOL(do_user_addr_fault);
Signature · 1 line
2.26.2
#1 lore raw
Quoted 1 line · Peter Xu

Use the general page fault accounting by passing regs into handle_mm_fault().

...

Quoted 4 lines
arch/x86/mm/fault.c +0 -4
-	/*
-	 * Major/minor page fault accounting. If any of the events
-	 * returned VM_FAULT_MAJOR, we account it as a major fault.
-	 */

arch/x86/mm/fault.c void do_user_addr_fault(struct pt_regs *regs, · line 1323

Quoted 10 lines
arch/x86/mm/fault.c +0 -8
-	if (major) {
-		tsk->maj_flt++;
-		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
-	} else {
-		tsk->min_flt++;
-		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
-	}
-
 	check_v8086_mode(regs, address, tsk);
 }

I did a quick grep and it wasn't obvious to me how PERF_COUNT_SW_PAGE_FAULTS_MIN/MAJ get bumped in the handle_mm_fault() path.

Are you sure they get set?

author
#2 lore raw

Hi, Dave,

Quoted 21 lines · Dave Hansen
Quoted 1 line · Peter Xu

Use the general page fault accounting by passing regs into handle_mm_fault().

...

Quoted 4 lines
arch/x86/mm/fault.c +0 -4
-	/*
-	 * Major/minor page fault accounting. If any of the events
-	 * returned VM_FAULT_MAJOR, we account it as a major fault.
-	 */

arch/x86/mm/fault.c void do_user_addr_fault(struct pt_regs *regs, · line 1323

Quoted 10 lines
arch/x86/mm/fault.c +0 -8
-	if (major) {
-		tsk->maj_flt++;
-		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
-	} else {
-		tsk->min_flt++;
-		perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
-	}
-
 	check_v8086_mode(regs, address, tsk);
 }

I did a quick grep and it wasn't obvious to me how PERF_COUNT_SW_PAGE_FAULTS_MIN/MAJ get bumped in the handle_mm_fault() path.

Quoted 1 line

Are you sure they get set?

Sorry for missing the context. This patch is based on the 1st patch of the same series:

https://lore.kernel.org/lkml/[email protected]/

Both of them are set there.

Thanks,

Signature · 1 line
Peter Xu