From owner-svn-src-head@FreeBSD.ORG Thu Apr 12 06:32:46 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AFF9D106566C for ; Thu, 12 Apr 2012 06:32:46 +0000 (UTC) (envelope-from andrey@zonov.org) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 1D0968FC15 for ; Thu, 12 Apr 2012 06:32:45 +0000 (UTC) Received: by lagv3 with SMTP id v3so1695558lag.13 for ; Wed, 11 Apr 2012 23:32:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:x-gm-message-state; bh=X/leeGBKreRkeDKGLnxVcShyUabI+X2rcNy+ZoxWA+A=; b=lUSmEIiDymjNqznzGeCYEQBPr+LZe7Lcj4hM1DYP+7lHSBzFNfeWUoYtuHAkV73uz9 gf2oWRHvkGy6LaHT5vfj/W2WLsuWsdQ8ojB9j36D+9VxKeXvd1ZlGuDTC7eCl9ynQZd1 qur03uP6Wl4dZ091Y9HzZ5rO/x2fcj/Iv/Ll06J8ovXPyG9fHrn9vVwvxebl4pGtYFD4 mydWr6+T0B53hH8Iwn40KGaPh8qdT0ghWW9R84VuwOisXy4JUQVg7S4gzZHjaghjtn5z 9NqSOBRQku34HRh0iFy9wvKZTsyCW4/OIwJ7f+rBKENxcf4wTsrKbwv+13gavuAPCi6g K9Tg== Received: by 10.152.110.193 with SMTP id ic1mr1098738lab.4.1334212364659; Wed, 11 Apr 2012 23:32:44 -0700 (PDT) Received: from [10.254.254.77] (ppp109-252-212-252.pppoe.spdop.ru. [109.252.212.252]) by mx.google.com with ESMTPS id h8sm6491916lbx.8.2012.04.11.23.32.43 (version=SSLv3 cipher=OTHER); Wed, 11 Apr 2012 23:32:44 -0700 (PDT) Message-ID: <4F86770B.508@zonov.org> Date: Thu, 12 Apr 2012 10:32:43 +0400 From: Andrey Zonov User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.24) Gecko/20100228 Thunderbird/2.0.0.24 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: John Baldwin References: <201204051713.q35HDE3d067735@svn.freebsd.org> <4F848E4B.8020302@zonov.org> <201204111202.05409.jhb@freebsd.org> In-Reply-To: <201204111202.05409.jhb@freebsd.org> Content-Type: multipart/mixed; boundary="------------070604040808030408020200" X-Gm-Message-State: ALoCoQmq40EmDjdWEIypSvfazmXcyADa4ZgnO4cKJj/B1hoNpmt+RgmdTsIwbn0D2+aKBwk7N9Fr Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r233925 - in head: sys/kern sys/sys sys/vm usr.bin/kdump usr.bin/ktrace X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2012 06:32:46 -0000 This is a multi-part message in MIME format. --------------070604040808030408020200 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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 --------------070604040808030408020200 Content-Type: text/plain; charset=windows-1251; name="ktrace_csw.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ktrace_csw.patch" 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); --------------070604040808030408020200--