PR_TASK_PER...ENTS_DISABLE(2)

πŸ“¦ version 6.9.1, in debian trixie, ubuntu questing

✨ PR_TASK_PER...ENTS_DISABLE(2) ✨

System Calls Manual πŸŽ€ bestie, this page is about the prctl() calls that switch performance counters off and on for your process. Let's get into it πŸ’…

πŸ’– NAME

PR_TASK_PERF_EVENTS_DISABLE, PR_TASK_PERF_EVENTS_ENABLE β€” disable or enable performance counters attached to the calling process πŸ¦‹

πŸ“š LIBRARY

Standard C library (libc, -lc) 🌸

🧩 SYNOPSIS

#include <linux/prctl.h>  /* Definition of PR_* constants */
#include <sys/prctl.h>

int prctl(PR_TASK_PERF_EVENTS_DISABLE);
int prctl(PR_TASK_PERF_EVENTS_ENABLE);

πŸ”₯ DESCRIPTION

okay so these two are a matching pair, no cap ✨

  • PR_TASK_PERF_EVENTS_DISABLE β€” this one shuts off every performance counter attached to the calling process, and it doesn't matter who made them. Your process made them or some other process did, either way they're getting switched off πŸ™ˆ Counters that your process created for other processes? Those are totally unaffected, so don't panic.
  • PR_TASK_PERF_EVENTS_ENABLE β€” the total opposite of the one above! It turns the performance counters attached to the calling process back on 🧚

πŸ‘‘ RETURN VALUE

On success, 0 is returned πŸ’œ. On error, -1 is returned and errno gets set to tell you what went wrong 😭

🌈 STANDARDS

Linux. 🐧

πŸ•°οΈ HISTORY

Linux 2.6.31 is where this started πŸ“

Fun little plot twist: these were originally called PR_TASK_PERF_COUNTERS_DISABLE and PR_TASK_PERF_COUNTERS_ENABLE. They got renamed in Linux 2.6.32, but the numerical value stayed exactly the same, so nothing actually broke 🫢

πŸ”— SEE ALSO

prctl(2) ✨

For more on performance counters, check out the Linux kernel source file tools/perf/design.txt πŸ€“


Linux man-pages 6.9.1, dated 2024-06-02, and the PR_TASK_PER...ENTS_DISABLE(2) page itself πŸŽ€ bye bestie, go be a main character πŸ’…πŸ¦‹

πŸ“¦ where this page comes from