STRUCT PIPE_INODE_INFO(9)
π struct pipe_inode_info(9) π
okay so bestie, welcome to the Kernel API Manual β this one's all about struct pipe_inode_info, which is, like, the data structure behind every pipe in the linux kernel. yes THAT pipe, the one you've been piping ls into grep with since forever. she's the main character fr fr π
β¨ NAME β¨
struct pipe_inode_info β a linux kernel pipe π
π¦ SYNOPSIS π¦
struct pipe_inode_info {
struct mutex mutex;
wait_queue_head_t rd_wait, wr_wait;
union pipe_index;
unsigned int max_usage;
unsigned int ring_size;
unsigned int nr_accounted;
unsigned int readers;
unsigned int writers;
unsigned int files;
unsigned int r_counter;
unsigned int w_counter;
bool pseudo_edgetrigger;
#ifdef CONFIG_WATCH_QUEUE;
bool note_loss;
#endif;
struct anon_pipe_prealloc prealloc;
struct fasync_struct *fasync_readers;
struct fasync_struct *fasync_writers;
struct pipe_buffer *bufs;
struct user_struct *user;
#ifdef CONFIG_WATCH_QUEUE;
struct watch_queue *watch_queue;
#endif;
};
like, just look at her. iconic. no notes. π
πΈ Members πΈ
time for the member-by-member vibe check, one at a time, no skipping, we're doing ALL of them π«Ά
mutexβ the mutex protecting the whole thing. yes, the whole thing. she's the bouncer at the door of this entire struct, respectfully πrd_waitβ the reader wait point, for when the pipe is empty. reader besties hang out here when there's literally nothing to read πwr_waitβ the writer wait point, for when the pipe is full. writer besties queue up here when there's no room left to write πpipe_indexβ the pipe indeces β¨ (yes, that's the spelling, we keep it, we don't fix it)max_usageβ The maximum number of slots that may be used in the ring. like a capacity limit but make it ring-buffer core πring_sizeβ total number of buffers (should be a power of 2). should be. the kernel is trusting you on this one, no cap π«Άnr_accountedβ The amount this pipe accounts for inuser->pipe_bufs. keeping the receipts, ngl π§Ύreadersβ number of current readers of this pipe πwritersβ number of current writers of this pipe πfilesβ number ofstruct filereferring this pipe (protected by->i_lock). note the lock, bestie, that detail matters π₯r_counterβ reader counterw_counterβ writer counterpseudo_edgetriggerβ has anEPOLLETconsumer, enable per-write wakeups. so basically sarahah but for wakeups β¨note_lossβ The next read should insert a data-lost message. lowkey ominous of her but okay π (this one only exists#ifdef CONFIG_WATCH_QUEUE;)preallocβ per-pipe page preallocation pool. she pre-games. she prepares. we love a planner πfasync_readersβ reader side fasyncfasync_writersβ writer side fasyncbufsβ the circular array of pipe buffers. circular!! she goes around!! πuserβ the user who created this pipe. credit where credit is due πwatch_queueβ If this pipe is a watch_queue, this is the stuff for that. very "iykyk" of her π (again, only#ifdef CONFIG_WATCH_QUEUE;)
β SEE ALSO β
Kernel file ./include/linux/pipe_fs_i.h β and the whole friend group, go say hi:
struct pipe_buffer(9)union pipe_index(9)struct anon_pipe_prealloc(9)pipe_has_watch_queue(9)pipe_occupancy(9)pipe_empty(9)pipe_full(9)pipe_is_full(9)pipe_is_empty(9)pipe_buf_usage(9)pipe_buf(9)pipe_head_buf(9)pipe_buf_get(9)pipe_buf_release(9)pipe_buf_confirm(9)pipe_buf_try_steal(9)
ok that's the whole page, you ate that honestly. go forth and pipe things π«Ά
mwah π this page lives in ./include/linux, dated October 2026, and yes the footer says struct pipe_inode_info(9) β that's her name, don't wear it out πΈβ¨
π¦ 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