Linux-Fsdevel Archive on
 help / color / Atom feed
From: Roman Penyaev <>
To: unlisted-recipients:; (no To-header on input)
Cc: Roman Penyaev <>,
	Davidlohr Bueso <>, Jason Baron <>,
	Al Viro <>,
	Andrew Morton <>,
	Linus Torvalds <>,,
Subject: [PATCH v2 3/4] epoll: unify awaking of wakeup source on ep_poll_callback() path
Date: Thu,  3 Jan 2019 16:01:03 +0100
Message-ID: <> (raw)
In-Reply-To: <>

Original comment "Activate ep->ws since epi->ws may get deactivated
at any time" indeed sounds loud, but it is incorrect, because the path
where we check epi->ws is a path where insert to ovflist happens, i.e.
ep_scan_ready_list() has taken ep->mtx and waits for this callback
to finish, thus ep_modify() (which unregisters wakeup source) waits
for ep_scan_ready_list().

Here in this patch I simply call ep_pm_stay_awake_rcu(), which is
a bit extra for this path (indirectly protected by main ep->mtx, so
even rcu is not needed), but I do not want to create another naked
__ep_pm_stay_awake() variant only for this particular case, so rcu
variant is just better for all the cases.

Signed-off-by: Roman Penyaev <>
Cc: Davidlohr Bueso <>
Cc: Jason Baron <>
Cc: Al Viro <>
Cc: Andrew Morton <>
Cc: Linus Torvalds <>
 fs/eventpoll.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 3c373a510f65..0122b9147542 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1167,14 +1167,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
 		if (epi->next == EP_UNACTIVE_PTR) {
 			epi->next = READ_ONCE(ep->ovflist);
 			WRITE_ONCE(ep->ovflist, epi);
-			if (epi->ws) {
-				/*
-				 * Activate ep->ws since epi->ws may get
-				 * deactivated at any time.
-				 */
-				__pm_stay_awake(ep->ws);
-			}
+			ep_pm_stay_awake_rcu(epi);
 		goto out_unlock;

  parent reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03 15:01 [PATCH v2 0/4] use rwlock in order to reduce ep_poll_callback() contention Roman Penyaev
2019-01-03 15:01 ` [PATCH v2 1/4] epoll: make sure all elements in ready list are in FIFO order Roman Penyaev
2019-01-03 15:01 ` [PATCH v2 2/4] epoll: loosen irq safety in ep_poll_callback() Roman Penyaev
2019-01-03 15:01 ` Roman Penyaev [this message]
2019-01-03 15:01 ` [PATCH v2 4/4] epoll: use rwlock in order to reduce ep_poll_callback() contention Roman Penyaev

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Fsdevel Archive on

Archives are clonable:
	git clone --mirror linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ \
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone