STRUCT PMU(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

struct pmu β€” the generic performance monitoring unit πŸ’… like, the blueprint, the moment, the whole vibe


✨ SYNOPSIS ✨

okay bestie sit down because this struct is long β€” it's giving "I have a callback for everything" main character energy. here it is, untouched, every single field, no cap:

struct pmu {
    struct list_head                entry;
    spinlock_t events_lock;
    struct list_head                events;
    struct module                   *module;
    struct device                   *dev;
    struct device                   *parent;
    const struct attribute_group    **attr_groups;
    const struct attribute_group    **attr_update;
    const char                      *name;
    int type;
    int capabilities;
    unsigned int                    scope;
    struct perf_cpu_pmu_context * __percpu *cpu_pmu_context;
    atomic_t exclusive_cnt;
    int task_ctx_nr;
    int hrtimer_interval_ms;
    unsigned int                    nr_addr_filters;
    void (*pmu_enable)              (struct pmu *pmu);
    void (*pmu_disable)             (struct pmu *pmu);
    int (*event_init)               (struct perf_event *event);
    void (*event_mapped)            (struct perf_event *event, struct mm_struct *mm);
    void (*event_unmapped)          (struct perf_event *event, struct mm_struct *mm);
  #define PERF_EF_START                   0x01;
  #define PERF_EF_RELOAD                  0x02;
  #define PERF_EF_UPDATE                  0x04;
  #define PERF_EF_PAUSE                   0x08;
  #define PERF_EF_RESUME                  0x10;
    int (*add)                     (struct perf_event *event, int flags);
    void (*del)                     (struct perf_event *event, int flags);
    void (*start)                   (struct perf_event *event, int flags);
    void (*stop)                    (struct perf_event *event, int flags);
    void (*read)                    (struct perf_event *event);
    void (*start_txn)               (struct pmu *pmu, unsigned int txn_flags);
    int (*commit_txn)              (struct pmu *pmu);
    void (*cancel_txn)              (struct pmu *pmu);
    int (*event_idx)                (struct perf_event *event);
    void (*sched_task)              (struct perf_event_pmu_context *pmu_ctx, struct task_struct *task, bool sched_in);
    struct kmem_cache               *task_ctx_cache;
    void *(*setup_aux)              (struct perf_event *event, void **pages, int nr_pages, bool overwrite);
    void (*free_aux)                (void *aux);
    long (*snapshot_aux)            (struct perf_event *event, struct perf_output_handle *handle, unsigned long size);
    int (*addr_filters_validate)    (struct list_head *filters);
    void (*addr_filters_sync)       (struct perf_event *event);
    int (*aux_output_match)         (struct perf_event *event);
    bool (*filter)                  (struct pmu *pmu, int cpu);
    int (*check_period)             (struct perf_event *event, u64 value);
 };

a few things I need to scream about, bestie:

  • the function-pointer section is lowkey a buffet β€” pmu_enable, pmu_disable, event_init, add, del, start, stop, read, start_txn, commit_txn, cancel_txn, event_idx, sched_task, setup_aux, free_aux, snapshot_aux, addr_filters_validate, addr_filters_sync, aux_output_match, filter, check_period… like, she has options πŸ‘‘
  • there are five #defines just vibing in the middle of the struct β€” PERF_EF_START 0x01, PERF_EF_RELOAD 0x02, PERF_EF_UPDATE 0x04, PERF_EF_PAUSE 0x08, PERF_EF_RESUME 0x10 β€” unhinged placement, but we respect it 🫢
  • two struct list_heads (entry and events) plus a spinlock_t events_lock, so yeah, list behaviour is very much part of her personality ✨
  • struct perf_cpu_pmu_context * __percpu *cpu_pmu_context is a whole triple-star situation, no notes πŸ’€
  • and atomic_t exclusive_cnt out here keeping count like the responsible friend πŸ™ˆ
fr fr everything above is verbatim from the page β€” don't let the sparkle fool you, those types and names are load-bearing πŸ’–

πŸŽ€ Members πŸŽ€

ngl the Members section is literally empty in the original. nothing. a whole heading with zero content, and honestly? iconic. the struct in SYNOPSIS is doing all the heavy lifting, so scroll back up if you skipped it πŸ¦‹


πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./include/linux/perf_event.h
  • struct hw_perf_event(9)
  • struct perf_addr_filter(9)
  • struct perf_addr_filters_head(9)
  • struct perf_event(9)
  • struct perf_event_context(9)
  • struct perf_ctx_data(9)

that's the whole page bestie, go read perf_event.h, it's right there 🌈

mwah πŸ’‹ this came from ./include/linux, dated October 2026, and the page itself is struct pmu(9) β€” go off, kernel API manual, you ate πŸŽ€βœ¨

πŸ“¦ where this page comes from