summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-04-20 15:32:36 +0000
committerjhb <jhb@FreeBSD.org>2012-04-20 15:32:36 +0000
commitaa85973504e8ab2a6d5b1ab434c06030e5302f7c (patch)
tree210aa794e2e54dd698b7426768c3c9db3207febd /sys
parent58d2e125c4d6dc16535d5d50b8fa3eab9b287353 (diff)
downloadFreeBSD-src-aa85973504e8ab2a6d5b1ab434c06030e5302f7c.zip
FreeBSD-src-aa85973504e8ab2a6d5b1ab434c06030e5302f7c.tar.gz
Include the associated wait channel message for context switch ktrace
records. kdump supports both the old and new messages. Submitted by: Andrey Zonov andrey zonov org MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_condvar.c20
-rw-r--r--sys/kern/kern_ktrace.c7
-rw-r--r--sys/kern/kern_synch.c8
-rw-r--r--sys/kern/subr_trap.c4
-rw-r--r--sys/sys/ktrace.h8
5 files changed, 29 insertions, 18 deletions
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c
index e6a0b7a..9355819 100644
--- a/sys/kern/kern_condvar.c
+++ b/sys/kern/kern_condvar.c
@@ -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, cv_wmesg(cvp));
#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, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
@@ -162,7 +162,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object *lock)
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 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object *lock)
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
}
@@ -220,7 +220,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
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 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
#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 @@ _cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
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 @@ _cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
#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 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
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 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, cv_wmesg(cvp));
#endif
PICKUP_GIANT();
if (lock != &Giant.lock_object) {
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 363b8b8..d40fe51 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -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,10 @@ ktrcsw(out, user)
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);
}
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index a7945d2..85b11f9 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -142,7 +142,7 @@ _sleep(void *ident, struct lock_object *lock, int priority,
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 priority,
}
#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 char *wmesg, int timo)
#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 char *wmesg, int timo)
}
#ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
- ktrcsw(0, 0);
+ ktrcsw(0, 0, wmesg);
#endif
PICKUP_GIANT();
mtx_lock_spin(mtx);
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index ab83906..e57ab9e 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -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, __func__);
#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, __func__);
#endif
}
diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h
index 68008e2..b3e6be8 100644
--- a/sys/sys/ktrace.h
+++ b/sys/sys/ktrace.h
@@ -135,9 +135,15 @@ struct ktr_psig {
* 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 @@ 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);
OpenPOWER on IntegriCloud