History

mm/arm64: 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. To do this, we pass pt_regs pointer into __do_page_fault().

Peter Xu committed 6 years ago

Commit 6a1bb021 parent 79fea6c1 file · +6 −23Browse files

Unified · Split

arch/arm64/mm/fault.c+6−23
@@ -404,7 +404,8 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re · 403 unmodified lines
404#define VM_FAULT_BADACCESS 0x020000404#define VM_FAULT_BADACCESS 0x020000
405 405
406static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,406static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
407 unsigned int mm_flags, unsigned long vm_flags)407 unsigned int mm_flags, unsigned long vm_flags,
408 struct pt_regs *regs)
408{409{
409 struct vm_area_struct *vma = find_vma(mm, addr);410 struct vm_area_struct *vma = find_vma(mm, addr);
410 411
@@ -428,7 +429,7 @@ static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr, · 17 unmodified lines
428 */429 */
429 if (!(vma->vm_flags & vm_flags))430 if (!(vma->vm_flags & vm_flags))
430 return VM_FAULT_BADACCESS;431 return VM_FAULT_BADACCESS;
431 return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags, NULL);432 return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags, regs);
432}433}
433 434
434static bool is_el0_instruction_abort(unsigned int esr)435static bool is_el0_instruction_abort(unsigned int esr)
@@ -450,7 +451,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, · 15 unmodified lines
450{451{
451 const struct fault_info *inf;452 const struct fault_info *inf;
452 struct mm_struct *mm = current->mm;453 struct mm_struct *mm = current->mm;
453 vm_fault_t fault, major = 0;454 vm_fault_t fault;
454 unsigned long vm_flags = VM_ACCESS_FLAGS;455 unsigned long vm_flags = VM_ACCESS_FLAGS;
455 unsigned int mm_flags = FAULT_FLAG_DEFAULT;456 unsigned int mm_flags = FAULT_FLAG_DEFAULT;
456 457
@@ -516,8 +517,7 @@ retry: · 59 unmodified lines
516#endif517#endif
517 }518 }
518 519
519 fault = __do_page_fault(mm, addr, mm_flags, vm_flags);520 fault = __do_page_fault(mm, addr, mm_flags, vm_flags, regs);
520 major |= fault & VM_FAULT_MAJOR;
521 521
522 /* Quick path to respond to signals */522 /* Quick path to respond to signals */
523 if (fault_signal_pending(fault, regs)) {523 if (fault_signal_pending(fault, regs)) {
@@ -538,25 +538,8 @@ retry: · 14 unmodified lines
538 * Handle the "normal" (no error) case first.538 * Handle the "normal" (no error) case first.
539 */539 */
540 if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP |540 if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP |
541 VM_FAULT_BADACCESS)))) {541 VM_FAULT_BADACCESS))))
542 /*
543 * Major/minor page fault accounting is only done
544 * once. If we go through a retry, it is extremely
545 * likely that the page will be found in page cache at
546 * that point.
547 */
548 if (major) {
549 current->maj_flt++;
550 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
551 addr);
552 } else {
553 current->min_flt++;
554 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
555 addr);
556 }
557
558 return 0;542 return 0;
559 }
560 543
561 /*544 /*
562 * If we are in kernel mode at this point, we have no context to545 * If we are in kernel mode at this point, we have no context to

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t