[RFC,PATCH] poll cleanups 1/3

Manfred Spraul (manfred@colorfullife.com)
Sun, 10 Nov 2002 12:25:19 +0100


This is a multi-part message in MIME format.
--------------050905010103040001020202
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Change 1:
Davide added a 'queue' variable into the poll_table, to indicate that no
wait queue operations should happen.
This is not needed: setting the poll table to NULL achieves the same
effect, and is used by select/poll to implement syscalls with a 0 timeout.

Patch vs 2.5.46, untested.

--
    Manfred

--------------050905010103040001020202 Content-Type: text/plain; name="patch-poll-1-NULL" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-poll-1-NULL"

// $Header$ // Kernel Version: // VERSION = 2 // PATCHLEVEL = 5 // SUBLEVEL = 46 // EXTRAVERSION = --- 2.5/include/linux/poll.h 2002-11-10 11:54:59.000000000 +0100 +++ build-2.5/include/linux/poll.h 2002-11-10 11:57:39.000000000 +0100 @@ -13,7 +13,6 @@ struct poll_table_page; typedef struct poll_table_struct { - int queue; void *priv; void (*qproc)(void *, wait_queue_head_t *); int error; @@ -30,18 +29,16 @@ static inline void poll_initwait(poll_table* pt) { - pt->queue = 1; pt->qproc = NULL; pt->priv = NULL; pt->error = 0; pt->table = NULL; } -static inline void poll_initwait_ex(poll_table* pt, int queue, +static inline void poll_initwait_ex(poll_table* pt, void (*qproc)(void *, wait_queue_head_t *), void *priv) { - pt->queue = queue; pt->qproc = qproc; pt->priv = priv; pt->error = 0; --- 2.5/fs/select.c 2002-11-10 11:54:59.000000000 +0100 +++ build-2.5/fs/select.c 2002-11-10 11:58:24.000000000 +0100 @@ -77,9 +77,6 @@ { struct poll_table_page *table = p->table; - if (!p->queue) - return; - if (p->qproc) { p->qproc(p->priv, wait_address); return; --- 2.5/fs/eventpoll.c 2002-11-10 11:54:59.000000000 +0100 +++ build-2.5/fs/eventpoll.c 2002-11-10 11:57:17.000000000 +0100 @@ -828,7 +828,7 @@ } /* Attach the item to the poll hooks */ - poll_initwait_ex(&pt, 1, ep_ptable_queue_proc, dpi); + poll_initwait_ex(&pt, ep_ptable_queue_proc, dpi); revents = tfile->f_op->poll(tfile, &pt); poll_freewait(&pt); @@ -854,25 +854,14 @@ /* - * Returns the current events of the given file. It uses the special - * poll table initialization to avoid any poll queue insertion. + * Returns the current events of the given file. */ static unsigned int ep_get_file_events(struct file *file) { unsigned int revents; - poll_table pt; - /* - * This is a special poll table initialization that will - * make poll_wait() to not perform any wait queue insertion when - * called by file->f_op->poll(). This is a fast way to retrieve - * file events with perform any queue insertion, hence saving CPU cycles. - */ - poll_initwait_ex(&pt, 0, NULL, NULL); - - revents = file->f_op->poll(file, &pt); + revents = file->f_op->poll(file, NULL); - poll_freewait(&pt); return revents; } @@ -1056,15 +1045,6 @@ unsigned long flags; struct list_head *lsthead = &ep->rdllist; struct pollfd eventbuf[EP_EVENT_BUFF_SIZE]; - poll_table pt; - - /* - * This is a special poll table initialization that will - * make poll_wait() to not perform any wait queue insertion when - * called by file->f_op->poll(). This is a fast way to retrieve - * file events with perform any queue insertion, hence saving CPU cycles. - */ - poll_initwait_ex(&pt, 0, NULL, NULL); write_lock_irqsave(&ep->lock, flags); @@ -1075,7 +1055,7 @@ EP_LIST_DEL(&dpi->rdllink); /* Fetch event bits from the signaled file */ - revents = dpi->file->f_op->poll(dpi->file, &pt); + revents = dpi->file->f_op->poll(dpi->file, NULL); if (revents & dpi->pfd.events) { eventbuf[ebufcnt] = dpi->pfd; @@ -1091,7 +1071,6 @@ write_unlock_irqrestore(&ep->lock, flags); if (__copy_to_user(&events[eventcnt], eventbuf, ebufcnt * sizeof(struct pollfd))) { - poll_freewait(&pt); return -EFAULT; } eventcnt += ebufcnt; @@ -1111,8 +1090,6 @@ eventcnt += ebufcnt; } - poll_freewait(&pt); - return eventcnt; }

--------------050905010103040001020202--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/