mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, Eric Wong <normalperson@yhbt.net>,
	Davide Libenzi <davidel@xmailserver.org>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 1/2] epoll: hoist out duplicated wake up logic
Date: Mon,  4 Mar 2013 03:06:07 +0000	[thread overview]
Message-ID: <1362366368-15246-1-git-send-email-normalperson@yhbt.net> (raw)
In-Reply-To: <20130304030500.GA29365@dcvr.yhbt.net>

This makes the kernel slightly smaller, and hopefully easier to follow.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 fs/eventpoll.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 5a1a596..6a70b7d 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -536,6 +536,13 @@ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
 	}
 }
 
+static int __must_check ep_wake_up_locked(struct eventpoll *ep)
+{
+	if (waitqueue_active(&ep->wq))
+		wake_up_locked(&ep->wq);
+	return waitqueue_active(&ep->poll_wait);
+}
+
 /**
  * ep_scan_ready_list - Scans the ready list in a way that makes possible for
  *                      the scan code, to call f_op->poll(). Also allows for
@@ -620,10 +627,7 @@ static int ep_scan_ready_list(struct eventpoll *ep,
 		 * Wake up (if active) both the eventpoll wait list and
 		 * the ->poll() wait list (delayed after we release the lock).
 		 */
-		if (waitqueue_active(&ep->wq))
-			wake_up_locked(&ep->wq);
-		if (waitqueue_active(&ep->poll_wait))
-			pwake++;
+		pwake = ep_wake_up_locked(ep);
 	}
 	spin_unlock_irqrestore(&ep->lock, flags);
 
@@ -991,10 +995,7 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
 	 * Wake up ( if active ) both the eventpoll wait list and the ->poll()
 	 * wait list.
 	 */
-	if (waitqueue_active(&ep->wq))
-		wake_up_locked(&ep->wq);
-	if (waitqueue_active(&ep->poll_wait))
-		pwake++;
+	pwake = ep_wake_up_locked(ep);
 
 out_unlock:
 	spin_unlock_irqrestore(&ep->lock, flags);
@@ -1250,10 +1251,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
 		__pm_stay_awake(epi->ws);
 
 		/* Notify waiting tasks that events are available */
-		if (waitqueue_active(&ep->wq))
-			wake_up_locked(&ep->wq);
-		if (waitqueue_active(&ep->poll_wait))
-			pwake++;
+		pwake = ep_wake_up_locked(ep);
 	}
 
 	spin_unlock_irqrestore(&ep->lock, flags);
@@ -1360,10 +1358,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
 			__pm_stay_awake(epi->ws);
 
 			/* Notify waiting tasks that events are available */
-			if (waitqueue_active(&ep->wq))
-				wake_up_locked(&ep->wq);
-			if (waitqueue_active(&ep->poll_wait))
-				pwake++;
+			pwake = ep_wake_up_locked(ep);
 		}
 		spin_unlock_irq(&ep->lock);
 	}
-- 
1.8.1.2.526.gf51a757


  reply	other threads:[~2013-03-04  3:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-02  7:25 [PATCH] epoll: preserve ordering of events from ovflist Eric Wong
2013-03-04  3:05 ` Eric Wong
2013-03-04  3:06   ` Eric Wong [this message]
2013-03-04  3:06     ` [PATCH 2/2] epoll: add tracepoints for epitem enqueue/dequeue Eric Wong
2013-03-08  1:32       ` Eric Wong

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=1362366368-15246-1-git-send-email-normalperson@yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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®