---
name: "pmc_pmcinfo"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pmc_capabilities"
---

# pmc\_pmcinfo(3)

retrieve information about performance monitoring counters

Part of [pmc\_capabilities(3)](/pmc_capabilities/3.md).

## NAME

**pmc\_capabilities**, **pmc\_cpuinfo**, **pmc\_ncpu**, **pmc\_npmc**, **pmc\_pmcinfo**, **pmc\_width** – retrieve information about performance monitoring counters

## LIBRARY

library “libpmc”

## SYNOPSIS

**#include \<pmc.h\>**

*int*\

**pmc\_capabilities**(*pmc\_id\_t pmc*, *uint32\_t \*caps*);

*int*\

**pmc\_cpuinfo**(*const struct pmc\_cpuinfo \*\*cpu\_info*);

*int*\

**pmc\_ncpu**(*void*);

*int*\

**pmc\_npmc**(*int cpu*);

*int*\

**pmc\_pmcinfo**(*int cpu*, *struct pmc\_pmcinfo \*\*pmc\_info*);

*int*\

**pmc\_width**(*pmc\_id\_t pmc*, *uint32\_t \*width*);

## DESCRIPTION

These functions retrieve information about performance monitoring hardware.

Function **pmc\_capabilities**() retrieves the hardware capabilities of a PMC. Argument *pmc* is a PMC handle obtained by a prior call to **pmc\_allocate**(). The function sets argument *caps* to a bit mask of capabilities supported by the PMC denoted by argument *pmc*. PMC capabilities are described in [pmc(3)](/pmc/3.md).

Function **pmc\_cpuinfo**() retrieves information about the CPUs in the system. Argument *cpu\_info* will be set to point to an internal structure with information about the system's CPUs. The caller should not free this pointer value. This structure has the following fields:

- pm\_cputype

  Specifies the CPU type.

- pm\_ncpu

  Specifies the number of CPUs in the system.

- pm\_npmc

  Specifies the number of PMC rows per CPU.

- pm\_nclass

  Specifies the number of distinct classes of PMCs in the system.

- pm\_classes

  Contains an array of *struct pmc\_classinfo* descriptors describing the properties of each class of PMCs in the system.

Function **pmc\_ncpu**() is a convenience function that returns the maximum CPU number in the system. On systems that support sparsely numbered CPUs, not all CPUs may be physically present. Applications need to be prepared to deal with nonexistent CPUs.

Function **pmc\_npmc**() is a convenience function that returns the number of PMCs available in the CPU specified by argument *cpu*.

Function **pmc\_pmcinfo**() returns information about the current state of the PMC hardware in the CPU specified by argument *cpu*. The location specified by argument *pmc\_info* is set to point an array of *struct pmc\_info* structures each describing the state of one PMC in the CPU. These structure contain the following fields:

- pm\_name

  A human readable name for the PMC.

- pm\_class

  The PMC class for the PMC.

- pm\_enabled

  Non-zero if the PMC is enabled.

- pm\_rowdisp

  The disposition of the PMC row for this PMC. Row dispositions are documented in [hwpmc(4)](/hwpmc/4.md).

- pm\_ownerpid

  If the hardware is in use, the process id of the owner of the PMC.

- pm\_mode

  The PMC mode as described in [pmc(3)](/pmc/3.md).

- pm\_event

  If the hardware is in use, the PMC event being measured.

- pm\_flags

  If the hardware is in use, the flags associated with the PMC.

- pm\_reloadcount

  For sampling PMCs, the reload count associated with the PMC.

Function **pmc\_width**() is used to retrieve the width in bits of the hardware counters associated with a PMC. Argument *pmc* is a PMC handle obtained by a prior call to **pmc\_allocate**(). The function sets the location pointed to by argument *width* to the width of the physical counters associated with PMC *pmc*.

## RETURN VALUES

Functions **pmc\_ncpu**() and **pmc\_npmc**() returns a positive integer if successful; otherwise the value -1 is returned and the global variable *errno* is set to indicate the error.

Functions **pmc\_capabilities**(), **pmc\_cpuinfo**(), **pmc\_pmcinfo**() and **pmc\_width**() return 0 if successful; otherwise the value -1 is returned and the global variable *errno* is set to indicate the error.

## ERRORS

A call to function **pmc\_capabilities**() may fail with the following errors:

- \[EINVAL\]

  The argument to the function was invalid.

Calls to functions **pmc\_cpuinfo**(), **pmc\_ncpu**() and **pmc\_npmc**() may fail with the following errors:

- \[ENXIO\]

  A prior call to **pmc\_init**() to initialize the PMC library had failed.

A call to function **pmc\_pmcinfo**() may fail with the following errors:

- \[EINVAL\]

  The argument *cpu* was invalid.

- \[ENXIO\]

  The argument *cpu* specified a disabled or absent CPU.

A call to function **pmc\_width**() may fail with the following errors:

- \[EINVAL\]

  The argument to the function was invalid.

## SEE ALSO

[pmc(3)](/pmc/3.md), [pmc\_allocate(3)](/pmc_allocate/3.md), [pmc\_get\_driver\_stats(3)](/pmc_get_driver_stats/3.md), [pmc\_name\_of\_capability(3)](/pmc_name_of_capability/3.md), [pmc\_name\_of\_class(3)](/pmc_name_of_class/3.md), [pmc\_name\_of\_cputype(3)](/pmc_name_of_cputype/3.md), [pmc\_name\_of\_event(3)](/pmc_name_of_event/3.md), [pmc\_name\_of\_mode(3)](/pmc_name_of_mode/3.md), [hwpmc(4)](/hwpmc/4.md)
