STRUCT PT_BUFFER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct pt_buffer(9) β€” Kernel API Manual, but make it a group chat πŸ’–

okay bestie, so this is a page from the Kernel API Manual and it's literally about struct pt_buffer β€” which is the buffer configuration, and there's one buffer per task_struct or per cpu, depending on the perf event configuration. slay. two possible situations, one struct, very main character.


✨ NAME ✨

struct pt_buffer β€” it's giving buffer configuration energy πŸŽ€ one buffer per task_struct or cpu, depending on your perf event configuration. iykyk.


πŸ¦‹ SYNOPSIS πŸ¦‹

struct pt_buffer {
    struct list_head        tables;
    struct topa             *first, *last, *cur;
    unsigned int            cur_idx;
    size_t output_off;
    unsigned long           nr_pages;
    local_t data_size;
    local64_t head;
    bool snapshot;
    bool single;
    bool wrapped;
    long stop_pos, intr_pos;
    struct topa_entry       *stop_te, *intr_te;
    void **data_pages;
 };

like, that's the whole struct, no cap. copy it exactly if you need it, i'm not touching a single character πŸ’…


πŸ‘‘ Members πŸ‘‘

okay so now we go through every single member, and no we are not skipping any, bestie. this is the whole list. periodt.

  • tables β€” the list of ToPA tables chilling in this buffer 🫢
  • first β€” shorthand for the first topa table, it's just a lil nickname
  • last β€” shorthand for the last topa table, same vibe
  • cur β€” the current topa table, the one we're literally on right now
  • cur_idx β€” the index of the current output region within cur's table
  • output_off β€” offset within the current output region, yes it's offset-ception
  • nr_pages β€” buffer size, in pages (pages!! not bytes, bestie, watch out)
  • data_size β€” a running total of how much data is in this buffer, like a little counter keeping track 🌸
  • head β€” the logical write offset inside the buffer, this is where the writing vibes happen
  • snapshot β€” true if this is for a snapshot/overwrite counter
  • single β€” use Single Range Output instead of ToPA
  • wrapped β€” buffer advance wrapped back to the first topa table, it did a little loop πŸŒ€
  • stop_pos β€” the STOP topa entry index
  • intr_pos β€” the INT topa entry index
  • stop_te β€” the STOP topa entry pointer
  • intr_te β€” the INT topa entry pointer
  • data_pages β€” array of pages from perf
πŸ’€ friendly reminder: stop_pos/intr_pos are the index versions and stop_te/intr_te are the pointer versions. don't mix them up, i'm begging πŸ™ˆ

🌈 SEE ALSO 🌈

go look at the kernel file ./arch/x86/events/intel/pt.h, and also these icons:

  • struct pt_filter(9)
  • struct pt_filters(9)
  • struct pt(9)

⭐ and that's the whole page, bestie. it lives under ./arch/x86/events/intel, dated October 2026, and you can find it chilling in struct pt_buffer(9) whenever you need it. ate and left no crumbs πŸ’œπŸŽ€

πŸ“¦ where this page comes from