aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2009-01-06 17:40:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:12 -0500
commit5f820f648c92a5ecc771a96b3c29aa6e90013bba (patch)
tree0445b45fa33072d37b32c6ef592a4d0c102e05cc /include
parent67ec7d3ab779ad9001ef57a6b4cfdf80ac9f9acc (diff)
poll: allow f_op->poll to sleep
f_op->poll is the only vfs operation which is not allowed to sleep. It's because poll and select implementation used task state to synchronize against wake ups, which doesn't have to be the case anymore as wait/wake interface can now use custom wake up functions. The non-sleep restriction can be a bit tricky because ->poll is not called from an atomic context and the result of accidentally sleeping in ->poll only shows up as temporary busy looping when the timing is right or rather wrong. This patch converts poll/select to use custom wake up function and use separate triggered variable to synchronize against wake up events. The only added overhead is an extra function call during wake up and negligible. This patch removes the one non-sleep exception from vfs locking rules and is beneficial to userland filesystem implementations like FUSE, 9p or peculiar fs like spufs as it's very difficult for those to implement non-sleeping poll method. While at it, make the following cosmetic changes to make poll.h and select.c checkpatch friendly. * s/type * symbol/type *symbol/ : three places in poll.h * remove blank line before EXPORT_SYMBOL() : two places in select.c Oleg: spotted missing barrier in poll_schedule_timeout() Davide: spotted missing write barrier in pollwake() Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Ingo Molnar <mingo@elte.hu> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Davide Libenzi <davidel@xmailserver.org> Cc: Brad Boyer <flar@allandria.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Roland McGrath <roland@redhat.com> Cc: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Davide Libenzi <davidel@xmailserver.org> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/poll.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/linux/poll.h b/include/linux/poll.h
index badd98ab06f6..8c24ef8d9976 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -46,9 +46,9 @@ static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
46} 46}
47 47
48struct poll_table_entry { 48struct poll_table_entry {
49 struct file * filp; 49 struct file *filp;
50 wait_queue_t wait; 50 wait_queue_t wait;
51 wait_queue_head_t * wait_address; 51 wait_queue_head_t *wait_address;
52}; 52};
53 53
54/* 54/*
@@ -56,7 +56,9 @@ struct poll_table_entry {
56 */ 56 */
57struct poll_wqueues { 57struct poll_wqueues {
58 poll_table pt; 58 poll_table pt;
59 struct poll_table_page * table; 59 struct poll_table_page *table;
60 struct task_struct *polling_task;
61 int triggered;
60 int error; 62 int error;
61 int inline_index; 63 int inline_index;
62 struct poll_table_entry inline_entries[N_INLINE_POLL_ENTRIES]; 64 struct poll_table_entry inline_entries[N_INLINE_POLL_ENTRIES];
@@ -64,6 +66,13 @@ struct poll_wqueues {
64 66
65extern void poll_initwait(struct poll_wqueues *pwq); 67extern void poll_initwait(struct poll_wqueues *pwq);
66extern void poll_freewait(struct poll_wqueues *pwq); 68extern void poll_freewait(struct poll_wqueues *pwq);
69extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
70 ktime_t *expires, unsigned long slack);
71
72static inline int poll_schedule(struct poll_wqueues *pwq, int state)
73{
74 return poll_schedule_timeout(pwq, state, NULL, 0);
75}
67 76
68/* 77/*
69 * Scaleable version of the fd_set. 78 * Scaleable version of the fd_set.