PR_SET_TSC(2const)

πŸ’… PR_SET_TSC (the 2const one, bestie)

okay so you know how prctl(2) has like a million little sub-commands and you're supposed to just know which one does what? yeah. this is one of them. it lives in the 2const corner of the manual, and honestly? she's a lil niche x86 queen. πŸŽ€

It's all about the timestamp counter β€” that RDTSC-ish thing your CPU keeps ticking away β€” and whether your process is allowed to read it. That's it. That's the whole job. πŸ‘‘


✨ NAME ✨

PR_SET_TSC β€” change whether the timestamp counter can be read by the process

yes literally that. no cap. πŸ¦‹


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

like every other normal human function, she's just chillin' in libc. 🫢


🌸 SYNOPSIS 🌸

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

int prctl(PR_SET_TSC, long flag);

so you're calling prctl (the big grab-bag syscall wrapper) and you're passing PR_SET_TSC as the operation, plus one long called flag. That flag is where you tell her what vibe you want. πŸ’«


πŸ’– DESCRIPTION πŸ’–

So what she does is: she sets the state of the flag that determines whether the timestamp counter can be read by the process. Think of it like a lil permission switch on your process, and the CPU's counter is the thing behind it. πŸŽ€

And you flip that switch with flag, and there are exactly two moods:

  • PR_TSC_ENABLE β€” pass this and you're allowing the timestamp counter to be read. she's unlocked. go read it. ✨
  • PR_TSC_SIGSEGV β€” pass this and the process gets hit with a SIGSEGV the moment it tries to read the timestamp counter. not a fun surprise. she said no. πŸ’€
fr fr, that second one is not a gentle "permission denied" β€” it's a whole signal. so if you hand PR_TSC_SIGSEGV to some code that's just casually reading the TSC, you're gonna have a bad time. 😭

πŸ”₯ RETURN VALUE πŸ”₯

  • On success: 0 is returned. slay. βœ…
  • On error: -1 is returned, and errno gets set to tell you what went wrong. πŸ™ˆ

πŸ‘‘ ERRORS πŸ‘‘

  • EINVAL β€” flag is not a valid value.

that's it. that's the only one on the list. give her a flag she doesn't recognise and she simply Will Not. πŸ’…


🌈 STANDARDS 🌈

  • Linux.
  • x86 only.

so if you're out here on some other architecture, bestie, this is not the page for you. x86 girlies only. 🧚


⭐ HISTORY ⭐

  • Linux 2.6.26 (x86).

ancient by now but still iconic. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

(that second one is the read-only sibling β€” she asks, this one tells. iykyk. πŸ’œ)


that's the whole page, every single detail intact, nothing skipped, she's fully unhinged but 100% accurate. πŸŽ€

smooches, and remember: read your man pages, check your errno, and never hand PR_TSC_SIGSEGV to a process that's just vibing. πŸ’…βœ¨

this lil love letter is from Linux man-pages 6.20, dated 2026-02-08 β€” mwah, bye bestie! 🫢🌸

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms