From owner-freebsd-arch@FreeBSD.ORG Mon May 2 20:35:08 2011 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9013C106566C for ; Mon, 2 May 2011 20:35:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 0CD2E8FC1B for ; Mon, 2 May 2011 20:35:07 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p42JttK0047337 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 2 May 2011 22:55:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p42Jttfl057238; Mon, 2 May 2011 22:55:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p42Jttil057237; Mon, 2 May 2011 22:55:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 2 May 2011 22:55:55 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20110502195555.GC48734@deviant.kiev.zoral.com.ua> References: <201105021537.19507.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Qcz4xfO8nvR/PV7q" Content-Disposition: inline In-Reply-To: <201105021537.19507.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: arch@freebsd.org Subject: Re: [PATCH] Add ktrace records for user page faults X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2011 20:35:08 -0000 --Qcz4xfO8nvR/PV7q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 02, 2011 at 03:37:19PM -0400, John Baldwin wrote: > One thing I have found useful is knowing when processes are in the kernel= =20 > instead of in userland. ktrace already provides records for syscall=20 > entry/exit. The other major source of time spent in the kernel that I've= seen=20 > is page fault handling. To that end, I have a patch that adds ktrace rec= ords=20 > to the beginning and end of VM faults. This gives a pair of records so a= user=20 > can see how long a fault took (similar to how one can see how long a sysc= all=20 > takes now). Sample output from kdump is below: >=20 > 47565 echo CALL mmap(0x800a87000,0x179000,PROT_READ| > PROT_WRITE,MAP_PRIVATE|MAP_ANON,0xffffffff,0) > 47565 echo RET mmap 34370777088/0x800a87000 > 47565 echo PFLT 0x800723000 VM_PROT_EXECUTE > 47565 echo RET KERN_SUCCESS > 47565 echo CALL munmap(0x800887000,0x179000) > 47565 echo RET munmap 0 > 47565 echo PFLT 0x800a00000 VM_PROT_WRITE > 47565 echo RET KERN_SUCCESS >=20 > The patch is available at www.freebsd.org/~jhb/patches/ktrace_fault.patch= and=20 > included below. One immediate detail is that trap() truncates the fault address to the page address, that arguably looses useful information. --Qcz4xfO8nvR/PV7q Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2/DEsACgkQC3+MBN1Mb4jLCQCeOFcMzhtRL8/aHutAqSaKl2wz 7XUAn3O73HqERdXiKwFLqqC+yHJLl2// =Dcqf -----END PGP SIGNATURE----- --Qcz4xfO8nvR/PV7q--