PMC_ALLOCATE(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

🌸 NAME

okay so this is pmc_allocate(3), from the Library Functions Manual, and it's the page for pmc_allocate, pmc_release β€” allocate and free performance monitoring counters. bestie, we are literally allocating and freeing performance monitoring counters. periodt. πŸ’…

🫢 LIBRARY

Performance Counters Library (libpmc, -lpmc) β€” iconic, no cap.

✨ SYNOPSIS

#include <pmc.h>

int
pmc_allocate(const char *eventspecifier, enum pmc_mode mode,
    uint32_t flags, int cpu, pmc_id_t *pmcid, uint64_t count);

int
pmc_release(pmc_id_t pmc);

πŸ’– DESCRIPTION

okay so function pmc_allocate() allocates a performance monitoring counter that measures the events named by argument eventspecifier, and writes the allocated handle to the location pointed to by argument pmcid. slay. πŸ¦‹

Argument eventspecifier comprises a PMC event name followed by an optional comma separated list of keywords and qualifiers. The allowed syntax for argument eventspecifier is processor specific and is listed in section β€œEVENT SPECIFIERS” in the pmc(3) manual page. iykyk. ✨

The desired PMC mode is specified by argument mode. Legal values for the mode argument are:

  • PMC_MODE_SC β€” allocate a system-scope counting PMC. πŸ’«
  • PMC_MODE_SS β€” allocate a system-scope sampling PMC. 🌟
  • PMC_MODE_TC β€” allocate a process-scope counting PMC. 🧚
  • PMC_MODE_TS β€” allocate a process-scope sampling PMC. πŸŽ€

Mode specific modifiers may be specified using argument flags. The flags supported at PMC allocation time are:

  • PMC_F_DESCENDANTS β€” for process-scope PMCs, automatically track descendants of attached processes. πŸ‘‘
  • PMC_F_LOG_PROCCSW β€” for process-scope counting PMCs, generate a log event at every context switch containing the incremental number of hardware events seen by the process during the time it was executing on the CPU. πŸ”₯
  • PMC_F_LOG_PROCEXIT β€” for process-scope counting PMCs, accumulate hardware events seen when the process was executing on a CPU and generate a log event when an attached process exits. πŸ’œ
🚨 warning, bestie β€” PMCs allocated with flags PMC_F_LOG_PROCCSW and PMC_F_LOG_PROCEXIT need a log file to be configured before they are started. do not skip this part fr fr. 😭

For system scope PMCs, the argument cpu is a non-negative value that specifies the CPU number that the PMC is to be allocated on. Process scope PMC allocations should specify the constant PMC_CPU_ANY for this argument. πŸ–₯️✨

The count argument behaves identically to the pmc_set(3) function's value argument. For counting PMCs, count specifies the initial value of the allocated PMC. For sampling PMCs, count specifies the reload count. math-ing, but make it cute. πŸ“

Function pmc_release() releases the PMC denoted by argument pmcid. bye bye, counter. πŸ‘‹πŸ’–

πŸ’€ RETURN VALUES

If successful, function pmc_allocate() sets the location specified by argument pmcid to the handle of the allocated PMC and returns 0. In case of an error, the function returns -1 and sets the global variable errno to indicate the error. πŸ’…

The pmc_release() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. 😭

πŸ”₯ ERRORS

  • [EINVAL] β€” The argument mode to function pmc_allocate() had an invalid value.
  • [EINVAL] β€” Argument cpu to function pmc_allocate() had an invalid CPU number.
  • [EINVAL] β€” Argument flags contained flags that were unsupported or otherwise incompatible with the requested PMC mode.
  • [EINVAL] β€” Argument eventspecifier to function pmc_allocate() specified an event not supported by hardware or contained a syntax error.
  • [ENXIO] β€” Function pmc_allocate() requested the use of a hardware resource that was absent or administratively disabled.
  • [EOPNOTSUPP] β€” The underlying hardware does not support the capabilities needed for a PMC being allocated by a call to pmc_allocate().
  • [EPERM] β€” A system scope PMC allocation was attempted without adequate process privilege.
  • [ESRCH] β€” Function pmc_release() was called without first having allocated a PMC.
  • [EINVAL] β€” Argument pmcid to function pmc_release() did not specify a PMC previously allocated by this process.

🌈 SEE ALSO

pmc(3), pmc_attach(3), pmc_configure_logfile(3), pmc_start(3), hwpmc(4) β€” go read the lore, bestie. πŸ«ΆπŸ“š


πŸ’– source/version: Debian Β· date: April 21, 2021 β€” mwah, slay, bye bestie, go allocate something iconic and remember to release it. πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from