STRUCT ANNOTATED_BRANCH(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

struct annotated_branch β€” the whole entire lowdown on basic blocks and IPC info for a symbol, bestie πŸ’…

okay so real quick before we dive in: this is a Kernel API Manual page (yes, the (9) girlies, section 9, kernel API) and honestly? she's giving main character energy. let's get into it 🫢


🌸 SYNOPSIS 🌸

struct annotated_branch {
    u64 hit_cycles;
    u64 hit_insn;
    unsigned int            total_insn;
    unsigned int            cover_insn;
    struct cyc_hist         *cycles_hist;
    u64 max_coverage;
    u64 *br_cntr;
 };

no cap, that's the whole shape of her. now let's meet the members one by one πŸŽ€


πŸ’… Members πŸ’…

  • hit_cycles β€” total executed cycles. literally the cycle count, periodt. πŸ”₯
  • hit_insn β€” total number of instructions executed. the way she just counts insns for you, obsessed.
  • total_insn β€” number of instructions in the function. (unsigned int, so she's got limits, iykyk)
  • cover_insn β€” number of distinct instructions that were actually executed. distinct!! not just any old repeat, okay? πŸ™ˆ
  • cycles_hist β€” struct cyc_hist *, an array of cyc_hist for each instruction. one per instruction bestie, a whole little lineup 🧚
  • max_coverage β€” maximum number of covered basic block (used for block-range). she's a u64 and she's holding the ceiling for you πŸ‘‘
  • br_cntr β€” u64 *, array of the occurrences of events (branch counters) during a block. counting branches like it's her job, because it is πŸ’€

πŸ¦‹ Description πŸ¦‹

so this struct is used by two different codes when the sample has branch stack and cycles information. two codes, one struct, we love a shared-usage moment 🫢

Here's the tea on who does what:

  • annotation__compute_ipc calculates average IPC using hit_insn / hit_cycles. math! slay! ⭐
  • The actual coverage can be calculated using cover_insn / total_insn. another ratio, another vibe check.
  • The cycles_hist can give IPC for each (longest) basic block ends at the given address. yes, longest β€” that's the qualifier, don't come for me.
  • process_basic_block calculates coverage of instructions (or basic blocks) in the function.

and that's it, that's the whole description, no extra lore, no invented features, we stay factual in this group chat πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./tools/perf/util/annotate.h plus the whole friend group:

  • struct sym_hist(9)
  • struct cyc_hist(9)
  • struct annotated_source(9)
  • struct annotated_op_loc(9)
  • struct annotated_insn_loc(9)
  • struct annotated_basic_block(9)

go read them, they're literally iconic, fr fr 🌈


ngl the manual name is struct annotated_branch(9) from Kernel API Manual β€” and this page lives in ./tools/perf/util, October 2026 edition. that's the footer, folded into a sign-off because we're cute like that. byeeee βœ¨πŸŽ€πŸ’–
πŸ“¦ where this page comes from