freebsd-src/usr.sbin/pmcstat
Mitchell Horne c362fe939f pmcstat: fix duplicate event allocation on CPU 0
Commit b6e28991bf modified the allocation path for system scope PMCs
so that the event was allocated early for CPU 0. The reason is so that
the PMC's capabilities could be checked, to determine if pmcstat should
allocate the event on every CPU, or just on one CPU in each NUMA domain.
In the current scheme, there is no way to determine this information
without performing the PMC allocation.

This broke the established use-case of log analysis, and so
0aa1507751 was committed to fix the assertion. The result was what
appeared to be functional, but in normal counter measurement pmcstat was
silently allocating two counters for CPU 0.

This cuts the total number of counters that can be allocated from a CPU
in half. Additionally, depending on the particular hardware/event, we
might not be able to allocate the same event twice on a single CPU.

The simplest solution is to release the early-allocated PMC once we have
obtained its capabilities, and reallocate it later on. This restores the
event list logic to behave as it has for many years, and partially
reverts commit b6e28991bf.

Reported by:	alc, kevans
Reviewed by:	jkoshy, ray
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41978
2023-09-27 13:39:56 -03:00
..
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
pmcpl_annotate.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pmcpl_annotate.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcpl_annotate_cg.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pmcpl_annotate_cg.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcpl_callgraph.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pmcpl_callgraph.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcpl_calltree.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pmcpl_calltree.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcpl_gprof.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pmcpl_gprof.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcstat.8 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
pmcstat.c pmcstat: fix duplicate event allocation on CPU 0 2023-09-27 13:39:56 -03:00
pmcstat.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcstat_log.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pmcstat_log.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pmcstat_top.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00