Skip to content

Commit 900bbaa

Browse files
Xuewen Yanbrauner
authored andcommitted
epoll: Add synchronous wakeup support for ep_poll_callback
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]>
1 parent 0dfcb72 commit 900bbaa

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
@@ -1373,7 +1373,10 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
13731373
break;
13741374
}
13751375
}
1376-
wake_up(&ep->wq);
1376+
if (sync)
1377+
wake_up_sync(&ep->wq);
1378+
else
1379+
wake_up(&ep->wq);
13771380
}
13781381
if (waitqueue_active(&ep->poll_wait))
13791382
pwake++;

include/linux/wait.h

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

225226
#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
226227
#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)

0 commit comments

Comments
 (0)