svn commit: r233925 - in head: sys/kern sys/sys sys/vm usr.bin/kdump usr.bin/ktrace

Andrey Zonov andrey at zonov.org
Tue Apr 10 19:47:27 UTC 2012


On 05.04.2012 21:13, John Baldwin wrote:
> Author: jhb
> Date: Thu Apr  5 17:13:14 2012
> New Revision: 233925
> URL: http://svn.freebsd.org/changeset/base/233925
>
> Log:
>    Add new ktrace records for the start and end of VM faults.  This gives
>    a pair of records similar to syscall entry and return that a user can
>    use to determine how long page faults take.  The new ktrace records are
>    enabled via the 'p' trace type, and are enabled in the default set of
>    trace points.
>
>    Reviewed by:	kib
>    MFC after:	2 weeks
>

Hi John,

Thanks a lot, this change is very useful!

And while you are here I would like to show you a patch which adds a 
"wmesg" to the context switch tracing.  It is not finished, it's just a 
concept.  Please review it and if you are interesting in that I'll 
finish it and will test more widely.

-- 
Andrey Zonov
-------------- next part --------------
Index: usr.bin/kdump/kdump.c
===================================================================
--- usr.bin/kdump/kdump.c	(revision 233925)
+++ usr.bin/kdump/kdump.c	(working copy)
@@ -1247,8 +1247,8 @@ ktrpsig(struct ktr_psig *psig)
 void
 ktrcsw(struct ktr_csw *cs)
 {
-	printf("%s %s\n", cs->out ? "stop" : "resume",
-		cs->user ? "user" : "kernel");
+	printf("%s %s \"%s\"\n", cs->out ? "stop" : "resume",
+		cs->user ? "user" : "kernel", cs->wmesg ? cs->wmesg : "");
 }
 
 #define	UTRACE_DLOPEN_START		1
Index: sys/sys/ktrace.h
===================================================================
--- sys/sys/ktrace.h	(revision 233925)
+++ sys/sys/ktrace.h	(working copy)
@@ -138,6 +138,7 @@ struct ktr_psig {
 struct ktr_csw {
 	int	out;	/* 1 if switch out, 0 if switch in */
 	int	user;	/* 1 if usermode (ivcsw), 0 if kernel (vcsw) */
+	char	wmesg[8];
 };
 
 /*
@@ -244,7 +245,7 @@ struct ktr_faultend {
 
 #ifdef	_KERNEL
 void	ktrnamei(char *);
-void	ktrcsw(int, int);
+void	ktrcsw(int, int, const char *);
 void	ktrpsig(int, sig_t, sigset_t *, int);
 void	ktrfault(vm_offset_t, int);
 void	ktrfaultend(int);
Index: sys/kern/kern_ktrace.c
===================================================================
--- sys/kern/kern_ktrace.c	(revision 233925)
+++ sys/kern/kern_ktrace.c	(working copy)
@@ -733,8 +733,9 @@ ktrpsig(sig, action, mask, code)
 }
 
 void
-ktrcsw(out, user)
+ktrcsw(out, user, wmesg)
 	int out, user;
+	const char *wmesg;
 {
 	struct thread *td = curthread;
 	struct ktr_request *req;
@@ -746,6 +747,8 @@ void
 	kc = &req->ktr_data.ktr_csw;
 	kc->out = out;
 	kc->user = user;
+	if (wmesg != NULL)
+		strncpy(kc->wmesg, wmesg, sizeof(kc->wmesg));
 	ktr_enqueuerequest(td, req);
 	ktrace_exit(td);
 }
Index: sys/kern/subr_trap.c
===================================================================
--- sys/kern/subr_trap.c	(revision 233925)
+++ sys/kern/subr_trap.c	(working copy)
@@ -219,7 +219,7 @@ ast(struct trapframe *framep)
 	if (flags & TDF_NEEDRESCHED) {
 #ifdef KTRACE
 		if (KTRPOINT(td, KTR_CSW))
-			ktrcsw(1, 1);
+			ktrcsw(1, 1, NULL);
 #endif
 		thread_lock(td);
 		sched_prio(td, td->td_user_pri);
@@ -227,7 +227,7 @@ ast(struct trapframe *framep)
 		thread_unlock(td);
 #ifdef KTRACE
 		if (KTRPOINT(td, KTR_CSW))
-			ktrcsw(0, 1);
+			ktrcsw(0, 1, NULL);
 #endif
 	}
 
Index: sys/kern/kern_condvar.c
===================================================================
--- sys/kern/kern_condvar.c	(revision 233925)
+++ sys/kern/kern_condvar.c	(working copy)
@@ -103,7 +103,7 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
 	lock_state = 0;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, NULL);
 #endif
 	CV_ASSERT(cvp, lock, td);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -140,7 +140,7 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, NULL);
 #endif
 	PICKUP_GIANT();
 	if (lock != &Giant.lock_object) {
@@ -162,7 +162,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object
 	td = curthread;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, NULL);
 #endif
 	CV_ASSERT(cvp, lock, td);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -197,7 +197,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, NULL);
 #endif
 	PICKUP_GIANT();
 }
@@ -220,7 +220,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *l
 	lock_state = 0;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, NULL);
 #endif
 	CV_ASSERT(cvp, lock, td);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -258,7 +258,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *l
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, NULL);
 #endif
 	PICKUP_GIANT();
 	if (lock != &Giant.lock_object) {
@@ -286,7 +286,7 @@ _cv_timedwait(struct cv *cvp, struct lock_object *
 	lock_state = 0;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, NULL);
 #endif
 	CV_ASSERT(cvp, lock, td);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -324,7 +324,7 @@ _cv_timedwait(struct cv *cvp, struct lock_object *
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, NULL);
 #endif
 	PICKUP_GIANT();
 	if (lock != &Giant.lock_object) {
@@ -353,7 +353,7 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_obje
 	lock_state = 0;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, NULL);
 #endif
 	CV_ASSERT(cvp, lock, td);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -392,7 +392,7 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_obje
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, NULL);
 #endif
 	PICKUP_GIANT();
 	if (lock != &Giant.lock_object) {
Index: sys/kern/kern_synch.c
===================================================================
--- sys/kern/kern_synch.c	(revision 233925)
+++ sys/kern/kern_synch.c	(working copy)
@@ -142,7 +142,7 @@ _sleep(void *ident, struct lock_object *lock, int
 	p = td->td_proc;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, wmesg);
 #endif
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
 	    "Sleeping on \"%s\"", wmesg);
@@ -236,7 +236,7 @@ _sleep(void *ident, struct lock_object *lock, int
 	}
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, wmesg);
 #endif
 	PICKUP_GIANT();
 	if (lock != NULL && lock != &Giant.lock_object && !(priority & PDROP)) {
@@ -298,7 +298,7 @@ msleep_spin(void *ident, struct mtx *mtx, const ch
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW)) {
 		sleepq_release(ident);
-		ktrcsw(1, 0);
+		ktrcsw(1, 0, wmesg);
 		sleepq_lock(ident);
 	}
 #endif
@@ -316,7 +316,7 @@ msleep_spin(void *ident, struct mtx *mtx, const ch
 	}
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_CSW))
-		ktrcsw(0, 0);
+		ktrcsw(0, 0, wmesg);
 #endif
 	PICKUP_GIANT();
 	mtx_lock_spin(mtx);


More information about the svn-src-all mailing list