register_ftrace_direct(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 register_ftrace_direct(9) β€” like, the kernel API manual, bestie 🌸

okay so real talk, this is a page straight out of the Kernel API Manual (register_ftrace_direct(9), section 9, kernel vibes only) and it's genuinely one of those "small function, huge consequences" situations. sit down, grab a lil drink πŸ“, and let's get into it.


✨ SYNOPSIS ✨

int register_ftrace_direct (struct ftrace_ops *ops , unsigned long addr
);

like yes that's the whole signature, she's cute, she's compact πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • ops β€” the address of the struct ftrace_ops object. that's your lil registry of which functions we're messing with 🫢
  • addr β€” the address of the trampoline that gets called at the ops functions. the destination of the jump, iykyk

πŸ¦‹ DESCRIPTION πŸ¦‹

so what this actually does: it hooks up direct calls to addr from the nop locations of the functions registered in ops β€” and those functions get registered via the ftrace_set_filter_ip function, no cap.

the way that this works is lowkey important though: the location it calls (addr) must be able to handle a direct call. not optional, not a suggestion, it's giving requirement ✨. and it has to save the parameters of the function being traced, and restore them (or inject new ones if needed 😳) before returning. that's the whole deal. miss that and it's a whole situation.


πŸ”₯ RETURN πŸ”₯

  • 0 β€” success, we ate πŸ’…
  • -EINVAL β€” the ops object was already registered with this call, or there are no functions in the ops object. either way, invalid, periodt.
  • -EBUSY β€” another direct function is already attached. and bestie, there can be only one. that's the rule.
  • -ENODEV β€” ip does not point to a ftrace nop location (or it's not supported). wrong address, wrong vibe 😭
  • -ENOMEM β€” there was an allocation failure. the memory said no πŸ™ˆ

πŸ’œ SEE ALSO πŸ’œ

okay this list is LONG and honestly iconic for it. first up, the source file:

  • Kernel file ./kernel/trace/ftrace.c

and then the whole friend group (all section 9, all linked):

like. forty-five entries. she's thorough and honestly? obsessed 🧚

ngl this whole page lives under ./kernel/trace, dated October 2026, and it's still signing off as register_ftrace_direct(9) at the bottom. main character energy from start to finish πŸ‘‘

and that's the page, bestie. go forth, register your direct calls responsibly, and remember: addr has to handle the call. no shortcuts, no vibes-based guessing 🌈⭐

πŸ“¦ where this page comes from