PMC_CONFIGURE_LOGFILE(3)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.1

๐Ÿ’… PMC_CONFIGURE_LOGFILE(3) โ€” log file management, but make it make sense

okay bestie so this is PMC_CONFIGURE_LOGFILE(3) from the Library Functions Manual and it's genuinely so useful โ€” it's all about wrangling log files for hwpmc(4) events ๐ŸŽ€


โœจ NAME โœจ

pmc_configure_logfile, pmc_flush_logfile, pmc_writelog, pmc_close_logfile โ€” log file management

๐Ÿ“š LIBRARY ๐Ÿ“š

Performance Counters Library (libpmc, -lpmc) โ€” yes you gotta link it, no cap ๐Ÿ”ฅ

๐Ÿซถ SYNOPSIS ๐Ÿซถ

#include <pmc.h>

int
pmc_configure_logfile(int fd);

int
pmc_flush_logfile(void);

int
pmc_writelog(uint32_t userdata);

int
pmc_close_logfile(void);

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so these four functions are the whole friend group that manages logging of hwpmc(4) events ๐Ÿ’– like that's their entire job and they ate.

Let me break down who does what, one icon at a time:

  • pmc_configure_logfile(fd) turns logging on and off โ€” main character energy, honestly. The way it works: if the argument fd is a valid file handle returned by a prior call to open(2) or socket(2), then performance events get logged to the file corresponding to that handle โœจ but if the value of fd is -1? Then logging gets stopped after any pending data is flushed. bye bestie ๐Ÿ‘‹
  • pmc_flush_logfile() forces ALL log data queued inside the hwpmc(4) driver to be written out. like it literally will not leave that data sitting in there, obsessed ๐Ÿ˜ญ
  • pmc_writelog(userdata) appends a log entry containing the value of userdata to the log file. cute little custom note, love that for you ๐Ÿฆ‹
  • pmc_close_logfile() flushes all pending log data and closes hwpmc(4)'s side of the stream. graceful exit, periodt ๐Ÿ’…

โญ RETURN VALUES โญ

Upon successful completion, the value 0 is returned ๐ŸŒˆ otherwise the value -1 is returned and the global variable errno is set to indicate the error ๐Ÿšจ like it's telling you exactly what went wrong, iykyk.

๐Ÿ’€ ERRORS ๐Ÿ’€

a call to pmc_configure_logfile() may fail with these, mmkay

  • [EAGAIN] โ€” the hwpmc(4) driver was not able to create a helper process due to system limits being reached ๐Ÿ˜ฎโ€๐Ÿ’จ (system said "no more helpers", rude)
  • [EBUSY] โ€” function pmc_configure_logfile() was called with a log file already configured ๐Ÿ™ˆ one at a time please!!
  • [EINVAL] โ€” function pmc_configure_logfile() was called with an argument of -1 without a log file being previously configured ๐Ÿ’€ you can't stop what was never started, bestie
  • [ENOMEM] โ€” the system encountered a memory shortage when servicing this request ๐Ÿ“ memory said "not today"

a call to pmc_flush_logfile() may fail with this one

  • [EINVAL] โ€” function pmc_flush_logfile() was called without a log file being previously configured ๐Ÿ˜ญ pls configure first

a call to pmc_writelog() may fail with these two

  • [EINVAL] โ€” function pmc_writelog() was called without a log file being previously configured ๐Ÿ™ˆ same vibe, no log file, no entry
  • [ENOMEM] โ€” the system encountered a memory shortage when servicing this request ๐Ÿ“ again with the memory shortage
ngl fam, the recurring theme here is: configure your log file first. the setup is the whole plot. โœจ

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

the crossover episode you didn't know you needed ๐Ÿงš


that's the whole page bestie, go forth and log responsibly ๐Ÿ’œ

Debian โ€” November 24, 2007 โ€” pmc_configure_logfile(3), signing off ๐ŸŽ€

๐Ÿ“ฆ where this page comes from