From owner-freebsd-arch@freebsd.org Wed Nov 8 06:37:54 2017 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3847E6F57A for ; Wed, 8 Nov 2017 06:37:54 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) Received: from ppsw-43.csi.cam.ac.uk (ppsw-43.csi.cam.ac.uk [131.111.8.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6B89B6CFE9 for ; Wed, 8 Nov 2017 06:37:53 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://help.uis.cam.ac.uk/email-scanner-virus Received: from sc1.bsdpad.com ([163.172.212.18]:27963) by ppsw-43.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:rb743) (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1eCJzj-0002sI-n2 (Exim 4.89) for freebsd-arch@freebsd.org (return-path ); Wed, 08 Nov 2017 06:37:51 +0000 Date: Wed, 8 Nov 2017 06:31:09 +0000 From: Ruslan Bukin To: freebsd-arch@freebsd.org Subject: Intel PT support Message-ID: <20171108063109.GA68007@bsdpad.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) Sender: "R. Bukin" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 06:37:54 -0000 Hi, Here is patch enables Intel Processor Tracing (PT) support. This is exciting new and first(?) hardware-level tracing support available for FreeBSD! PT is supported on Intel 5th generation Core (Broadwell), 6th generation Core (Skylake) CPUs, and later. I'm testing it currently on a late Kabylake. PT is evolving since its introduction in Broadwell CPU and I'm not sure if the features we use on Kabylake are available on Broeadwell (tracing to SG buffer for example). I will try to support all of these CPUs but if someone can help testing it would be good. Providing the output of pt_enumerate() on your CPU may be helpful as well. So with a minimal impact on system perfomance we can trace pretty much everything now. I provided simple 'pmctrace' application that enables tracing and decodes tracing buffers. It supports function tracing. Intel PT provides 25 types of packets, we currently decode few of them only. Example usage: 1. Trace all the conditional branches for uname(1) application. pmctrace -u pt,branches uname 2. Trace all the conditional branches in memset(3) function in libc. pmctrace -u pt,branches -i libc.so.7 -f memset sleep 1 3. Trace all the conditional branches for copyin() and show timestamp (TSC -- amount of clock cycles since boot). sudo pmctrace -s pt,branches,tsc -i kernel -f copyin So I have added new counters modes for HWPMC: MODE_ST - system tracing MODE_TT - virtual thread tracing We may look for ARM tracing technologies later as well. It is on review here: https://reviews.freebsd.org/D12875 It require libipt decoder from Intel as well: https://reviews.freebsd.org/D12717 Thanks. Ruslan