Page MenuHomeFreeBSD

libpmc: userland support and pmc.rapl.3 for the RAPL class
ClosedPublic

Authored by afscoelho_gmail.com on Jul 3 2026, 6:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Aug 15, 5:13 PM
Unknown Object (File)
Sat, Aug 15, 4:09 PM
Unknown Object (File)
Sat, Aug 15, 4:06 PM
Unknown Object (File)
Sat, Aug 15, 3:58 PM
Unknown Object (File)
Thu, Aug 13, 1:07 AM
Unknown Object (File)
Mon, Aug 10, 12:36 PM
Unknown Object (File)
Sun, Aug 9, 8:15 PM
Unknown Object (File)
Sun, Aug 9, 4:18 PM
Subscribers

Details

Summary

Register PMC_CLASS_RAPL in libpmc: event table, allocator, class-table
descriptor, and the event-name/class-listing lookups, all x86-guarded
and modeled on the TSC class. Energy events are read-only and
unqualified. The class prefix (RAPL-) supplies the friendly spelling, so
pmcstat -S rapl-energy-pkg resolves to the canonical ENERGY_PKG event.

Add a pmc.rapl.3 manual page documenting the events, counter scope, the
microjoule unit and wrap handling, and the NUMA/package domain mapping;
link it from pmc.3.

Diff Detail

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

Event Timeline

lib/libpmc/pmc.rapl.3
28

sentence after the semicolon doesn't follow. If your talking about the bug fix drop it?

41

Maybe something close to: The RAPL PMC driver provides a virtual 64-bit counter that is guaranteed to be monotonic, by periodically sampling the 32-bit hardware counters that wrap frequently. Saying the kernel folds them is awkward.

mhorne added inline comments.
lib/libpmc/libpmc.c
895

Are the casts needed?

899
This revision is now accepted and ready to land.Jul 10 2026, 4:48 PM

Address review feedback: drop the unneeded (int) casts on pe in rapl_allocate_pmc, since the RAPL bounds are enum pmc_event members (mhorne); reword the microjoule-scaling sentence and describe wrap handling as a virtual 64-bit counter in pmc.rapl.3 (ali_mashtizadeh).

This revision now requires review to proceed.Jul 14 2026, 7:51 PM
afscoelho_gmail.com marked 2 inline comments as done.

Address review: use explicit 'ctrspec != NULL' in rapl_allocate_pmc (mhorne, style(9)).

afscoelho_gmail.com added inline comments.
lib/libpmc/libpmc.c
895

No, they are not! I copied this from soft_allocate_pmc and didn't check, thanks for the warning !

lib/libpmc/pmc.rapl.3
28

right, I reworded it.

41

I did as you suggested, thanks!

mhorne added inline comments.
lib/libpmc/pmc.rapl.3
2–5
This revision is now accepted and ready to land.Jul 16 2026, 6:21 PM
This revision now requires review to proceed.Mon, Jul 27, 7:11 PM
This revision was not accepted when it landed; it landed in state Needs Review.Tue, Jul 28, 3:02 PM
This revision was automatically updated to reflect the committed changes.