linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC,PATCH] poll cleanups 1/3
@ 2002-11-10 11:25 Manfred Spraul
  2002-11-10 19:20 ` Davide Libenzi
  0 siblings, 1 reply; 2+ messages in thread
From: Manfred Spraul @ 2002-11-10 11:25 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, Davide Libenzi

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

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

[-- Attachment #2: patch-poll-1-NULL --]
[-- Type: text/plain, Size: 3423 bytes --]

// $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;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-10 19:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-10 11:25 [RFC,PATCH] poll cleanups 1/3 Manfred Spraul
2002-11-10 19:20 ` Davide Libenzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).