Module Name:    src
Committed By:   matt
Date:           Wed Mar  5 02:10:39 UTC 2014

Modified Files:
        src/sys/arch/arm/arm32: fault.c

Log Message:
Only do UVMHIST_LOG is maphist have its entry buffer initialized


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/arm/arm32/fault.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm32/fault.c
diff -u src/sys/arch/arm/arm32/fault.c:1.96 src/sys/arch/arm/arm32/fault.c:1.97
--- src/sys/arch/arm/arm32/fault.c:1.96	Wed Feb 26 07:48:29 2014
+++ src/sys/arch/arm/arm32/fault.c	Wed Mar  5 02:10:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.96 2014/02/26 07:48:29 skrll Exp $	*/
+/*	$NetBSD: fault.c,v 1.97 2014/03/05 02:10:39 matt Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -81,7 +81,7 @@
 #include "opt_kgdb.h"
 
 #include <sys/types.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.96 2014/02/26 07:48:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.97 2014/03/05 02:10:39 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -242,7 +242,12 @@ data_abort_handler(trapframe_t *tf)
 	int error;
 	ksiginfo_t ksi;
 
-	UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist);
+	UVMHIST_FUNC(__func__);
+#ifdef UVMHIST
+	if (__predict_true(maphist.e)) {
+		UVMHIST_CALLED(maphist);
+	}
+#endif
 
 	/* Grab FAR/FSR before enabling interrupts */
 	far = cpu_faultaddress();
@@ -258,10 +263,14 @@ data_abort_handler(trapframe_t *tf)
 
 	/* Get the current lwp structure */
 
-	UVMHIST_LOG(maphist, " (l=%#x, far=%#x, fsr=%#x",
-	    l, far, fsr, 0);
-	UVMHIST_LOG(maphist, "  tf=%#x, pc=%#x)",
-	    tf, tf->tf_pc, 0, 0);
+#ifdef UVMHIST
+	if (__predict_true(maphist.e)) {
+		UVMHIST_LOG(maphist, " (l=%#x, far=%#x, fsr=%#x",
+		    l, far, fsr, 0);
+		UVMHIST_LOG(maphist, "  tf=%#x, pc=%#x)",
+		    tf, tf->tf_pc, 0, 0);
+	}
+#endif
 
 	/* Data abort came from user mode? */
 	bool user = (TRAP_USERMODE(tf) != 0);
@@ -461,7 +470,11 @@ data_abort_handler(trapframe_t *tf)
 	last_fault_code = fsr;
 #endif
 	if (pmap_fault_fixup(map->pmap, va, ftype, user)) {
-		UVMHIST_LOG(maphist, " <- ref/mod emul", 0, 0, 0, 0);
+#ifdef UVMHIST
+		if (__predict_true(maphist.e)) {
+			UVMHIST_LOG(maphist, " <- ref/mod emul", 0, 0, 0, 0);
+		}
+#endif
 		goto out;
 	}
 
@@ -485,7 +498,11 @@ data_abort_handler(trapframe_t *tf)
 			uvm_grow(l->l_proc, va); /* Record any stack growth */
 		else
 			ucas_ras_check(tf);
-		UVMHIST_LOG(maphist, " <- uvm", 0, 0, 0, 0);
+#ifdef UVMHIST
+		if (__predict_true(maphist.e)) {
+			UVMHIST_LOG(maphist, " <- uvm", 0, 0, 0, 0);
+		}
+#endif
 		goto out;
 	}
 
@@ -514,7 +531,11 @@ data_abort_handler(trapframe_t *tf)
 	ksi.ksi_code = (error == EACCES) ? SEGV_ACCERR : SEGV_MAPERR;
 	ksi.ksi_addr = (uint32_t *)(intptr_t) far;
 	ksi.ksi_trap = fsr;
-	UVMHIST_LOG(maphist, " <- error (%d)", error, 0, 0, 0);
+#ifdef UVMHIST
+	if (__predict_true(maphist.e)) {
+		UVMHIST_LOG(maphist, " <- error (%d)", error, 0, 0, 0);
+	}
+#endif
 
 do_trapsignal:
 	call_trapsignal(l, tf, &ksi);
@@ -782,7 +803,12 @@ prefetch_abort_handler(trapframe_t *tf)
 	ksiginfo_t ksi;
 	int error, user;
 
-	UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist);
+	UVMHIST_FUNC(__func__);
+#ifdef UVMHIST
+	if (__predict_true(maphist.e)) {
+		UVMHIST_CALLED(maphist);
+	}
+#endif
 
 	/* Update vmmeter statistics */
 	curcpu()->ci_data.cpu_ntrap++;
@@ -826,8 +852,12 @@ prefetch_abort_handler(trapframe_t *tf)
 	/* Get fault address */
 	fault_pc = tf->tf_pc;
 	lwp_settrapframe(l, tf);
-	UVMHIST_LOG(maphist, " (pc=0x%x, l=0x%x, tf=0x%x)", fault_pc, l, tf,
-	    0);
+#ifdef UVMHIST
+	if (__predict_true(maphist.e)) {
+		UVMHIST_LOG(maphist, " (pc=0x%x, l=0x%x, tf=0x%x)",
+		    fault_pc, l, tf, 0);
+	}
+#endif
 
 	/* Ok validate the address, can only execute in USER space */
 	if (__predict_false(fault_pc >= VM_MAXUSER_ADDRESS ||
@@ -850,7 +880,11 @@ prefetch_abort_handler(trapframe_t *tf)
 	last_fault_code = -1;
 #endif
 	if (pmap_fault_fixup(map->pmap, va, VM_PROT_READ|VM_PROT_EXECUTE, 1)) {
-		UVMHIST_LOG (maphist, " <- emulated", 0, 0, 0, 0);
+#ifdef UVMHIST
+		if (__predict_true(maphist.e)) {
+			UVMHIST_LOG (maphist, " <- emulated", 0, 0, 0, 0);
+		}
+#endif
 		goto out;
 	}
 
@@ -865,12 +899,20 @@ prefetch_abort_handler(trapframe_t *tf)
 	error = uvm_fault(map, va, VM_PROT_READ);
 
 	if (__predict_true(error == 0)) {
-		UVMHIST_LOG (maphist, " <- uvm", 0, 0, 0, 0);
+#ifdef UVMHIST
+		if (__predict_true(maphist.e)) {
+			UVMHIST_LOG (maphist, " <- uvm", 0, 0, 0, 0);
+		}
+#endif
 		goto out;
 	}
 	KSI_INIT_TRAP(&ksi);
 
-	UVMHIST_LOG (maphist, " <- fatal (%d)", error, 0, 0, 0);
+#ifdef UVMHIST
+	if (__predict_true(maphist.e)) {
+		UVMHIST_LOG (maphist, " <- fatal (%d)", error, 0, 0, 0);
+	}
+#endif
 	if (error == ENOMEM) {
 		printf("UVM: pid %d (%s), uid %d killed: "
 		    "out of swap\n", l->l_proc->p_pid, l->l_proc->p_comm,

Reply via email to