Major cleanup, moving things around, documenting, etc
RFC PATCH 17/21 Major cleanup, moving things around, documenting, etc
--- include/linux/relay.h | 52 +-- include/linux/relay_pagewriter.h | 72 ++--- kernel/relay.c | 700 +++++++++++++++++++------------------- kernel/relay_pagewriter.c | 513 ++++++++++++++++------------ 4 files changed, 698 insertions(+), 639 deletions(-)
include/linux/relay.h +19 -33
@@ -26,8 +26,10 @@*/ #define RCHAN_GLOBAL_BUFFER 0x00000001/* not using per-cpu */ -struct relay_page -{ +/* +* For page lists +*/ +struct relay_page {struct page *page;struct list_head list;struct relay_page_callbacks *cb;
@@ -37,17 +39,16 @@ struct relay_page/* * Per-cpu relay channel buffer */ -struct rchan_buf -{ +struct rchan_buf {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 */ +size_t nr_pages;/* number of unconsumed pages */ spinlock_t lock;/* protect pages list */ size_t consumed_offset;/* bytes consumed in cur page */ -size_t nr_pages;/* number of unconsumed pages */ unsigned int finalized;/* buffer has been finalized */ unsigned int cpu;/* this buf's cpu */ }____cacheline_aligned ;
@@ -115,40 +116,25 @@ struct rchan_callbacksstruct relay_page_callbacks {/* -* page_released - called on switch to a new page -* @buf: the channel buffer containing the new page -* @page_data: the start of the new page +* page_released - notification that a page is ready for re-use +* @page: the released page +* @private_data: user-defined data associated with the page * -* This is simply a notification that a new page has been -* switched to. The default version does nothing but call -* relay_wakeup_readers(). Clients who override this callback -* should also call relay_wakeup_readers() to get that default -* behavior in addition to whatever they add. Clients who -* don't want to wake up readers should just not call it. -* Clients can use the channel private_data to track previous -* pages, determine whether this is the first page, etc. -* -* NOTE: the client can reserve bytes at the beginning of the new -* page by calling page_start_reserve() in this callback. +* This callback is a notification that a given page has been +* read by userspace and can be re-used. Always called in +* user context. */ void (*page_released) (struct page *page,void *private_data);/* -* page_stolen - called on switch to a new page -* @buf: the channel buffer containing the new page -* @page_data: the start of the new page -* -* This is simply a notification that a new page has been -* switched to. The default version does nothing but call -* relay_wakeup_readers(). Clients who override this callback -* should also call relay_wakeup_readers() to get that default -* behavior in addition to whatever they add. Clients who -* don't want to wake up readers should just not call it. -* Clients can use the channel private_data to track previous -* pages, determine whether this is the first page, etc. +* page_released - notification that a page has been stolen +* @page: the stolen page +* @private_data: user-defined data associated with the page * -* NOTE: the client can reserve bytes at the beginning of the new -* page by calling page_start_reserve() in this callback. +* This callback is a notification that a given page has been +* stolen by userspace. The owner may wish to replace it; +* this gives it the opportunity to do so. Always called in +* user context. */ void (*page_stolen) (struct page *page,void *private_data); };
include/linux/relay_pagewriter.h +33 -39
175 lines not on this page · raw message
kernel/relay.c +354 -346
873 lines not on this page · raw message
kernel/relay_pagewriter.c +292 -221
632 lines not on this page · raw message
Signature · 1 line
1.5.3.5