Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 May 2021 20:39:18 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 167cdaa7e300 - main - pmccontrol: improve -L with pmu-events
Message-ID:  <202105312039.14VKdIZt040615@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=167cdaa7e30093215a753d4f788d921b1f7c1474

commit 167cdaa7e30093215a753d4f788d921b1f7c1474
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-05-31 14:14:36 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-05-31 20:39:05 +0000

    pmccontrol: improve -L with pmu-events
    
    Check if the pmu utils are supported rather than carrying a
    machine-dependent #ifdef.
    
    Reviewed by:    gnn, ray, emaste
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D30526
---
 usr.sbin/pmccontrol/pmccontrol.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c
index 147aab2d2ba1..9d57a2923784 100644
--- a/usr.sbin/pmccontrol/pmccontrol.c
+++ b/usr.sbin/pmccontrol/pmccontrol.c
@@ -282,14 +282,6 @@ pmcc_do_list_state(void)
 	return 0;
 }
 
-#if defined(__i386__) || defined(__amd64__)
-static int
-pmcc_do_list_events(void)
-{
-	pmc_pmu_print_counters(NULL);
-	return (0);
-}
-#else
 static int
 pmcc_do_list_events(void)
 {
@@ -298,6 +290,13 @@ pmcc_do_list_events(void)
 	const char **eventnamelist;
 	const struct pmc_cpuinfo *ci;
 
+	/* First, try pmu events. */
+	if (pmc_pmu_enabled()) {
+		pmc_pmu_print_counters(NULL);
+		return (0);
+	}
+
+	/* Otherwise, use the legacy pmc(3) interfaces. */
 	if (pmc_cpuinfo(&ci) != 0)
 		err(EX_OSERR, "Unable to determine CPU information");
 
@@ -319,7 +318,6 @@ pmcc_do_list_events(void)
 	}
 	return 0;
 }
-#endif
 
 static int
 pmcc_show_statistics(void)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105312039.14VKdIZt040615>