PMC_READ(3)
π PMC_READ(3) β bestie's guide to the library functions manual
okay so this is pmc_read(3), straight out of the Library Functions Manual, and no cap it's the whole trio: pmc_read, pmc_rw, and pmc_write. three icons, one page. let's get into it π
β¨ NAME β¨
pmc_read, pmc_rw, pmc_write β read and write hardware performance counters
like literally, that's the whole gig. reading counters, writing counters, and one very special atomic combo move π«
π LIBRARY π
Performance Counters Library (libpmc, -lpmc)
yes bestie you gotta link the library, don't forget the -lpmc or the linker will be like "who?" π
πΈ SYNOPSIS πΈ
#include <pmc.h>
int
pmc_read(pmc_id_t pmc, pmc_value_t *value);
int
pmc_rw(pmc_id_t pmc, pmc_value_t newvalue, pmc_value_t *oldvaluep);
int
pmc_write(pmc_id_t pmc, pmc_value_t value);
three little functions, all return int, all living their best lives in <pmc.h> π«Ά
π¦ DESCRIPTION π¦
so these functions read and write the current value of a PMC. that's the vibe check. πβοΈ
- function
pmc_read()will read the current value of the PMC specified by argument pmc and write it to the location specified by argument value. it's giving "just peek at it, don't touch" π - function
pmc_write()will set the current value of the PMC specified by argument pmc to the value specified by argument value. full send, we're overwriting βοΈ - function
pmc_rw()combines a read and a write into a single atomic operation. iconic behavior actually β one move, no in-between, nobody can sneak in the middle π β¨
β οΈ important lil note: for write operations the PMC should be a quiescent state. like, be QUIET please, the counter is busy π«₯
π RETURN VALUES π
upon successful completion, the value 0 is returned β slay, we love a zero π
otherwise the value -1 is returned and the global variable errno is set to indicate the error. so if you see -1, go check errno, it's literally telling you what went wrong π
π₯ ERRORS π₯
a call to these functions may fail with the following errors:
[EBUSY]β a write operation specified a currently running PMC. bestie it's BUSY, stop trying to write to it while it's working π€[EINVAL]β argument pmc specified a PMC not in a readable state. can't read it, it's not in its readable era rn π[EINVAL]β the PMC specified by argument pmc was not owned by the current process. not yours, not your counter, no cap π«π
(note that EINVAL shows up twice with two different meanings β she's versatile, she contains multitudes π§)
π SEE ALSO π
go read those too, iykyk ππ
and that's the whole page!! this beauty came from Debian, dated November 25, 2007 β a vintage, an absolute classic, we stan a timestamped legend βππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2007 Joseph Koshy. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms