From nobody Tue Aug 08 14:12:52 2023 X-Original-To: arch@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RKwCR62Wdz4mPcX for ; Tue, 8 Aug 2023 14:13:39 +0000 (UTC) (envelope-from br@bsdpad.com) Received: from mail.bsdpad.com (mail.bsdpad.com [116.202.106.248]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4RKwCQ16QDz3QcZ for ; Tue, 8 Aug 2023 14:13:38 +0000 (UTC) (envelope-from br@bsdpad.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdpad.com header.s=20201212 header.b=tcCjlmmy; spf=pass (mx1.freebsd.org: domain of br@bsdpad.com designates 116.202.106.248 as permitted sender) smtp.mailfrom=br@bsdpad.com; dmarc=pass (policy=none) header.from=bsdpad.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bsdpad.com; s=20201212; h=Subject:To:From; bh=OFXpnogA2bVmdWiWgZGYVsMHWjEanqdsDAkWdWbFGxY=; b=tcCjlmmyaLil7vmWZeeLr+94cp HbXJ7QK7rVtmvVE4rYLc7x7ZivBBUXOOfVx75WK1lMyQG2b/fG0yUFgX/wzE4B/mRFwjKw8sJclZA dYp+y3mTeXCHd/0JMrewCTBXlXayATH1Dt75hO7ciFQ+Z9m/UVoQo44+ifdnfvts8sGLUrsZF4dyZ vPYGs41iJgVlmRyO74CcMlPOvwIju1TFPmVOjV0n2dOW5Hve86j/f8qoFbvAbZ129pg7ELWKq5T9S otFEOXmqUki2z9bRpEVxiBhS++rkWnZVDyCITTC9VnSmZxiXKu4rn+QhUNMHGGQ6aVCP9dj5WmSWW bTaAvIdA==; Received: from localhost ([127.0.0.1] helo=bsdpad.com) by mail.bsdpad.com with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1qTNS8-00067M-2d for arch@freebsd.org; Tue, 08 Aug 2023 15:12:52 +0100 Received: by bsdpad.com (nbSMTP-1.00) for uid 1001 br@bsdpad.com; Tue, 8 Aug 2023 15:12:52 +0100 (BST) Date: Tue, 8 Aug 2023 15:12:52 +0100 From: Ruslan Bukin To: arch@freebsd.org Subject: D40466: HW-assisted tracing Message-ID: List-Id: Discussion related to FreeBSD architecture List-Archive: https://lists.freebsd.org/archives/freebsd-arch List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arch@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spamd-Result: default: False [-3.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.97)[-0.972]; DMARC_POLICY_ALLOW(-0.50)[bsdpad.com,none]; R_SPF_ALLOW(-0.20)[+mx]; R_DKIM_ALLOW(-0.20)[bsdpad.com:s=20201212]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[arch@freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:24940, ipnet:116.202.0.0/16, country:DE]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_TWO(0.00)[2]; FREEFALL_USER(0.00)[br]; DKIM_TRACE(0.00)[bsdpad.com:+]; FROM_HAS_DN(0.00)[]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spamd-Bar: --- X-Rspamd-Queue-Id: 4RKwCQ16QDz3QcZ Hello, I have been working on the new tracing framework to provide instrumentation needed for technologies like ARM Coresight, ARM Statistical Profiling Extension (SPE), Intel Processor Trace (PT). My previous attempt on adding that functionality into hwpmc(4) fail so I decided to try again. So the new framework manages hardware technology that collects information about software execution and records it as "events" in highly compressed format into DRAM. The events cover information about control flow changes of a program, whether branches taken or not, exceptions taken, timing information, cycles elapsed and more. That allow us to restore entire program flow of a given application without performance impact. With this we can get the call trace and (with some effort of tracing analysis) understand how many times functions are called, how much time we spent in a single function, how we been interrupted and what we were doing inside the functions. We can trace individual threads of an executable in userspace or whatever CPU activity (of a specified IP range) in kernel mode, regardless of a thread. Currently targeting ARM Coresight support. Hovewer, my colleague in ARM Ltd is working on adding SPE support to it. I have some snippets for Intel PT as well, if someone is interested on adding PT support then let me know and I can help. https://reviews.freebsd.org/D40466 Ruslan