From owner-freebsd-arch@FreeBSD.ORG Wed Apr 4 16:00:14 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DC53E106567D for ; Wed, 4 Apr 2012 16:00:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 55A358FC14 for ; Wed, 4 Apr 2012 16:00:14 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id F27FBB9BF for ; Wed, 4 Apr 2012 12:00:12 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Date: Wed, 4 Apr 2012 12:00:10 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) References: <201105021537.19507.jhb@freebsd.org> In-Reply-To: <201105021537.19507.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201204041200.10773.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 04 Apr 2012 12:00:13 -0400 (EDT) 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: Wed, 04 Apr 2012 16:00:14 -0000 On Monday, May 02, 2011 3:37:19 pm John Baldwin wrote: > One thing I have found useful is knowing when processes are in the kernel > instead of in userland. ktrace already provides records for syscall > entry/exit. The other major source of time spent in the kernel that I've seen > is page fault handling. To that end, I have a patch that adds ktrace records > to the beginning and end of VM faults. This gives a pair of records so a user > can see how long a fault took (similar to how one can see how long a syscall > takes now). Sample output from kdump is below: > > 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 > > The patch is available at www.freebsd.org/~jhb/patches/ktrace_fault.patch and > included below. I've updated this based on some previous feedback. It now uses 'PRET' instead of 'RET' for return from a page fault. I've also made it possible for the MD layers to pass a non-truncated address, though those changes are not part of this patch. The updated patch is available at the URL above. I'd like to merge it in if there are no objections. If folks have other suggestions than 'PFLT' and 'PRET' for the markers for page faults that is fine with me. -- John Baldwin