PMC_GET_MSR(3)

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

πŸ’– NAME πŸ’–

Okay bestie, this is PMC_GET_MSR(3) from the Library Functions Manual β€” it’s all about x86 architecture-specific PMC operations, and the function girlies are pmc_get_msr. Slay. ✨


πŸŽ€ LIBRARY πŸŽ€

Performance Counters Library (libpmc, -lpmc) β€” that’s the vibe, that’s the link line. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pmc.h>

int
pmc_get_msr(pmc_id_t pmc, uint32_t *msr);

🌸 DESCRIPTION 🌸

So the function pmc_get_msr() returns the processor model specific register number that’s associated with a PMC, for subsequent use with RDPMC instructions. Like, it’s giving β€œhere’s the magical number, go use it directly.” ✨

Argument pmc specifies a process scope counting PMC. The function will write the model specific register number associated with the PMC to the location pointed to by argument msr. No cap, it literally writes it right into *msr. 🫢

After successful completion of this function, applications can directly read the contents of PMC hardware using RDPMC instructions. So yeah, after it succeeds, the app can go straight to the hardware with RDPMC. Iconic. πŸ”₯


⭐ RETURN VALUES ⭐

The pmc_get_msr() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. Bestie, always check errno when you get that -1. 😭


πŸ’€ ERRORS πŸ’€

A call to pmc_get_msr() may fail with the following errors:

  • [EINVAL] β€” The PMC handle specified was invalid.
  • [EINVAL] β€” The PMC specified did not have process scope or counting mode.
  • [EINVAL] β€” The PMC specified was allocated with the PMC_F_DESCENDANTS flag.
  • [EINVAL] β€” The specified PMC is already attached to target processes other than the owner.
  • [ENOSYS] β€” The underlying hardware does not support an RDPMC instruction.

πŸ‘‘ SEE ALSO πŸ‘‘


Mwah πŸ’‹ β€” this little cutie is from source/version Debian, dated November 25, 2007, and its page is PMC_GET_MSR(3). Periodt. πŸŽ€πŸ’–

πŸ“¦ where this page comes from