STRUCT PERF_FILE_HEADER(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’– struct perf_file_header(9) ๐Ÿ’–

ok so bestie, welcome to the struct perf_file_header(9) page from the Kernel API Manual โ€” this is the little on-disk glow-up that heads up a perf file, and honestly? it's giving โœจ*manifest*โœจ energy. let's get into it ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

struct perf_file_header โ€” the header representation on disk, no cap. this is literally the first thing that shows up when your perf file wakes up and chooses main character energy ๐Ÿ’…


โœจ SYNOPSIS โœจ

struct perf_file_header {
    u64 magic;
    u64 size;
    u64 attr_size;
    struct perf_file_section        attrs;
    struct perf_file_section        data;
    struct perf_file_section        event_types;
    unsigned long adds_features[BITS_TO_LONGS( HEADER_FEAT_BITS)];
};

like, look at her. seven whole fields. iconic. ๐Ÿ‘‘


๐Ÿฆ‹ Members ๐Ÿฆ‹

okay so let's go field by field because every single one matters, fr fr ๐Ÿซถ

  • magic โ€” holds "PERFILE2". that's the vibe check at the door โ€” if this doesn't match, the file is not getting in ๐Ÿ”ฅ
  • size โ€” the size of this header, literally sizeof(struct perf_file_header). she knows her own measurements ๐Ÿ’–
  • attr_size โ€” the size of the attrs entries, and that's sizeof(struct perf_event_attr) + sizeof(struct perf_file_section). yes, both. do the math, don't skip a term ๐Ÿงฎโœจ
  • attrs โ€” the offset and size of the file section holding the attributes. that's where the attr crew lives ๐ŸŽ€
  • data โ€” the offset and size of the file section holding regular event data. the actual main event data, literally ๐ŸŒˆ
  • event_types โ€” ignored. yeah. she's just there. not me pointing at her ๐Ÿ’€ (the manpage said ignored, so bestie, we ignore her ๐Ÿ™ˆ)
  • adds_features โ€” a bitmap of features. important detail: the features are immediately after the data section. don't go hunting elsewhere, they're right there ๐Ÿ•ต๏ธโ€โ™€๏ธโญ

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • Kernel file ./tools/perf/util/header.h โ€” go read the source, iykyk ๐Ÿ“–๐Ÿ’œ

and that's the whole page, bestie!! ๐ŸŽ‰ no notes. now go forth and parse some headers, you absolute icon ๐ŸŒŸ

with love from the Kernel API Manual, struct perf_file_header(9), brought to you by ./tools/perf/util ๐Ÿซถ โ€” dropped October 2026, mark your calendars ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from