Skip to content

Commit

Permalink
epoll: Add synchronous wakeup support for ep_poll_callback
Browse files Browse the repository at this point in the history
commit 900bbaa 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]>
  • Loading branch information
Xuewen Yan authored and gregkh committed Dec 27, 2024
1 parent b3ab125 commit d9831a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,10 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
break;
}
}
wake_up(&ep->wq);
if (sync)
wake_up_sync(&ep->wq);
else
wake_up(&ep->wq);
}
if (waitqueue_active(&ep->poll_wait))
pwake++;
Expand Down
1 change: 1 addition & 0 deletions include/linux/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ void __wake_up_pollfree(struct wait_queue_head *wq_head);
#define wake_up_all(x) __wake_up(x, TASK_NORMAL, 0, NULL)
#define wake_up_locked(x) __wake_up_locked((x), TASK_NORMAL, 1)
#define wake_up_all_locked(x) __wake_up_locked((x), TASK_NORMAL, 0)
#define wake_up_sync(x) __wake_up_sync(x, TASK_NORMAL)

#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
Expand Down

0 comments on commit d9831a6

Please sign in to comment.