aboutsummaryrefslogtreecommitdiff
path: root/lib/libpmc
Commit message (Collapse)AuthorAgeFilesLines
* libpmc: add more alderlake modelsacazuc2025-02-251-0/+3
| | | | | | | | | | | | According to [1], the CPU models 6-{b7,ba,bf} are also alderlake-family models. This patch adds them to the mapfile.csv. [1] https://github.com/torvalds/linux/blob/master/tools/perf/pmu-events/arch/x86/mapfile.csv#L2 Reviewed by: mhorne MFC after: 3 days Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D49126
* man: Misc syntax fixesGraham Percival2024-11-142-2/+0
| | | | | | | | | | | | - loader.efi.8: use proper way of printing a backslash. - usr.bin/gzip/gzip.1: contained a non-breaking space (in utf-8, 0xC2A0). - lib/libpmc/pmc.*.3: remove two duplicate .Xr lines Signed-off-by: Graham Percival <gperciva@tarsnap.com> Reviewed by: mhorne, Alexander Ziaee <concussious.bugzilla@runbox.com> MFC after: 3 days Sponsored by: Tarsnap Backup Inc. Pull Request: https://github.com/freebsd/freebsd-src/pull/1523
* manuals: Fix datesGraham Percival2024-10-281-1/+1
| | | | | | | | | | These were reported by `mandoc -T lint ...` as warnings. Signed-off-by: Graham Percival <gperciva@tarsnap.com> Reviewed by: mhorne MFC after: 3 days Sponsored by: Tarsnap Backup Inc. Pull Request: https://github.com/freebsd/freebsd-src/pull/1475
* Remove residual blank line at start of MakefileWarner Losh2024-07-153-3/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* cross-tools: fts has different types for cmp routineWarner Losh2024-05-261-1/+1
| | | | | | | | | | | | | | | | fts has different types for its compare rotuine. Other systems, not 4.4BSD based, have a non-const version. Before we tested against __GLIBC__, but now we test against __linux__ because that's Linux's API and musl doesn't define __GLIBC__. In addition, link against libftl on this platform since musl doesn't include ftl routines in libc, but rather in libftl. Co-authored-by: Val Packett <val@packett.cool> Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/1066 Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45349
* libpmc: remove tautological assertBrooks Davis2024-05-231-1/+0
| | | | | | | | gcc13 whines about this assert than an unsigned integer is >= 0. Reviewed by: luporl Fixes: b48a2770d48b9 powerpc64: add Power8 and Power9 PMCs Differential Revision: https://reviews.freebsd.org/D45232
* libpmc: Import AMD Zen 4 PMU eventsAlexander Motin2024-04-2011-1/+3871
| | | | MFC after: 1 week
* jevents: Fix bootstrapping on macOS with Clang 16 / Apple Clang 15Jessica Clarke2024-03-161-1/+1
| | | | | | | | | macOS, like Linux, does not include an outer const qualifier for its fts_open callback arguments, so -Wincompatible-function-pointer-types also picks this up and breaks the build now Clang 16 makes it an error by default. Extend the existing Linux support to fix this. MFC after: 1 week
* jevents: fix bootstrapping on Linux with Clang 16Alex Richardson2023-12-121-0/+4
| | | | | | | | | The glibc fts_open() callback type does not have the second const qualifier and it appears that Clang 16 errors by default for mismatched function pointer types. Add an ifdef to handle this case. Reviewed By: imp, emaste Differential Revision: https://reviews.freebsd.org/D43000
* lib: Automated cleanup of cdefs and other formattingWarner Losh2023-11-273-3/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* dirdeps: Add missing dependency filesStephen J. Kiernan2023-10-291-0/+10
| | | | | Some leaf directories were missing Makefile.depend files or needed architecture-specific Makefile.depend.* files.
* pmc.amd(3): rename from pmc.k8(3)Mitchell Horne2023-10-1825-27/+32
| | | | | | | | | | | | | | This is the first step in recognizing that the K8 microarchitecture represents a small and aged subset of AMD CPUs supported by this class. Future changes will update the code and documentation details to better reflect this. Keep the old filename as an alias. Reviewed by: jkoshy MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41279
* pmc: remove last bits of AMD K7 CPU supportMitchell Horne2023-10-1826-294/+1
| | | | | | | | | This includes event definitions from sys/pmc_events.h, definitions from sys/pmc.h, and the man pages. Reviewed by: jkoshy Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41275
* pmc: better distinguish pmu-events allocation pathMitchell Horne2023-09-033-17/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Background: The pm_ev field of struct pmc_op_pmcallocate and struct pmc traditionally contains the index of the chosen event, corresponding to the __PMC_EVENTS array in pmc_events.h. This is a static list of events, maintained by FreeBSD. In the usual case, libpmc translates the user supplied event name (string) into the pm_ev index, which is passed as an argument to the allocation syscall. On the kernel side, the allocation method for the relevant hwpmc class translates the given index into the event code that will be written to an event selection register. In 2018, a new source of performance event definitions was introduced: the pmu-events json files, which are maintained by the Linux kernel. The result was better coverage for newer Intel processors with a reduced maintenance burden for libpmc/hwpmc. Intel and AMD CPUs were unconditionally switched to allocate events from pmu-events instead of the traditional scheme (959826ca1bb0a, 81eb4dcf9e0d). Under the pmu-events scheme, the pm_ev field contains an index corresponding to the selected event from the pmu-events table, something which the kernel has no knowledge of. The configuration for the performance counting registers is instead passed via class-dependent fields (struct pmc_md_op_pmcallocate). In 2021 I changed the allocation logic so that it would attempt to pull from the pmu-events table first, and fall-back to the traditional method (dfb4fb41166bc3). Later, pmu-events support for arm64 and power8 CPUs was added (28dd6730a5d6 and b48a2770d48b). The problem that remains is that the pm_ev field is overloaded, without a definitive way to determine whether the event allocation came from the pmu-events table or FreeBSD's statically-defined PMC events. This resulted in a recent fix, 21f7397a61f7. Change: To disambiguate these two supported but separate use-cases, add a new flag, PMC_F_EV_PMU, to be set as part of the allocation, indicating that the event index came from pmu-events. This is useful in two ways: 1. On the kernel side, we can validate the syscall arguments better. Some classes support only the traditional event scheme (e.g. hwpmc_armv7), while others support only the pmu-events method (e.g. hwpmc_core for Intel). We can now check for this. The hwpmc_arm64 class supports both methods, so the new flag supersedes the existing MD flag, PM_MD_EVENT_RAW. 2. The flag will be tracked in struct pmc for the duration of its lifetime, meaning it is communicated back to userspace. This allows libpmc to perform the reverse index-to-event-name translation without speculating about the meaning of the index value. Adding the flag is a backwards-incompatible ABI change. We recently bumped the major version of the hwpmc module, so this breakage is acceptable. Reviewed by: jkoshy MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40753
* libpmc: make pmc_pmu_pmcallocate() machine-independentMitchell Horne2023-09-032-13/+26
| | | | | | | | | | | Have it call the platform-dependent version. For better layering, move the reset logic inside the new function. This is mainly to facilitate an upcoming change. Reviewed by: jkoshy MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40752
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-1638-76/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-164-4/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-162-4/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .c comment patternWarner Losh2023-08-162-2/+0
| | | | Remove /^/[*/]\s*\$FreeBSD\$.*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-169-18/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* pmclog(3): Drop .UdMitchell Horne2023-07-101-3/+1
| | | | | | | | This API is stable and should not be advertised as "currently under development". MFC after: 3 days Sponsored by: The FreeBSD Foundation
* pmc: clean up remaining Pentium man page referencesMitchell Horne2023-06-242-6/+0
| | | | | | | | These have been removed. Fixes: d78896e46f1d ("pmc(3): remove Pentium-related man pages...") MFC after: 3 days Sponsored by: The FreeBSD Foundation
* libpmc: Define a PMCLOG_SKIP32 helper macro to skip over a 32-bit field.John Baldwin2023-06-201-6/+7
| | | | | | | | This replaces a set but unused noop variable with a more explicit macro. Reviewed by: jkoshy, mhorne Differential Revision: https://reviews.freebsd.org/D40651
* pmc: clarify and strengthen statements about API/ABIMitchell Horne2023-06-161-6/+2
| | | | | | | | | | | | | - Make it clear that applications are not only encouraged to use the pmc(3) library, but use of the hwpmc(4) interface directly is a use-case we do not support - Move the COMPATIBILITY section above PROGRAMMING API in hwpmc(4) - Drop statements about the driver and library being "under development" Reviewed by: jkoshy, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40543
* libpmc: Handle PMCALLOCATE log with PMC code on PMU event systemJessica Clarke2023-06-072-7/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | On an arm64 system that reports as a Cortex A72 r0p3, running pmcstat -P CPU_CYCLES command works, but pmcstat -P cpu-cycles command does not. This is because the former uses the PMU event from the JSON source, resulting in pl_event in the log event being a small index (here, 5) into the generated events table, whilst the latter does not match any of the JSON events and falls back on PMC's own tables, mapping it to the PMC event 0x14111, i.e. PMC_EV_ARMV8_EVENT_11H. Then, when libpmc gets the PMCALLOCATE event, it tries to use the event as an index into the JSON-derived table, but doing so only makes sense for the former, whilst for the latter it will go way out of bounds and either read junk (which may trigger the != NULL assertion) or segfault. As far as I can tell we don't have anything lying around to tell us which of the two cases we're in, but we can exploit the fact that the first 0x1000 PMC event codes are reserved, and that none of our PMU events tables reach that number of entries yet. PR: 268857 Reviewed by: mhorne MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D39592
* libpmc: expand PMC_OP* definesMitchell Horne2023-06-011-24/+23
| | | | | | | | | | | | When performing the syscall, specify the full name of the desired operation. This improves grep-ability. No functional change. Reviewed by: jkoshy MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40334
* pmc: Rework PROCEXEC event to support PIEsJessica Clarke2023-05-303-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the PROCEXEC event only reports a single address, entryaddr, which is the entry point of the interpreter in the typical dynamic case, and used solely to calculate the base address of the interpreter. For PDEs this is fine, since the base address is known from the program headers, but for PIEs the base address varies at run time based on where the kernel chooses to load it, and so pmcstat has no way of knowing the real address ranges for the executable. This was less of an issue in the past since PIEs were rare, but now they're on by default on 64-bit architectures it's more of a problem. To solve this, pass through what was picked for et_dyn_addr by the kernel, and use that as the offset for the executable's start address just as is done for everything in the kernel. Since we're changing this interface, sanitise the way we determine the interpreter's base address by passing it through directly rather than indirectly via the entry point and having to subtract off whatever the ELF header's e_entry is (and anything that wants the entry point in future can still add that back on as needed; this merely changes the interface to directly provide the underlying variables involved). This will be followed up by a bump to the pmc major version. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D39595
* pmc: Initialise and check the pm_flags field for CONFIGURELOGJessica Clarke2023-05-301-0/+1
| | | | | | | | | | Whilst the former is not breaking, the latter is, and so this will be followed by a bump to the pmc major version. This will allow the flags to actually be usable in future, as otherwise we cannot distinguish uninitialised stack junk from a deliberately-initialised value. Reviewed by: jhb, mhorne Differential Revision: https://reviews.freebsd.org/D40049
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-128-8/+8
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-0/+1
|
* pmc: Keep a list sorted.Joseph Koshy2023-04-051-41/+41
| | | | | Approved by: gnn (mentor) Differential Revision: https://reviews.freebsd.org/D39439
* libpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library.John Baldwin2023-03-231-2/+1
| | | | | | | | | | | | This uses the C++ compiler as the linker instead of the C compiler letting the compiler driver pick the right libraries. This is a no-op on main and stable/13 but matters for stable/12 where the current logic breaks for external GCC since it tries to use a non-existent libstdc++. Reviewed by: emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39197
* Refresh CPU types and classes from sys/sys/pmc.h.Pau Amma2023-01-181-8/+72
| | | | | | | | | | | | | | While here, fix a few nits. Inspired by reviewing D35342. Sources for trademark info - https://www.arm.com/company/policies/trademarks (no Arm8, curiously) - https://www.ibm.com/legal/copytrade?mhsrc=ibmsearch_a&mhq=trademark Reviewed by: carlavilla, luporl, mhorne Approved by: carlavilla (mentor), mhorne (src) Differential Revision: https://reviews.freebsd.org/D35344
* libpmc: remove unused auto_ptr warning suppressionEd Maste2022-12-021-3/+0
| | | | | | | | | | libpmc used -Wno-deprecated-declarations to silence warnings about usage of deprecated std::auto_ptr, but there is (now) now use of auto_ptr in libpmc. Reviewed by: mhorne Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37576
* pmc.sandybridge(3): Fix a few EVENT_ vs Event inconsistenciesJessica Clarke2022-10-101-4/+4
| | | | | Every event other than these four is listed as Event X, Umask Y; fix these to conform to that style.
* libpmc: pmc_init() should avoid overflowing pmc_class_tableToomas Soome2022-09-052-22/+88
| | | | | | | | | | | Use calloc(). Walk the class list we get from kernel, so we will not add something the kernel does not know about. Avoid picking headers from /usr/include. Differential Revision: https://reviews.freebsd.org/D36401
* pmc(3): Correct some typos in event descriptionsGordon Bergling2022-09-046-10/+10
| | | | | | | - s/occured/occurred/ - s/the the/the/ MFC after: 3 days
* Add pmc.dmc-620(3) man page.Aleksandr Rybalko2022-07-262-0/+166
| | | | | | Reviewed by: pauamma Sponsored By: Ampere Computing Differential Revision: https://reviews.freebsd.org/D32669
* Add the Arm CoreLink CMN-600 Coherent Mesh Network Controller PMU driver man ↵Aleksandr Rybalko2022-07-102-0/+598
| | | | | | | | | | page. Add the Arm CoreLink CMN-600 Coherent Mesh Network Controller PMU driver man page. Reviewed by: pauamma_gundo.com Sponsored By: ARM Differential Revision: https://reviews.freebsd.org/D32335
* libpmc: add armv8 pmu-event aliasesMitchell Horne2022-07-061-0/+15
| | | | | | | | | | | | | These are all "standard microarchitectural events", which in theory are supported by every ARMv8 processor. In practice, it depends on the pmu-event definitions being complete and accurate, which they are not for every processor. Still, these aliases should be functional on the majority of systems. PR: 254532 Reported by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35550
* libpmc: import updated pmu-events for arm64Mitchell Horne2022-07-06168-4/+10204
| | | | | | | | | | | | | Thanks to the recently updated import of the jevents utility by mav@, we can now compile the latest version of these event definitions. This should support a wider set of common ARMv8 processors, for example, the Cortex-A72 in the Raspberry Pi 4. This brings this folder in sync with Linux commit 62e6eb8d5454. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35549
* pmc(3): Fix a common typo in a descriptionGordon Bergling2022-07-031-1/+1
| | | | | | - s/transistioned/transitioned/ MFC after: 3 days
* libpmc: attempt to fix the buildBjoern A. Zeeb2022-06-261-0/+2
| | | | | Try to fix the build (blindly) after e3572eb654733a94e1e765fe9e95e0579981d851. I had missed the missing #ifdef in the review. Hope that's all it takes.
* Allocate event for DMC-620 and CMN-600 controllers PMU. Add events supported ↵Aleksandr Rybalko2022-06-261-0/+181
| | | | | | | | | | | | by DMC-620 and CMN-600 controllers PMU. Allocate event for DMC-620 and CMN-600 controllers PMU. Add events supported by DMC-620 and CMN-600 controllers PMU. Reviewed by: bz Sponsored By: ARM Sponsored By: Ampere Computing Differential Revision: https://reviews.freebsd.org/D35609
* System wide and NUMA domain wide counters support. PMC classes for ARM ↵Aleksandr Rybalko2022-06-261-1/+5
| | | | | | | | | | | | DMC-620 and CMN-600. Add support for system wide and NUMA domain wide counters support. Add 3 new PMC classes for ARM DMC-620 and CMN-600 controllers PMU. Reviewed by: mhorne Sponsored By: ARM Sponsored By: Ampere Computing Differential Revision: https://reviews.freebsd.org/D35342
* libpmc: Prefer fixed counters in Intel event aliases.Alexander Motin2022-06-021-4/+4
| | | | | | | | | | It is recommended by Intel to use fixed counters when possible to leave programmable ones for different events. This fixes `pmc stat`, which tries to count 6 events same time, while many Intel CPUs have only 4 programmable counters. MFC after: 1 month
* libpmc: Fix INVERT flag mapping for both Intel and AMD.Alexander Motin2022-05-311-2/+2
| | | | | | Looks like somebody's trivial copy/paste bug. MFC after: 1 month
* libpmc: Disable hardcoding of Intel fixed counters.Alexander Motin2022-05-312-2/+3
| | | | | | | Intel json's now have pretty reasonable fixed counters representation via event=0 and umask. Hardcoded values create more confusion than fix. MFC after: 1 month
* libpmc: jevents: Sync with the latest Linux kernel.Alexander Motin2022-05-3010-233/+569
| | | | | | | commit f4df0dbbe62ee8e4405a57b27ccd54393971c773 Date: Wed May 25 22:04:10 2022 +0800 MFC after: 1 month