Skip to content

Commit 400a2ae

Browse files
Xuewen Yangregkh
authored andcommitted
epoll: Add synchronous wakeup support for ep_poll_callback
commit 900bbaae67e980945dec74d36f8afe0de7556d5a upstream. Now, the epoll only use wake_up() interface to wake up task. However, sometimes, there are epoll users which want to use the synchronous wakeup flag to hint the scheduler, such as Android binder driver. So add a wake_up_sync() define, and use the wake_up_sync() when the sync is true in ep_poll_callback(). Co-developed-by: Jing Xia <[email protected]> Signed-off-by: Jing Xia <[email protected]> Signed-off-by: Xuewen Yan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Brian Geffon <[email protected]> Reviewed-by: Brian Geffon <[email protected]> Reported-by: Benoit Lize <[email protected]> Signed-off-by: Christian Brauner <[email protected]> Cc: Brian Geffon <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6c45048 commit 400a2ae

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fs/eventpoll.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,10 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
12371237
break;
12381238
}
12391239
}
1240-
wake_up(&ep->wq);
1240+
if (sync)
1241+
wake_up_sync(&ep->wq);
1242+
else
1243+
wake_up(&ep->wq);
12411244
}
12421245
if (waitqueue_active(&ep->poll_wait))
12431246
pwake++;

include/linux/wait.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ void __wake_up_pollfree(struct wait_queue_head *wq_head);
224224
#define wake_up_all(x) __wake_up(x, TASK_NORMAL, 0, NULL)
225225
#define wake_up_locked(x) __wake_up_locked((x), TASK_NORMAL, 1)
226226
#define wake_up_all_locked(x) __wake_up_locked((x), TASK_NORMAL, 0)
227+
#define wake_up_sync(x) __wake_up_sync(x, TASK_NORMAL)
227228

228229
#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
229230
#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)

0 commit comments

Comments
 (0)