aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/hwpmc
Commit message (Collapse)AuthorAgeFilesLines
* hwpmc_armv7: plug memory leakMitchell Horne2023-09-111-1/+9
| | | | | | | | | | | | | Free allocated per-CPU structures in the pcpu_fini and finalize methods. While here, add debug trace entries to these methods. Reviewed by: jkoshy, andrew MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41269 (cherry picked from commit 9c0a2d522f3a18fc795a7dd6266d2be2aff4b084)
* hwpmc_arm64: plug memory leakMitchell Horne2023-09-111-1/+9
| | | | | | | | | | | | | Free allocated per-CPU structures in the pcpu_fini and finalize methods. While here, add debug trace entries to these methods. Reviewed by: jkoshy, andrew MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41268 (cherry picked from commit 8bdceaecabd91ce5ed23646d91cef878681e19d6)
* Fix mis-mergeKonstantin Belousov2023-08-281-1/+1
|
* hwpmc: on process exit, ensure that the owned log is closedKonstantin Belousov2023-08-281-3/+5
| | | | (cherry picked from commit 3c872a70b883e4e2b38135bd6bd114ac9d2ea579)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-2323-46/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-2311-22/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-2524-24/+24
| | | | | | | | | | | 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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* pmc_events.h: update top-level commentMitchell Horne2023-07-171-5/+3
| | | | | | | | | | It points to non-existent documentation. The wiki page still contains a useful overview, so keep this link. MFC after: 3 days Sponsored by: The FreeBSD Foundation (cherry picked from commit f7a217060608b5fa9e7c59724a617b7241a3ee3b)
* hwpmc: remove stub pmd_switch_{in,out} methodsMitchell Horne2023-06-094-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 (cherry picked from commit fa88954fd8f16ef60084a73d446a23e791ed22e5)
* hwpmc: remove pmd_pcpu_{init,fini} callbacksMitchell Horne2023-06-093-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 (cherry picked from commit 772b2dc3abc5072743e7598d35e0a8ad621e7b0d)
* hwpmc: pass pmc pointer to more class methodsMitchell Horne2023-06-0913-306/+83
| | | | | | | | | | | | | | 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 (cherry picked from commit 39f92a76a99a2ceb747250da4f2d627b9c317f8c)
* hwpmc: unused/diagused annotations in tsc classMitchell Horne2023-06-091-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 (cherry picked from commit a35453b9c7644f11df83d0c7e73da488f521e56e)
* hwpmc: use kstack_contains()Mitchell Horne2023-06-093-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 (cherry picked from commit aba91805aa92a47b2f3f01741a55ff9f07c42d04)
* hwpmc: purge EOL release compatibilityElliott Mitchell2023-06-093-14/+0
| | | | (cherry picked from commit cb6abe87cf1c178ea1b9cd8a385e53459aef96e8)
* hwpmc: simplify arm64 kernel stack unwindingMitchell Horne2023-06-091-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 (cherry picked from commit 5387495773e9e92441b795c0eb8c2a3ecc25708a)
* hwpmc_logging: less macro magic for type namesMitchell Horne2023-06-091-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 (cherry picked from commit 3a7c9fc01bdae13edbd5724745b748e6a61065eb)
* hwpmc: don't use deprecated copystr(9)Mitchell Horne2023-06-0910-76/+20
| | | | | | | | | | | | 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 (cherry picked from commit 31610e34b7e39d573d927ea98346c88f23cabdab)
* hwpmc: trim obsolete Intel CPU and class defsMitchell Horne2023-06-091-1/+1
| | | | | | | | | | | No functional change. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39904 (cherry picked from commit ca43b2ae3ef2ed86b0df36296464d7830b61b944)
* pmc_events.h: event list formattingMitchell Horne2023-06-091-28/+28
| | | | | | | | | | | | 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 (cherry picked from commit b6c9d2a3f892169d4a6acc92869f9d9db52876ea)
* pmc_events.h: update event list commentMitchell Horne2023-06-091-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 (cherry picked from commit 6bdf067890ed1d1515ad0dbd105848bb11711210)
* hwpmc: remove remaining UCP event definitionsMitchell Horne2023-06-092-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 (cherry picked from commit d71a439020721a9abea5c353b9e03b5dc29d253e)
* hwpmc: drop vestigial IAP event definitionsMitchell Horne2023-06-091-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 (cherry picked from commit 1be8ef26794dcf93e2f4851474808dc3b34dbcbd)
* hwpmc: Fix a typoMark Johnston2023-05-091-1/+1
| | | | | | MFC after: 1 week (cherry picked from commit 56da525b535f8537205bccd1f4b25b3ce354ca62)
* arm64 hwpmc: Support restricting counters to user or kernel mode.John Baldwin2022-11-101-0/+17
| | | | | | | | | | | | Support the "usr" and "os" qualifiers on arm64 events to restrict event counting to either usermode or the kernel, respectively. If neither qualifier is given, events are counted in both. Reviewed by: emaste Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D34527 (cherry picked from commit 6bb7ba4aa180f667c1b558de1fc364f41bab57ce)
* pmc_save_user_callchain: eliminate write only td variableWarner Losh2022-10-021-2/+0
| | | | | | Sponsored by: Netflix (cherry picked from commit 6ca6b8ea523daa6f17e010711458800f30d2e1ee)
* hwpmc: Avoid touching MSR_DEBUGCTLMSR inside VMs.Alexander Motin2022-09-081-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 (cherry picked from commit 4e679d8aeaa86ce061b15c51fe9a5eae1eff7470)
* Adjust function definition in hwpmc to avoid clang 15 warningAndrew Turner2022-08-225-5/+5
| | | | | | | | | | | | | | | | | 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 (cherry picked from commit 05cef74742154cf3c89be214a464d8fabddf8d7d)
* Adjust pmc_thread_descriptor_pool_drain() definition to avoid clang 15 warningDimitry Andric2022-07-241-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 (cherry picked from commit 555d2c9394fa673241fd26a95152adfb9d20952e)
* Adjust pcm_md_initialize() definition to avoid clang 15 warningDimitry Andric2022-07-241-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 (cherry picked from commit dc0cde7a21a6aab0a5e876d8f890764e32718932)
* Fix unused variable warnings in hwpmc_mod.cDimitry Andric2022-07-241-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 (cherry picked from commit 38a9b8a00ce933e99b4a643cdcc3220be82e7d62)
* Adjust pcmlog_{initialize,shutdown}() definitions to avoid clang 15 warningDimitry Andric2022-07-241-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 (cherry picked from commit ba95c556029357800d18a5bc5abd02a2b7d0c9de)
* hwpmc: Permit the minimum sampling count to be set as a sysctl.John Baldwin2022-07-131-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 (cherry picked from commit ca341f3cf52f8cb036d93cd611d8f3f5b552ea8e)
* hwpmc: don't validate capabilities in allocation methodMitchell Horne2022-07-056-32/+5
| | | | | | | | | | | | These checks were inconsistently applied across the various hwpmc classes. The condition is already checked by the generic code in hwpmc_mod.c, so remove them. MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31388 (cherry picked from commit 0e78510b75497d183ab1aafbd99ff1031798bd84)
* hwpmc: consistently validate PMC class in allocation methodMitchell Horne2022-07-057-0/+16
| | | | | | | | | | | | | | | | | | It is always a good idea. In one case, attempting to allocate N+1 PMCs from a class with N hardware counters would incorrectly attempt to allocate from the next class in the list. Without this validation, this can lead to all kinds of strange behaviour. Since powerpc_allocate_pmc() is used by both the mpc7xxx and ppc970 classes, add a new global to track which is active (it will never be both). Reviewed by: luporl, ray MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31387 (cherry picked from commit 315cd55dba61416495a847f0eed6e522421e2347)
* hwpmc: Reenable PME before reenabling counters.Alexander Motin2022-07-041-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 (cherry picked from commit f9e62419f6daf226a7116be2601842f8f07b1928)
* hwpmc: Correct sysctl description.Alexander Motin2022-07-041-1/+1
| | | | | | MFC after: 2 weeks (cherry picked from commit 918505d0a084d18ad8e440c12c24b58231b33626)
* hwpmc: Increase thread priority while iterating CPUs.Alexander Motin2022-07-042-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 (cherry picked from commit eff9ee7c0c8e1fe782d6c01a29bb23224b02a847)
* hwpmc: Add IDs for few more Intel Atom CPUs.Alexander Motin2022-07-042-4/+19
| | | | | | MFC after: 1 month (cherry picked from commit 1326017849ee0536e415d69f150514d410b588ff)
* hwpmc: Skip GLOBAL_CTRL updates on stop_pmc().Alexander Motin2022-07-042-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 (cherry picked from commit 326a8d3e085dda2b82c99cf1eb2997cb4dc99a71)
* hwpmc: Bump Intel's IA32_PERFEVTSELx width to 64 bits.Alexander Motin2022-07-044-23/+28
| | | | | | | | | Haswell added there bits 32/33 for TSX, and AlderLake added bit 34 for Adaptive PEBS Record. MFC after: 1 month (cherry picked from commit 1a4614a51ee7e3d3cd4ef30b16e13f9ef1713a56)
* hwpmc: Make powerpc memory allocation alike to x86.Alexander Motin2022-07-042-7/+5
| | | | | | | | It should remove some unneeded pointer dereferences. MFC after: 1 month (cherry picked from commit 47699fc265b9d966b4eba6bc0c41739ac793f52b)
* hwpmc: Remove always zero pc_resync field.Alexander Motin2022-07-041-21/+8
| | | | | | MFC after: 1 month (cherry picked from commit 5acb4c862b5b22c0556545a0e3a8dc2300238aca)
* hwpmc: Add basic Intel Alderlake CPUs support.Alexander Motin2022-07-042-80/+28
| | | | | | | | | | The PMC subsystem is not designed for non-uniform CPU capabilities (P/E-cores are different), but at least several working architectural events like cpu_clk_unhalted.thread_p should be better than nothing. MFC after: 1 month (cherry picked from commit fe109d3113166c8e3b8557f0569c4e5a3597ac93)
* hwpmc: Update Intel's programmable counters restrictions.Alexander Motin2022-07-041-47/+54
| | | | | | | | Primarily remove unneeded restrictions from later CPUs. MFC after: 1 month (cherry picked from commit ae57fbc7ec65fcc75575a55c911e0da32ea9c20d)
* hwpmc: Correct selection of Intel fixed counters.Alexander Motin2022-07-041-9/+25
| | | | | | | | | Intel json's use event=0 to specify fixed counter number via umask. Alternatively fixed counters have equivalent programmable event/umask. MFC after: 1 month (cherry picked from commit c1e813d1230915e19a236ec687cadc1051841e56)
* hwpmc: Use hardware PMCs freezing on PMI on Intel v2+.Alexander Motin2022-07-041-129/+86
| | | | | | | | | | Since version 2 Intel CPUs can freeze PMCs when intering PMI to reduce PMI effects on collected statistics. Since version 4 hardware supports "streamlined" mechanism, not requiring IA_GLOBAL_CTRL MSR access. MFC after: 1 month (cherry picked from commit 81ffb45f02dac470cfeddb98f2e4af2d895fea4a)
* hwpmc: Add Intel Core register defines up to version 5.Alexander Motin2022-07-041-6/+15
| | | | | | MFC after: 1 month (cherry picked from commit 245b056556e61792ae3cb21fd61e9b2ce362f4b9)
* hwpmc_intel: assert for correct nclasses valueMitchell Horne2022-07-041-0/+2
| | | | | | | | | | | | | | | | This variable is set based on the exact CPU model detected. If this value is set too small, it could lead to a NULL-dereference from an improperly initialized pmc_rowindex_to_classdep array. Though it has been fixed, this was previously the case for Broadwell. Add two asserts to catch this in DEBUG kernels, as it represents a configuration error that may be hard to uncover otherwise. PR: 253687 Reported by: Zhenlei Huang <zlei.huang@gmail.com> Sponsored by: The FreeBSD Foundation (cherry picked from commit 8399d923a5697b7c194dbd44c33018c94ec42c4e)
* hwpmc: drop 0x before %p printf format stringEd Maste2022-02-081-1/+1
| | | | | | | | %p already includes the 0x. Sponsored by: The FreeBSD Foundation (cherry picked from commit 2075d00fabb6d6a76c4829b9e027a496f04262b0)
* hwpmc(4): Fix a typo in a sysctl descriptionGordon Bergling2022-01-291-1/+1
| | | | | | - s/avalable/available/ (cherry picked from commit 9966757dd6efe7514290d41cae761baf389dcfc2)