Make relay buffers variable-length.
RFC PATCH 13/21 Make relay buffers variable-length.
Make everything use variable-length relay buffers and remove everything that this change makes obsolete, including mmap.
--- include/linux/relay.h | 69 +++------- kernel/relay.c | 385 +++++++++++++------------------------------------ 2 files changed, 121 insertions(+), 333 deletions(-)
include/linux/relay.h +17 -52
@@ -27,8 +27,7 @@/* * relay channel flags */ -#define RCHAN_MODE_OVERWRITE 0x00000001/* 'flight' mode */ -#define RCHAN_GLOBAL_BUFFER 0x00000002/* not using per-cpu */ +#define RCHAN_GLOBAL_BUFFER 0x00000001/* not using per-cpu */ struct relay_page {
@@ -44,16 +43,15 @@ struct rchan_bufvoid *data;/* address of current page */ struct relay_page *page;/* current write page */ size_t offset;/* current offset into page */ -size_t consumed_offset;/* bytes consumed in cur page */ -size_t produced;/* count of pages produced */ -size_t consumed;/* count of pages consumed */ struct rchan *chan;/* associated channel */ wait_queue_head_t read_wait;/* reader wait queue */ struct timer_list timer;/* reader wake-up timer */ struct dentry *dentry;/* channel file dentry */ struct kref kref;/* channel buffer refcount */ struct list_head pages;/* current set of unconsumed pages */ -unsigned int page_count;/* number of current buffer pages */ +size_t consumed_offset;/* bytes consumed in cur page */ +size_t nr_pages;/* number of unconsumed pages */ +struct list_head pool;/* current set of unused pages */ unsigned int finalized;/* buffer has been finalized */ size_t early_bytes;/* bytes consumed before VFS inited */ unsigned int cpu;/* this buf's cpu */
@@ -67,7 +65,6 @@ struct rchanu32 version;/* the version of this struct */ size_t n_pages;/* number of pages per buffer */ size_t n_pages_wakeup;/* wake up readers after filling n */ -size_t alloc_size;/* total buffer size allocated */ struct rchan_callbacks *cb;/* client callbacks */ struct kref kref;/* channel refcount */ void *private_data;/* for user-defined data */
@@ -107,25 +104,6 @@ struct rchan_callbacks void *page_data);/* -* buf_mapped - relay buffer mmap notification -* @buf: the channel buffer -* @filp: relay file pointer -* -* Called when a relay file is successfully mmapped -*/ -void (*buf_mapped)(struct rchan_buf *buf, -struct file *filp); - -/* -* buf_unmapped - relay buffer unmap notification -* @buf: the channel buffer -* @filp: relay file pointer -* -* Called when a relay file is successfully unmapped -*/ -void (*buf_unmapped)(struct rchan_buf *buf, -struct file *filp); -/* * create_buf_file - create file to represent a relay channel buffer * @filename: the name of the file to create * @parent: the parent of the file to create
@@ -184,23 +162,21 @@ struct rchan_callbacks* CONFIG_RELAY kernel API, kernel/relay.c */ -struct rchan *relay_open (const char *base_filename, -struct dentry *parent, -size_t n_pages, -size_t n_pages_wakeup, -struct rchan_callbacks *cb, -void *private_data, -unsigned long rchan_flags); -extern int relay_late_setup_files (struct rchan *chan, -const char *base_filename, -struct dentry *parent); +extern struct rchan *relay_open (const char *base_filename, +struct dentry *parent, +size_t n_pages, +size_t n_pages_wakeup, +struct rchan_callbacks *cb, +void *private_data, +unsigned long rchan_flags);extern void relay_close (struct rchan *chan);extern void relay_flush (struct rchan *chan); -extern void relay_pages_consumed (struct rchan *chan, -unsigned int cpu, -size_t consumed);extern void relay_reset (struct rchan *chan); -extern int relay_buf_full (struct rchan_buf *buf); +extern void relay_add_page (struct rchan_buf *buf,struct page *page); + +extern int relay_late_setup_files (struct rchan *chan, +const char *base_filename, +struct dentry *parent); extern size_t relay_switch_page_default_callback(struct rchan_buf *buf, size_t length,
@@ -221,7 +197,7 @@ static inline void relay_wakeup_readers(struct rchan_buf *buf) {size_t wakeup = buf->chan->n_pages_wakeup; -if (wakeup && (buf->produced % wakeup ==0 ) && +if (wakeup && (buf->nr_pages % wakeup ==0 ) && (waitqueue_active (&buf->read_wait)))/* * Calling wake_up_interruptible() from here
@@ -264,17 +240,6 @@ static inline void relay_update_filesize(struct rchan_buf *buf, size_t length) }/** -* relay_inc_produced - increase number of pages produced by 1 -* @buf: relay channel buffer -* -* switch_page() helper function. -*/ -static inline void relay_inc_produced (struct rchan_buf *buf) -{ - buf->produced++; -} - -/** * relay_write - write data into the channel * @chan: relay channel * @data: data to be written
kernel/relay.c +104 -281
632 lines not on this page · raw message
Signature · 1 line
1.5.3.5