aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/hwpmc
Commit message (Collapse)AuthorAgeFilesLines
...
* hwpmc_mod.c: whitespace style cleanupMitchell Horne2023-06-141-291/+169
| | | | | | | | | | | | | | | Handle a few things related to spacing: - Remove redundant/superfluous blank lines (and add a couple where helpful) - Add spacing around binary operators - Remove spacing after casts and before goto labels - Adjustments for line width of 80 chars - Tab/space character issues Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40514
* hwpmc_mod.c: return statement styleMitchell Horne2023-06-141-42/+38
| | | | | | | Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40513
* pmc: Rework PROCEXEC event to support PIEsJessica Clarke2023-05-302-7/+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: Provide full path to modules from kernel linkerJessica Clarke2023-05-301-1/+1
| | | | | | | | | | | | | | | | | This unifies the user object and kernel module paths in libpmcstat, allows modules loaded from non-standard locations (e.g. from a user's home directory when testing) to be found and, since buffer is what all the warnings here use (they were never updated when buffer_modules were added to pick based on where the file was found) has the side-effect of ensuring the messages are correct. This includes obsoleting the now-superfluous -k option in pmcstat. This change breaks the hwpmc ABI and will be followed by a bump to the pmc major version. Reviewed by: jhb, jkoshy, mhorne Differential Revision: https://reviews.freebsd.org/D40048
* pmc: Initialise and check the pm_flags field for CONFIGURELOGJessica Clarke2023-05-301-0/+6
| | | | | | | | | | 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-1221-21/+21
| | | | | | | | | 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
* hwpmc: pass pmc pointer to more class methodsMitchell Horne2023-05-0613-329/+87
| | | | | | | | | | | | In many cases this avoids an extra lookup, since the callers always have pm at hand. We can also eliminate several assertions, mostly for pm != NULL. The class methods are an internal interface, and the callers already handle such a scenario. No functional change intended. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39915
* hwpmc: unused/diagused annotations in tsc classMitchell Horne2023-05-061-19/+8
| | | | | | | | | These are preferred over casts to void. No functional change. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39914
* hwpmc: remove stub pmd_switch_{in,out} methodsMitchell Horne2023-05-064-64/+8
| | | | | | | | | | | Most platforms (non-x86) don't require these methods and implement stub versions. If we initialize the pmc_mdep structure to always point to the generic versions, then we can purge the duplicate stubs. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39913
* hwpmc: remove pmd_pcpu_{init,fini} callbacksMitchell Horne2023-05-063-11/+0
| | | | | | | | | These are unused on all platforms. Reviewed by: jkoshy, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39912
* hwpmc_logging: less macro magic for type namesMitchell Horne2023-05-061-24/+33
| | | | | | | | | | | | Provide the log type names in their entirely, rather than relying on the macro to prepend the prefix. This improves their searchability; for example, if I see PMCLOG_TYPE_PMCALLOCATE in libpmc I will now be able to find where that is emitted in the kernel with a simple grep. Reviewed by: jkoshy, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39911
* hwpmc: don't use deprecated copystr(9)Mitchell Horne2023-05-0610-78/+24
| | | | | | | | | | It is just wrapper around strlcpy(), but results in more complicated code. Clean this up to use strlcpy() or snprintf() as appropriate. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39910
* hwpmc: use kstack_contains()Mitchell Horne2023-05-063-69/+45
| | | | | | | | | | | | | | This existing helper function is preferable to the hand-rolled calculation of the kstack bounds. Make some small style improvements while here. Notably, rename every instance of "r", the return address, to "ra". Tidy the includes in the affected files. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39909
* hwpmc: simplify arm64 kernel stack unwindingMitchell Horne2023-05-061-21/+10
| | | | | | | | | | | Use the unwind_frame() function, which properly validates the frame pointer and uses ADDR_MAKE_CANONICAL() for the pc, required when PAC is enabled. Reviewed by: andrew, markj, jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39934
* hwpmc: trim obsolete Intel CPU and class defsMitchell Horne2023-05-061-1/+1
| | | | | | | | | No functional change. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39904
* pmc_events.h: event list formattingMitchell Horne2023-05-061-24/+24
| | | | | | | | | | Improve the legibility of the list. Bump overall indentation, fix some whitespace, and sort the IAF block. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39903
* pmc_events.h: update event list commentMitchell Horne2023-05-061-4/+4
| | | | | | | | | | | | This comment is no longer in sync with the contents of __PMC_EVENTS(). Update to reflect the removal of various Intel event definitions from this list; these event definitions now come from Linux and live in lib/libpmc/pmu-events/. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39902
* hwpmc: remove remaining UCP event definitionsMitchell Horne2023-05-062-33/+0
| | | | | | | | | | | | | | | | | | | | | | Although this block has remained in __PMC_EVENTS(), there is no handling of UCP in libpmc/libpmc.c, so it is not possible to select one of these events. It should therefore be impossible to trigger the code removed from ucp_start_pmc(). Note that the GQ_SNOOP_MSF MSR exists only for Nehalem and Westmere architectures, and the related events do not exist for later generations. The Uncore support in hwpmc has severely atrophied in general. We have uncore event definitions in pmu-events, but the kernel support was written against Intel Performance Measurement Architecture version 2, and is disabled for processor generations later than Westmere. Nehalem and Westmere lack uncore event definitions in pmu-events. I'd be surprised if Uncore support is usable on any machine in its current state. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39901
* hwpmc: drop vestigial IAP event definitionsMitchell Horne2023-05-061-16/+0
| | | | | | | | | These are maintained elsewhere. No functional change. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39900
* hwpmc: Fix a typoMark Johnston2023-05-011-1/+1
| | | | MFC after: 1 week
* hwpmc: Don't wrap entire files in #ifdef DEV_ACPI.John Baldwin2023-03-012-14/+1
| | | | | | | | | | | A subsequent commit will instead use existing infrastructure to exclude the files from hwpmc.ko for non-ACPI builds. Note that the original commit left the files as optional in sys/conf/files.arm64. This reverts commit 751d88119fdc1dff71d1390c7768942a9b857bc6. Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D38736
* Fix the SPDX-License-Identifier in DMC-620 filesAndrew Turner2022-12-224-4/+4
| | | | | | | | | | | The SPDX-License-Identifier was wrong in the Arm CoreLink DMC-620 driver files. It used the incorrect FreeBSD variant of the BSD-2-Clause identifier. According to [1] all files should use BSD-2-Clause. [1] https://tools.spdx.org/app/check_license/ Reported by: emaste Sponsored by: Arm Ltd
* Fix the SPDX-License-Identifier in CMN-600 filesAndrew Turner2022-12-222-2/+2
| | | | | | | | | | | The SPDX-License-Identifier was wrong in the Arm CoreLink CMN-600 driver files. It used the incorrect FreeBSD variant of the BSD-2-Clause identifier. According to [1] all files should use BSD-2-Clause. [1] https://tools.spdx.org/app/check_license/ Reported by: emaste Sponsored by: Arm Ltd
* Fix loading the hwpmc module when ACPI is enabledAndrew Turner2022-12-222-1/+14
| | | | | | | | | | | | | In 0a9a4d2cd6092 a check for OPT_ACPI was added to the hwpmc Makefile to fix loading the module in a kernel where ACPI has been disabled. This broke loading the module when ACPI was enabled in the build as OPT_ACPI isn't a Makefile macro so was always disabled. Move this check to the C files where the DEV_ACPI macro does exist. Reviewed by: gnn Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D37773
* hwpmc: Define full set of Armv8.0 eventsJessica Clarke2022-10-101-2/+773
| | | | | | | | | | | | | | Like many of the other encodings here, none of these are actually used by our tables. However, defining the EVENT_xH names allows them to be used by the user (e.g. when trying to use an implementation-defined event that they know about from their core's documentation but we don't) and allows us to define PMC_EV_ARMV8_LAST appropriately. Some of these are also used downstream in CheriBSD on Morello. Reviewed by: andrew, tsoome Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D36926
* hwpmc: Move DMC-620 and CMN-600 events to allow for full Armv8.0 spaceJessica Clarke2022-10-101-7/+7
| | | | | | | | | | | | | | | | | | | The documented encoding space for Armv8 was only 8 bits, but v8.0 has always had a 10-bit encoding space for its events, and downstream in CheriBSD we relied on this full space. This worked until the DMC-620 and CMN-600 events were added, trampling on what should have been reserved for Armv8.0 right from the start. Thus, renumber the DMC-620 and CMN-600 events to not do this before they make it into a stable release, allowing for the full Armv8.0 encoding space to be used without having to split it across two different regions. Note that Armv8.1 grows the encoding space to 16 bits, which doesn't fit well with our current approach. No attempt is made to allow for these events in this change, only the ones that have always been valid (according to the hardware) from the first commit of Armv8 support to hwpmc. Reviewed by: arichardson, tsoome Differential Revision: https://reviews.freebsd.org/D36925
* hwpmc: purge EOL release compatibilityElliott Mitchell2022-09-083-14/+0
|
* hwpmc: Avoid touching MSR_DEBUGCTLMSR inside VMs.Alexander Motin2022-09-011-1/+1
| | | | | | | At least KVM in Proxmox seems not happy about it. Just to be safe block it for all VMs, since it should just improve profile accuracy. MFC after: 1 week
* arm64: Fix hwpmc module for OPT_ACPI isn't selectedEmmanuel Vadot2022-08-311-0/+6
| | | | | Fixes: 59191f3573f6 ("Add support of ARM CMN-600 controller ...") Sponsored by: Beckhoff Automation GmbH & Co. KG
* pmu_dmc620: Remove unused devclass from DRIVER_MODULE.John Baldwin2022-08-231-3/+1
|
* Adjust function definition in hwpmc to avoid clang 15 warningAndrew Turner2022-08-117-8/+8
| | | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/hwpmc/hwpmc_arm64.c:530:21: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] pmc_arm64_initialize() ^ void This is because many of the functions are declared with a (void) argument list, but defined with an empty argument list. Make the definition match the declaration. Sponsored by: The FreeBSD Foundation
* AST: reworkKonstantin Belousov2022-08-021-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | Make most AST handlers dynamically registered. This allows to have subsystem-specific handler source located in the subsystem files, instead of making subr_trap.c aware of it. For instance, signal delivery code on return to userspace is now moved to kern_sig.c. Also, it allows to have some handlers designated as the cleanup (kclear) type, which are called both at AST and on thread/process exit. For instance, ast(), exit1(), and NFS server no longer need to be aware about UFS softdep processing. The dynamic registration also allows third-party modules to register AST handlers if needed. There is one caveat with loadable modules: the code does not make any effort to ensure that the module is not unloaded before all threads processed through AST handler in it. In fact, this is already present behavior for hwpmc.ko and ufs.ko. I do not think it is worth the efforts and the runtime overhead to try to fix it. Reviewed by: markj Tested by: emaste (arm64), pho Discussed with: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35888
* Fix unused variable warnings in hwpmc_mod.cDimitry Andric2022-07-211-15/+0
| | | | | | | | | | | | | | | | | With clang 15, the following -Werror warnings are produced: sys/dev/hwpmc/hwpmc_mod.c:4805:6: error: variable 'nfree' set but not used [-Werror,-Wunused-but-set-variable] int nfree; ^ sys/dev/hwpmc/hwpmc_mod.c:4804:6: error: variable 'ncallchains' set but not used [-Werror,-Wunused-but-set-variable] int ncallchains; ^ The 'nfree' and 'ncallchains' variables were used in KASSERTs, but these were removed due to refactoring in d9f1b8dbf29d. Remove the variables since they no longer serve any purpose. MFC after: 3 days
* Adjust pmc_thread_descriptor_pool_drain() definition to avoid clang 15 warningDimitry Andric2022-07-211-1/+1
| | | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/hwpmc/hwpmc_mod.c:2462:33: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] pmc_thread_descriptor_pool_drain() ^ void This is because pmc_thread_descriptor_pool_drain() is declared with a (void) argument list, but defined with an empty argument list. Make the definition match the declaration. MFC after: 3 days
* Adjust pcm_md_initialize() definition to avoid clang 15 warningDimitry Andric2022-07-211-1/+1
| | | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/hwpmc/hwpmc_x86.c:245:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] pcm_md_initialize() ^ void This is because pcm_md_initialize() is declared with a (void) argument list, but defined with an empty argument list. Make the definition match the declaration. MFC after: 3 days
* Adjust pcmlog_{initialize,shutdown}() definitions to avoid clang 15 warningDimitry Andric2022-07-211-2/+2
| | | | | | | | | | | | | | | | | | | With clang 15, the following -Werror warnings are produced: sys/dev/hwpmc/hwpmc_logging.c:1228:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] pmclog_initialize() ^ void sys/dev/hwpmc/hwpmc_logging.c:1277:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] pmclog_shutdown() ^ void This is because pcmlog_{initialize,shutdown}() are declared with (void) argument lists, but defined with empty argument lists. Make the definitions match the declarations. MFC after: 3 days
* hwpmc: further fix build (__diagused/debug/missing files entries)Bjoern A. Zeeb2022-06-272-9/+5
| | | | | | | | | | Fix builds after 1459a22787ea16e3798694067c8dcb20325dca4b and 59191f3573f6cb2ea055ac319cbcb68823ca8e17 by using __diagused for variables only used in KASSERT(). In addition remove two debug lines that look like a copy and paste error from dmc620 to cmn600. Further add the newly introduced files to sys/confg/files.arm64 as well so that LINT compiles without missing symbols.
* pmc: unhide struct pmc_md_dmc620_pmu_op_pmcallocateBjoern A. Zeeb2022-06-271-2/+2
| | | | | | Fix build after e3572eb654733a94e1e765fe9e95e0579981d851 as struct pmc_md_dmc620_pmu_op_pmcallocate is needed when building libpmc/pmclog.c as it is partof the public API via machine/pmc_mdep.h.
* Add support of ARM CMN-600 controller, PMU access functions only. Add ↵Aleksandr Rybalko2022-06-261-0/+830
| | | | | | | | | | | support of PMU counters of ARM CMN-600 controller. Add support of ARM CMN-600 controller, PMU access functions only. Add support of PMU counters of ARM CMN-600 controller. Reviewed by: mhorne Sponsored By: ARM Differential Revision: https://reviews.freebsd.org/D32321
* The Arm CoreLink DMC-620 Dynamic Memory Controller PMU driverAleksandr Rybalko2022-06-262-0/+1020
| | | | | | | | | Add the Arm CoreLink DMC-620 Dynamic Memory Controller PMU driver Add DMC-620 support to hwpmc(4) Reviewed by: mhorne Sponsored By: Ampere Computing Differential Revision: https://reviews.freebsd.org/D32670
* Allocate event for DMC-620 and CMN-600 controllers PMU. Add events supported ↵Aleksandr Rybalko2022-06-264-1/+432
| | | | | | | | | | | | 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
* Support of optional PMC classes.Aleksandr Rybalko2022-06-262-5/+36
| | | | | Reviewed by: mhorne Differential Revision: https://reviews.freebsd.org/D32316
* hwpmc: Reenable PME before reenabling counters.Alexander Motin2022-06-151-3/+3
| | | | | | | | Doing otherwise may lead to lost interrupts, that in combination with hardware PMCs freezing may leave them frozen forever. It may also slightly improve profiling accuracy. MFC after: 2 weeks
* hwpmc: Correct sysctl description.Alexander Motin2022-06-151-1/+1
| | | | MFC after: 2 weeks
* hwpmc: Permit the minimum sampling count to be set as a sysctl.John Baldwin2022-06-091-12/+26
| | | | | | | | | | | A rarely occurring event (e.g. an event that occurs less than 1000 times during execution of a program) may require a lower minimum threshold than 1000. Replace the hardcoded 1000 with a sysctl that the administrator can use to permit smaller sampling count values. Reviewed by: mhorne, mav Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D35400
* hwpmc: Increase thread priority while iterating CPUs.Alexander Motin2022-06-072-21/+17
| | | | | | | | | | | This allows to profile already running high-priority threads, that otherwise by blocking thread migration to respective CPUs blocked PMC management, i.e. profiling could start only when workload completed. While there, return the thread to its original CPU after iterating the list. Otherwise all threads using PMC end up on the last CPU. MFC after: 1 month
* hwpmc: Add IDs for few more Intel Atom CPUs.Alexander Motin2022-06-032-4/+19
| | | | MFC after: 1 month
* hwpmc: Skip GLOBAL_CTRL updates on stop_pmc().Alexander Motin2022-06-022-10/+4
| | | | | | | | | | | | After we wipe PMC configuration, including its local enable bit(s), we don't really care about its global enable bit. Global enable bits now may only be cleared by interrupt handler in case of error (sample buffer overflow). Being set is actually a reset default for them. This saves one WRMSR per process-scope PMC per context switch, that is clearly visible in profiles. MFC after: 1 month
* hwpmc: Bump Intel's IA32_PERFEVTSELx width to 64 bits.Alexander Motin2022-06-024-23/+28
| | | | | | | Haswell added there bits 32/33 for TSX, and AlderLake added bit 34 for Adaptive PEBS Record. MFC after: 1 month
* hwpmc: Make powerpc memory allocation alike to x86.Alexander Motin2022-06-012-7/+5
| | | | | | It should remove some unneeded pointer dereferences. MFC after: 1 month