From nobody Thu Apr 16 06:06:33 2026 X-Original-To: dev-commits-src-all@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 4fx6w959byz6Z0WR for ; Thu, 16 Apr 2026 06:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fx6w91xFDz3jcT for ; Thu, 16 Apr 2026 06:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776319593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cqFKkFi6HLyrgY8xEkRPycX/bZCpNPGWmu/LmOhszhU=; b=pQq7LukKHyIidHLqpyJIgkgYqFg0bkdggiAlT1qwUSbXfTtwZhMNsDBZ+msa+g1BpdlkL4 tg3J3+XGBuKb32rLg5E6ZPlKxvvYHiGa7KpvHBkwlML8pJVnFPs4tr21iVEPlXUmfkio1T nHGpgGx2FMCFpY6YKrNREwsdtjG+vcWzLwTde6OJBYinNB9DC7b4P464x8AAhWWUO+aaw3 95tSEuke2VoOlQYWLO+WosyRuTLBK90rWQZOmRVh3uqivBVMJ5Klbs3ntkIYPjZ1d68GbW 08eQ1ZaRgjQNTResTFx2INKF7T/E+Vl0IoHGdZsvFB9GZF68xaUxBX+YcHo50g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776319593; a=rsa-sha256; cv=none; b=cFKGsbmwSjoWW844FUy4XSm+zCT+0TC2JO0wUMa5tD1zF1C7vnIniOzdNllwRVV9XQ0hej dTs74a1UU4/ONyTdyx8Tmsa26iuoSnCu+0VkwLP/wtT1UEwk+G+is8qthgUmdyUfexnh5x lK/IsG07WbMgkQbYIGR1E0J9H5NExlZj53Lqj3BFbTQ9MpBWfsWg+/VFZSKSb5FzQXqRE2 6Ydt/qZMSr4KPhZSIXbl7nA5WxPhrKkgLkboj2/te8kcxNijmGk4UjX15JTeHN11lneggo PqtUZKrJNwf+hwIpjdmB2qdBN1Hf0gxoCLeysXk4wjBwLLi1b+8NmEmqcp+nlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776319593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cqFKkFi6HLyrgY8xEkRPycX/bZCpNPGWmu/LmOhszhU=; b=aHkns0meOE4R+Uv5gX+eTopeDcYnF10brfnM/IbO/QWi8WuKT/y/5TkuLIfF+U4NhPzYTD ngqpPnVWXXW0XZTOzX8rUcInXV/k951kI97EA4xs6gIIicDS8xFi/syabJ9/kZ+r0cEStG A8M4MHN1DqOuctIWsIBKYN9UW4lvDGlTg5jOg9612vRxD/Z/9mJOaI3rXjHXWQ4EkZLkJL Ob1mXVzvxurLMxK6UZa/W7rQukhKMRbsCWym5RHp5EuDVIyxMR+q1lfDdXOo7Aeh2MLQvf 0YeILEKT9EH1LP2jYWbDkGOVi9kPfbZOAE0i23fE/Gzw1RTd1iNLQsYjYA8hDQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fx6w90Xnjzvkt for ; Thu, 16 Apr 2026 06:06:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3cc0a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 16 Apr 2026 06:06:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Andre Silva From: Warner Losh Subject: git: ee12645ec737 - main - pmcstat: print raw TSC in decoded log output List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee12645ec737eb940554769af2c275524ea20d37 Auto-Submitted: auto-generated Date: Thu, 16 Apr 2026 06:06:33 +0000 Message-Id: <69e07c69.3cc0a.32f78fbf@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ee12645ec737eb940554769af2c275524ea20d37 commit ee12645ec737eb940554769af2c275524ea20d37 Author: Andre Silva AuthorDate: 2026-03-31 20:28:39 +0000 Commit: Warner Losh CommitDate: 2026-04-16 06:05:21 +0000 pmcstat: print raw TSC in decoded log output Extend pmcstat -R output to include the raw TSC for each decoded record and print tsc_freq from the initialize record so TSC deltas can be converted to elapsed time. Update the pmcstat documentation to describe the decoded output and the architecture-specific TSC behavior. Sponsored by: AMD Signed-off-by: Andre Silva Reviewed by: imp, mhorne, Ali Mashtizadeh Pull Request: https://github.com/freebsd/freebsd-src/pull/2085 --- usr.sbin/pmcstat/pmcstat.8 | 26 +++++++++++++++++++++++++- usr.sbin/pmcstat/pmcstat.h | 5 +++-- usr.sbin/pmcstat/pmcstat_log.c | 8 ++++++-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8 index edb9ff106092..c78a13f910f9 100644 --- a/usr.sbin/pmcstat/pmcstat.8 +++ b/usr.sbin/pmcstat/pmcstat.8 @@ -23,7 +23,7 @@ .\" out of the use of this software, even if advised of the possibility of .\" such damage. .\" -.Dd April 19, 2025 +.Dd April 15, 2026 .Dt PMCSTAT 8 .Os .Sh NAME @@ -220,6 +220,30 @@ specified in .It Fl R Ar logfilename Perform offline analysis using sampling data in file .Ar logfilename . +Each decoded record is printed as a single line with the following fields: +a record type (e.g., +.Dq callchain , +.Dq initlog ) , +type-specific data, and a trailing 20-digit raw TSC value recording the +CPU cycle at which the event occurred. +The +.Dq initlog +record additionally prints +.Dq Li tsc_freq= , +the TSC tick rate in Hz measured by the kernel at boot. +To convert a TSC delta to nanoseconds: +.Pp +.Dl elapsed_ns = (tsc_end - tsc_start) * 1e9 / tsc_freq +.Pp +TSC-based timestamps and +.Dq Li tsc_freq +are only meaningful on x86 architectures +.Pq amd64 and i386 . +On all other architectures +.Pq including arm64 and powerpc +the +.Dq Li tsc_freq +field will be zero. .It Fl S Ar event-spec Allocate a system mode sampling PMC measuring hardware events specified in diff --git a/usr.sbin/pmcstat/pmcstat.h b/usr.sbin/pmcstat/pmcstat.h index 67571ce4b2ee..6131d7a50404 100644 --- a/usr.sbin/pmcstat/pmcstat.h +++ b/usr.sbin/pmcstat/pmcstat.h @@ -50,8 +50,9 @@ #define PMCSTAT_PRINT_ENTRY(T,...) do { \ (void) fprintf(args.pa_printfile, "%-9s", T); \ - (void) fprintf(args.pa_printfile, " " __VA_ARGS__); \ - (void) fprintf(args.pa_printfile, "\n"); \ + (void) fprintf(args.pa_printfile, " " __VA_ARGS__); \ + (void) fprintf(args.pa_printfile, " %20ju\n", \ + (uintmax_t)_pmcstat_current_tsc); \ } while (0) #define PMCSTAT_PL_NONE 0 diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c index db9cbfabd9da..9af2ccc4e365 100644 --- a/usr.sbin/pmcstat/pmcstat_log.c +++ b/usr.sbin/pmcstat/pmcstat_log.c @@ -194,6 +194,7 @@ static struct pmc_plugins plugins[] = { }; static int pmcstat_mergepmc; +static uint64_t _pmcstat_current_tsc; /* TSC for PMCSTAT_PRINT_ENTRY */ int pmcstat_pmcinfilter = 0; /* PMC filter for top mode. */ float pmcstat_threshold = 0.5; /* Cost filter for top mode. */ @@ -471,6 +472,7 @@ pmcstat_print_log(void) while (pmclog_read(args.pa_logparser, &ev) == 0) { assert(ev.pl_state == PMCLOG_OK); + _pmcstat_current_tsc = ev.pl_tsc; switch (ev.pl_type) { case PMCLOG_TYPE_CALLCHAIN: PMCSTAT_PRINT_ENTRY("callchain", @@ -496,9 +498,11 @@ pmcstat_print_log(void) PMCSTAT_PRINT_ENTRY("drop",); break; case PMCLOG_TYPE_INITIALIZE: - PMCSTAT_PRINT_ENTRY("initlog","0x%x \"%s\"", + PMCSTAT_PRINT_ENTRY("initlog", + "0x%x \"%s\" tsc_freq=%" PRIu64, ev.pl_u.pl_i.pl_version, - pmc_name_of_cputype(ev.pl_u.pl_i.pl_arch)); + pmc_name_of_cputype(ev.pl_u.pl_i.pl_arch), + ev.pl_u.pl_i.pl_tsc_freq); if ((ev.pl_u.pl_i.pl_version & 0xFF000000) != PMC_VERSION_MAJOR << 24) warnx(