ARRAY_ELEM_PTR(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ARRAY_ELEM_PTR πŸ’…

okay so bestie, welcome to the Kernel API Manual, section 9 β€” this one's called ARRAY_ELEM_PTR and honestly? it's giving "quietly iconic helper macro" energy. it's the glow-up version of pointer-verifying that actually knows how big your array really is. let's get into it πŸŽ€


✨ NAME ✨

ARRAY_ELEM_PTR β€” Obtain the verified pointer to an array element 🫢

like fr, it hands you back a pointer that's been verified, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

ARRAY_ELEM_PTR (arr , i , n );

that's the whole vibe. three args, one macro, zero drama ✨


🌸 ARGUMENTS 🌸

  • arr β€” the array you're indexing into. your main character array, if you will πŸ‘‘
  • i β€” the array index. which element are we sliding into πŸ’…
  • n β€” the number of elements in the array. explicit. on purpose. we'll get to why 😌

πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• β€” it's Similar to MEMBER_VPTR but it's intended for use with arrays where the element count needs to be explicit.

why does that matter, you ask? πŸ₯Ί because it can be used in cases where a global array is defined with an initial size but is intended to be be resized before loading the BPF program. and here's the part where it gets messy, bestie β€” Without this version of the macro, MEMBER_VPTR will use the compile time size of the array to compute the max, which will result in rejection by the verifier πŸ’€πŸ’€πŸ’€

literally the verifier said "no ❀️" because the compile-time size wasn't the truth. so we pass n in ourselves and everyone stays unbothered. slay 🧚

πŸ”₯ SEE ALSO πŸ”₯

hiii go read these next, they're all besties:


🌈 mwah, that's the whole page! this iconic lil manual page lives at ./tools/sched_ext/include/scx and it's dated October 2026 β€” so yes, it's from the future, and it ate πŸ’…βœ¨ πŸŽ€

πŸ“¦ where this page comes from