ENUM RING_BUFFER_TYPE(9)
π¦ enum ring_buffer_type(9) π¦
okay so this is straight out of the Kernel API Manual, and it's genuinely one of those pages where the struct is tiny but the lore is deep. bestie, we're talking about the internal ring buffer types β the secret little type tags that live inside the kernel's ring buffer. let's get into it π
β¨ NAME β¨
enum ring_buffer_type β the internal ring buffer types, no cap π
πΈ SYNOPSIS πΈ
enum ring_buffer_type {
RINGBUF_TYPE_DATA_TYPE_LEN_MAX ,
RINGBUF_TYPE_PADDING ,
RINGBUF_TYPE_TIME_EXTEND ,
RINGBUF_TYPE_TIME_STAMP
};
that's the whole enum, icon behavior only β¨
π Constants π
RINGBUF_TYPE_DATA_TYPE_LEN_MAXβ okay so the source literally says-- undescribed --π like not me being left on read by the documentation. that's all we get, fr fr.RINGBUF_TYPE_PADDINGβ this one is for left over page padding or a discarded event π«Ά and it's giving conditional, so pay attention:- If
time_deltais0: the array is ignored, and the size is variable depending on how much padding is needed. - If
time_deltais non zero:array[0]holds the actual length, and size =4 + length(bytes).
- If
RINGBUF_TYPE_TIME_EXTENDβ used to extend the time delta π specificallyarray[0] = time delta (28 .. 59), and size =8 bytes. cute, compact, slays.RINGBUF_TYPE_TIME_STAMPβ absolute timestamp β same format asTIME_EXTENDexcept that the value is an absolute timestamp, not a delta. okay so details:event.time_deltacontains bottom 27 bits,array[0] = top (28 .. 59) bits, and size =8 bytes. the way that this one is doing the most with 8 bytes, obsessed π₯
π Description π
okay so the big picture: <= RINGBUF_TYPE_DATA_TYPE_LEN_MAX means it's a Data record π« and then it splits into two paths, so listen up:
- If
type_lenis zero:array[0]holds the actual lengtharray[1..(length+3)/4]holds data- size =
4 + length(bytes)
- else:
- length =
type_len << 2 array[0..(length+3)/4-1]holds data- size =
4 + length(bytes)
- length =
like, it's literally just bit math and array offsets, but it's our bit math and array offsets π main character energy for real.
lowkey important: thoselengthexpressions are exact β don't go rounding or "fixing" them, the kernel is doing(length+3)/4on purpose and it's not here for your vibes-based math π
π SEE ALSO π
- Kernel file
./include/linux/ring_buffer.hβ go read it, iykyk π
and that's the page!! π huge thanks to the source at ./include/linux, dated October 2026, for giving us this iconic little enum in the Kernel API Manual β go forth and read your ring buffer types responsibly, bestie πβ¨π¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms