Page MenuHomeFreeBSD

hwpmc: improve diagnostic messages for invalid tunables
ClosedPublic

Authored by paulo_nlink.com.br on Sun, Mar 22, 2:32 PM.
Tags
None
Referenced Files
F150492452: D56029.id174143.diff
Wed, Apr 1, 4:45 PM
Unknown Object (File)
Mon, Mar 30, 5:27 PM
Unknown Object (File)
Mon, Mar 30, 12:41 AM
Unknown Object (File)
Sun, Mar 29, 11:46 AM
Unknown Object (File)
Sat, Mar 28, 4:27 AM
Unknown Object (File)
Sat, Mar 28, 2:05 AM
Unknown Object (File)
Sat, Mar 28, 1:39 AM

Details

Summary

Replace printf() with log(LOG_WARNING, ...) in pmclog_initialize()
so that tunable validation failures are visible in dmesg and
/var/log/messages rather than only on the early console.

Also improve the messages to report both the invalid value and the
default it resets to, making it easier for users to understand why
their tunable was ignored.

Sponsored by: NLINK (nlink.com.br)

Test Plan

Set kern.hwpmc.nbuffers_pcpu="4096" in /boot/loader.conf.local or
/boot/loader.conf at your flavour.

After reboot, dmesg showed:
hwpmc: nbuffers_pcpu=4096 * logbuffersize=256 exceeds 32MB per CPU
limit, resetting to defaults (32 * 256)

Restored to kern.hwpmc.nbuffers_pcpu="128", clean boot, no warning.
Tested on AMD Ryzen 5600X (Family 19h / Zen 3), FreeBSD 16.0-CURRENT
master-n284614-1ba29614c4ce.

Diff Detail

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

Event Timeline

Might make sense to change these limits to #defines and also you might as well add this information to the man page for hwpmc.

Address ali_mashtizadeh.com feedback:

  • Extract hardcoded limits into named #defines in pmc.h: PMC_LOG_BUFFER_SIZE_MAX (16MB) and PMC_NLOGBUFFERS_PCPU_MEM_MAX (32MB)
  • Update log messages to use the new #defines
This revision is now accepted and ready to land.Mon, Mar 23, 3:49 AM
mhorne added a subscriber: mhorne.

Thanks. I will commit, with a couple of style/whitespace tweaks.