mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jay Vosburgh" <fubar@us.ibm.com>
To: davidel@xmailserver.org, Linus Torvalds <torvalds@transmeta.com>
Cc: "Janet Morgan" <janetinc@us.ibm.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] 2.5.46: epoll ep_insert doesn't wake waiters if events exist
Date: Thu, 7 Nov 2002 15:53:06 -0700	[thread overview]
Message-ID: <OF0E49851E.BBF9BCB0-ON88256C6A.007C9078@boulder.ibm.com> (raw)

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


      The logic in fs/eventpoll.c:ep_insert()  checks to see if events are
already present when processing an EP_CTL_ADD operation, and, if any are,
adds them to the list.  It does not wake up any waiters, so, e.g., another
thread waiting in epoll_wait() will not be awakened for these events.  The
fix is to have ep_insert() do wakeups, just as ep_poll_callback() does when
it adds events.

      -J

diff -ur linux-2.5.46.orig/fs/eventpoll.c linux-2.5.46/fs/eventpoll.c
--- linux-2.5.46.orig/fs/eventpoll.c      Thu Nov  7 14:31:21 2002
+++ linux-2.5.46/fs/eventpoll.c     Thu Nov  7 14:32:16 2002
@@ -838,8 +838,13 @@
      list_add(&dpi->llink, ep_hash_entry(ep, ep_hash_index(ep, tfile)));

      /* If the file is already "ready" we drop it inside the ready list */
-     if ((revents & pfd->events) && !EP_IS_LINKED(&dpi->rdllink))
+     if ((revents & pfd->events) && !EP_IS_LINKED(&dpi->rdllink)) {
            list_add(&dpi->rdllink, &ep->rdllist);
+           if (waitqueue_active(&ep->wq))
+                 wake_up(&ep->wq);
+           if (waitqueue_active(&ep->poll_wait))
+                 wake_up(&ep->poll_wait);
+     }

      write_unlock_irqrestore(&ep->lock, flags);



(See attached file: epoll-2.5.46-insert.patch)

[-- Attachment #2: epoll-2.5.46-insert.patch --]
[-- Type: application/octet-stream, Size: 703 bytes --]

diff -ur linux-2.5.46.orig/fs/eventpoll.c linux-2.5.46/fs/eventpoll.c
--- linux-2.5.46.orig/fs/eventpoll.c	Thu Nov  7 14:31:21 2002
+++ linux-2.5.46/fs/eventpoll.c	Thu Nov  7 14:32:16 2002
@@ -838,8 +838,13 @@
 	list_add(&dpi->llink, ep_hash_entry(ep, ep_hash_index(ep, tfile)));
 
 	/* If the file is already "ready" we drop it inside the ready list */
-	if ((revents & pfd->events) && !EP_IS_LINKED(&dpi->rdllink))
+	if ((revents & pfd->events) && !EP_IS_LINKED(&dpi->rdllink)) {
 		list_add(&dpi->rdllink, &ep->rdllist);
+		if (waitqueue_active(&ep->wq))
+			wake_up(&ep->wq);
+		if (waitqueue_active(&ep->poll_wait))
+			wake_up(&ep->poll_wait);
+	}
 
 	write_unlock_irqrestore(&ep->lock, flags);
 

             reply	other threads:[~2002-11-07 22:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-07 22:53 Jay Vosburgh [this message]
2002-11-07 23:24 ` Davide Libenzi
2002-11-08 15:49   ` Mark Hamblin
2002-11-08 17:43     ` Davide Libenzi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF0E49851E.BBF9BCB0-ON88256C6A.007C9078@boulder.ibm.com \
    --to=fubar@us.ibm.com \
    --cc=davidel@xmailserver.org \
    --cc=janetinc@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®