From nobody Tue Jul 28 19:29:25 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 4h8ls15lKgz6n9dQ for ; Tue, 28 Jul 2026 19:29:25 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h8ls140k0z43mk for ; Tue, 28 Jul 2026 19:29:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785266965; 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=yjIOTKNRvPTicu+P6/rlcbPGDAMDdNT3thR7yNh6kEI=; b=PiO8QtNlpI4eDmEpFz8epDGdh1fD61+Pm4TD7WIGOy+Y8BP+fthfnAbNVxz+LrLhMEEagA Z7TNClTFnKlFaGC4kHw+oevPZfnAc4SEcMWLnoMOgszEfv3qktftU6CxUyV8EQ1hx0EImZ WlClqMfQt/R+rtqpXEvYiYp+yIFfjXZdwOMI0lvxG6YkKdbLaIdKCf5qXKSy3u8q/gai1p x2c0i+ZGWq752C7B8MhjLFOrUP0jft75F/3v+waQdYpjmHUsyTTGS76CuZwwLyYL1qeLCq 3idE5V2MZOdtF/TjbFN3Ww4q+u6y3WbdHLHRCnI8UuiC6i9zrHXtRGtiRE7Upg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785266965; a=rsa-sha256; cv=none; b=wHMlzVx1w41i0CNBOtlrrxgVAwt/6kc0TnLapVGO4HIVWzGUNgQR9slCf5Ki0aCKfvqpr3 wDNqHkKAb+V4blf3+KUb3911wtCERY8wc46yZemuOduZ7EyLcK5zybFZiRbWJEoREh8+tt czqyiawu5x3O24YiBmv/jQVZ2bmKN87E3SENWCsi4msnpVSrcw9x6kfg8u9z4ywf0sa1up B3oc4z9Wh8wpmDK9B9AN1o5y4EGIc/cTt1WNPJMJ77Kh+zIZ7VEa4s401Z+dF9ZGu5AMe0 X2djoHjIHmmcwtme2UPGVoYNgFXLwf0MFAcCMI2PCO3+BfRuLPXBEKNdbeBPgg== 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=1785266965; 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=yjIOTKNRvPTicu+P6/rlcbPGDAMDdNT3thR7yNh6kEI=; b=CycvbcTXnMweo5dnANQj3Ua1seo2dCHm1UEYob7FUmEWnwrF2G4q05N7n+jiXj/BjLNzT5 ISqtEFZLJVRS5OME2sFCZ81cD5LLViIBVCSHbcO65c96d5kLe7h9CNrHiAjgbv/GCOCXSr aKnX46DSXDdt/1u3KDUTXVPP26+rH9iSC4NqbpSaTXzCp109u1FZtM+bicLblS/AtWXQpM EWJF1wusxWnnQ1q2qxNqVhMrd46IDHx/8Apo3wMSqGpCRfStnbCNZXH/WFTr1COj5p9FTJ ULT/4c2+lTn1n48KD8kMu6n3UPBfv6YYGc1jmt4LY04Tct1/yVKzxPFIPFJwNw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h8ls133Kdzsxy for ; Tue, 28 Jul 2026 19:29:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 431f8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 28 Jul 2026 19:29:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Ali Mashtizadeh From: Warner Losh Subject: git: 3adde0e55d7c - main - pmc: pmc info command 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 3adde0e55d7c01018b0877e1407aede7e757ce04 Auto-Submitted: auto-generated Date: Tue, 28 Jul 2026 19:29:25 +0000 Message-Id: <6a690315.431f8.294ad9d4@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3adde0e55d7c01018b0877e1407aede7e757ce04 commit 3adde0e55d7c01018b0877e1407aede7e757ce04 Author: Ali Mashtizadeh AuthorDate: 2026-07-28 17:46:41 +0000 Commit: Warner Losh CommitDate: 2026-07-28 19:27:45 +0000 pmc: pmc info command Prints the log header including machine, cpu and kernel details along with what counters were selected. Sponsored by: Netflix Reviewed by: adrian, imp Differential Revision: https://reviews.freebsd.org/D57778 --- usr.sbin/pmc/cmd_pmc_info.cc | 186 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/usr.sbin/pmc/cmd_pmc_info.cc b/usr.sbin/pmc/cmd_pmc_info.cc new file mode 100644 index 000000000000..4bff0240b774 --- /dev/null +++ b/usr.sbin/pmc/cmd_pmc_info.cc @@ -0,0 +1,186 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026, Netflix, Inc. + * + * This software was developed by Ali Mashtizadeh under the sponsorship from + * Netflix, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cmd_pmc.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "display.hh" +#include "view.hh" + +class info_view : public pmcview +{ +public: + virtual void + callchain(struct pmclog_ev_callchain &p) + { + uint64_t eventid = pmcidtoeventid(p.pl_pmcid); + + pmcinfo[eventid].count++; + } + + virtual void + print() + { + title("PMC Info"); + + header("System Info"); + printf("CPU Model: %s\n", cpumodel.c_str()); + printf("OS Release: %s\n", osrelease.c_str()); + printf("Build ID: %s\n", buildid.c_str()); + printf("\n"); + + if (arch == PMC_ARCH_AMD64) { + header("CPUID"); + for (auto &c : cpuid) + printf("0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", + c.first, c.second.eax, c.second.ebx, + c.second.ecx, c.second.edx); + printf("\n"); + } + + header("PMC Info"); + for (auto &p : extpmcinfo) + printf("%s\n", p.event.c_str()); + printf("\n"); + + table t = table(); + t.addcolumn("Counter", true); + t.addcolumn("Counts", true); + + for (auto &p : pmcinfo) { + std::vector r; + + r.emplace_back(p.second.name); + r.emplace_back((int64_t)p.second.count); + + t.addrow(r); + } + + t.print(); + } +}; + +static struct option longopts[] = { + PMCFILTER_LOPTS, + { NULL, 0, NULL, 0 } +}; + +static void +usage(void) +{ + printf("Usage: pmc info [options] [pmclog]\n\n"); + printf("Display a log summary\n\n"); + printf("Options:\n"); + PMCFILTER_PRINTOPTS(); +} + +int +cmd_pmc_info(int argc, char **argv) +{ + struct pmcfilter filter = pmcfilter(); + const char *logfile = "default.log"; + int option, logfd; + + while ((option = getopt_long(argc, argv, PMCFILTER_SOPTS "s:", longopts, NULL)) != -1) { + switch (option) { + PMCFILTER_CASE(filter); + case '?': + default: + usage(); + } + } + argc -= optind; + argv += optind; + if (argc != 0 && argc != 1) { + usage(); + exit(EX_USAGE); + } + if (argc == 1) + logfile = argv[0]; + + setup_screen(); + + if ((logfd = open(logfile, O_RDONLY)) < 0) { + errx(EX_OSERR, "ERROR: Cannot open \"%s\" for reading: %s.", logfile, + strerror(errno)); + return (EX_NOINPUT); + } + + info_view s = info_view(); + s.setfilter(filter); + s.process(logfd); + s.print(); + + return (EX_OK); +}