On 11.04.2012 20:02, John Baldwin wrote:
On Tuesday, April 10, 2012 3:47:23 pm Andrey Zonov wrote:
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.
Ah, this looks fairly neat. However, I think you will need a few changes:
1) You will want to make kdump handle either the old or new size of struct
ktr_csw. (The size of the record is in the header, so as long as you have
a 'struct ktr_csw_old' you can handle this fairly easily.)
It's a good suggestion. I've implemented that and tested.
2) cs->wmesg is never NULL. Instead, it should probably just always print it
out.
Agree.
3) condvar's have a valid wmesg.
Yes, I found it in 5 minutes after sending mail.
Please look at updated patch.
--
Andrey Zonov
Index: usr.bin/kdump/kdump.c
===================================================================
--- usr.bin/kdump/kdump.c (revision 233925)
+++ usr.bin/kdump/kdump.c (working copy)
@@ -94,7 +94,7 @@
void visdump(char *, int, int);
void ktrgenio(struct ktr_genio *, int);
void ktrpsig(struct ktr_psig *);
-void ktrcsw(struct ktr_csw *);
+void ktrcsw(struct ktr_csw *, int);
void ktruser_malloc(unsigned char *);
void ktruser_rtld(int, unsigned char *);
void ktruser(int, unsigned char *);
@@ -298,7 +298,7 @@
ktrpsig((struct ktr_psig *)m);
break;
case KTR_CSW:
- ktrcsw((struct ktr_csw *)m);
+ ktrcsw((struct ktr_csw *)m, ktrlen);
break;
case KTR_USER:
ktruser(ktrlen, m);
@@ -1245,10 +1245,16 @@
}
void
-ktrcsw(struct ktr_csw *cs)
+ktrcsw(struct ktr_csw *cs, int len)
{
- printf("%s %s\n", cs->out ? "stop" : "resume",
- cs->user ? "user" : "kernel");
+ if (len == sizeof(struct ktr_csw_old))
+ printf("%s %s\n", cs->out ? "stop" : "resume",
+ cs->user ? "user" : "kernel");
+ else if (len == sizeof(struct ktr_csw))
+ printf("%s %s \"%s\"\n", cs->out ? "stop" : "resume",
+ cs->user ? "user" : "kernel", cs->wmesg);
+ else
+ errx(1, "Unknown size of ktrace record");
}
#define UTRACE_DLOPEN_START 1
Index: sys/sys/ktrace.h
===================================================================
--- sys/sys/ktrace.h (revision 233925)
+++ sys/sys/ktrace.h (working copy)
@@ -135,9 +135,15 @@
* KTR_CSW - trace context switches
*/
#define KTR_CSW 6
+struct ktr_csw_old {
+ int out; /* 1 if switch out, 0 if switch in */
+ int user; /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */
+};
+
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 +250,7 @@
#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 @@
}
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,10 @@
kc = &req->ktr_data.ktr_csw;
kc->out = out;
kc->user = user;
+ if (wmesg != NULL)
+ strlcpy(kc->wmesg, wmesg, sizeof(kc->wmesg));
+ else
+ bzero(kc->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 @@
if (flags & TDF_NEEDRESCHED) {
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(1, 1);
+ ktrcsw(1, 1, __func__);
#endif
thread_lock(td);
sched_prio(td, td->td_user_pri);
@@ -227,7 +227,7 @@
thread_unlock(td);
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 1);
+ ktrcsw(0, 1, __func__);
#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 @@
lock_state = 0;
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(1, 0);
+ ktrcsw(1, 0, cv_wmesg(cvp));
#endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -140,7 +140,7 @@
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -162,7 +162,7 @@
td = curthread;
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(1, 0);
+ ktrcsw(1, 0, cv_wmesg(cvp));
#endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -197,7 +197,7 @@
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
}
@@ -220,7 +220,7 @@
lock_state = 0;
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(1, 0);
+ ktrcsw(1, 0, cv_wmesg(cvp));
#endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -258,7 +258,7 @@
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -286,7 +286,7 @@
lock_state = 0;
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(1, 0);
+ ktrcsw(1, 0, cv_wmesg(cvp));
#endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -324,7 +324,7 @@
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -353,7 +353,7 @@
lock_state = 0;
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(1, 0);
+ ktrcsw(1, 0, cv_wmesg(cvp));
#endif
CV_ASSERT(cvp, lock, td);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
@@ -392,7 +392,7 @@
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#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 @@
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 @@
}
#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 @@
#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 @@
}
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, wmesg);
#endif
PICKUP_GIANT();
mtx_lock_spin(mtx);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"