Page MenuHomeFreeBSD

pmcstat: fix duplicate event allocation on CPU 0
ClosedPublic

Authored by mhorne on Sep 25 2023, 5:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 1:47 PM
Unknown Object (File)
Sun, Apr 7, 9:29 AM
Unknown Object (File)
Sat, Apr 6, 9:50 PM
Unknown Object (File)
Mar 13 2024, 3:36 AM
Unknown Object (File)
Jan 17 2024, 11:25 PM
Unknown Object (File)
Dec 25 2023, 5:19 PM
Unknown Object (File)
Dec 13 2023, 4:10 AM
Unknown Object (File)
Dec 12 2023, 3:22 AM

Details

Summary

Commit b6e28991bf3a 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
0aa150775179a 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 b6e28991bf3a.

Reported by: alc, kevans

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This looks pretty good to me. FWIW, I have a test queued to verify this fixes the issue we were seeing; should have results by tomorrow (if not earlier).

Thanks!
--ap

This looks pretty good to me. FWIW, I have a test queued to verify this fixes the issue we were seeing; should have results by tomorrow (if not earlier).

Thanks!
--ap

Just got the results back and this does, indeed, fix the issue. Cheers!
--ap

This revision is now accepted and ready to land.Sep 26 2023, 11:43 AM
ray added a subscriber: ray.

Many thanks, Mitchell!