poll: avoid extra wakeups in select/poll
[sfrench/cifs-2.6.git] / include / linux / poll.h
index badd98ab06f662a43cf5fc3285aa80ac42c1d849..fa287f25138dc2a243e27825f92d670b210a4b6b 100644 (file)
@@ -32,6 +32,7 @@ typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_
 
 typedef struct poll_table_struct {
        poll_queue_proc qproc;
+       unsigned long key;
 } poll_table;
 
 static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
@@ -43,12 +44,14 @@ static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_addres
 static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
 {
        pt->qproc = qproc;
+       pt->key   = ~0UL; /* all events enabled */
 }
 
 struct poll_table_entry {
-       struct file * filp;
+       struct file *filp;
+       unsigned long key;
        wait_queue_t wait;
-       wait_queue_head_t * wait_address;
+       wait_queue_head_t *wait_address;
 };
 
 /*
@@ -56,7 +59,9 @@ struct poll_table_entry {
  */
 struct poll_wqueues {
        poll_table pt;
-       struct poll_table_page * table;
+       struct poll_table_page *table;
+       struct task_struct *polling_task;
+       int triggered;
        int error;
        int inline_index;
        struct poll_table_entry inline_entries[N_INLINE_POLL_ENTRIES];
@@ -64,6 +69,13 @@ struct poll_wqueues {
 
 extern void poll_initwait(struct poll_wqueues *pwq);
 extern void poll_freewait(struct poll_wqueues *pwq);
+extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
+                                ktime_t *expires, unsigned long slack);
+
+static inline int poll_schedule(struct poll_wqueues *pwq, int state)
+{
+       return poll_schedule_timeout(pwq, state, NULL, 0);
+}
 
 /*
  * Scaleable version of the fd_set.