[PATCH] PowerPC: rearrange/add trap markers in do_page_fault()

Sergei Shtylyov <[email protected]>
Newsgroups gmane.linux.kernel.tracing
Organization MontaVista Software Inc.
Message-ID <[email protected]>
Rearrange existing trap markers in PowerPC do_page_fault() to avoid duplicate
trap reporting in a certain case, and add the markers to some code paths that
were missed...
 
Signed-off-by: Sergei Shtylyov <[email protected]>

---
MIPS needs something along these lines as well.  Removing the trap tracepoints
from do_page_fault() was a bad move in the first place...

 arch/powerpc/mm/fault.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6-lttng/arch/powerpc/mm/fault.c
===================================================================
--- linux-2.6-lttng.orig/arch/powerpc/mm/fault.c
+++ linux-2.6-lttng/arch/powerpc/mm/fault.c
@@ -199,12 +199,15 @@ int __kprobes do_page_fault(struct pt_re
 	if (in_atomic() || mm == NULL) {
 		if (!user_mode(regs))
 			return SIGSEGV;
+		MARK(kernel_trap_entry, "%ld struct pt_regs %p",
+		     regs->trap, regs);
 		/* in_atomic() in user mode is really bad,
 		   as is current->mm == NULL. */
 		printk(KERN_EMERG "Page fault in user mode with"
 		       "in_atomic() = %d mm = %p\n", in_atomic(), mm);
 		printk(KERN_EMERG "NIP = %lx  MSR = %lx\n",
 		       regs->nip, regs->msr);
+		MARK(kernel_trap_exit, MARK_NOARGS);
 		die("Weird page fault", regs, SIGSEGV);
 	}
 
@@ -311,6 +314,8 @@ good_area:
 			if (pte_present(*ptep)) {
 				struct page *page = pte_page(*ptep);
 
+				MARK(kernel_trap_entry, "%ld struct pt_regs %p",
+				     regs->trap, regs);
 				if (!test_bit(PG_arch_1, &page->flags)) {
 					flush_dcache_icache_page(page);
 					set_bit(PG_arch_1, &page->flags);
@@ -319,6 +324,7 @@ good_area:
 				_tlbie(address);
 				pte_unmap_unlock(ptep, ptl);
 				up_read(&mm->mmap_sem);
+				MARK(kernel_trap_exit, MARK_NOARGS);
 				return 0;
 			}
 			pte_unmap_unlock(ptep, ptl);
@@ -342,30 +348,26 @@ good_area:
 	 * make sure we exit gracefully rather than endlessly redo
 	 * the fault.
 	 */
+	MARK(kernel_trap_entry, "%ld struct pt_regs %p", regs->trap, regs);
  survive:
- 	MARK(kernel_trap_entry, "%ld struct pt_regs %p",
-		regs->trap, regs);
 	switch (handle_mm_fault(mm, vma, address, is_write)) {
 
 	case VM_FAULT_MINOR:
-		MARK(kernel_trap_exit, MARK_NOARGS);
 		current->min_flt++;
 		break;
 	case VM_FAULT_MAJOR:
-		MARK(kernel_trap_exit, MARK_NOARGS);
 		current->maj_flt++;
 		break;
 	case VM_FAULT_SIGBUS:
-		MARK(kernel_trap_exit, MARK_NOARGS);
 		goto do_sigbus;
 	case VM_FAULT_OOM:
-		MARK(kernel_trap_exit, MARK_NOARGS);
 		goto out_of_memory;
 	default:
 		BUG();
 	}
 
 	up_read(&mm->mmap_sem);
+	MARK(kernel_trap_exit, MARK_NOARGS);
 	return 0;
 
 bad_area:
@@ -398,6 +400,7 @@ out_of_memory:
 		goto survive;
 	}
 	printk("VM: killing process %s\n", current->comm);
+	MARK(kernel_trap_exit, MARK_NOARGS);
 	if (user_mode(regs))
 		do_exit(SIGKILL);
 	return SIGKILL;
@@ -410,8 +413,10 @@ do_sigbus:
 		info.si_code = BUS_ADRERR;
 		info.si_addr = (void __user *)address;
 		force_sig_info(SIGBUS, &info, current);
+		MARK(kernel_trap_exit, MARK_NOARGS);
 		return 0;
 	}
+	MARK(kernel_trap_exit, MARK_NOARGS);
 	return SIGBUS;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.