mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
poll: allow f_op->poll to sleep
f_op->poll is the only vfs operation which is not allowed to sleep. It's because poll and select implementation used task state to synchronize against wake ups, which doesn't have to be the case anymore as wait/wake interface can now use custom wake up functions. The non-sleep restriction can be a bit tricky because ->poll is not called from an atomic context and the result of accidentally sleeping in ->poll only shows up as temporary busy looping when the timing is right or rather wrong. This patch converts poll/select to use custom wake up function and use separate triggered variable to synchronize against wake up events. The only added overhead is an extra function call during wake up and negligible. This patch removes the one non-sleep exception from vfs locking rules and is beneficial to userland filesystem implementations like FUSE, 9p or peculiar fs like spufs as it's very difficult for those to implement non-sleeping poll method. While at it, make the following cosmetic changes to make poll.h and select.c checkpatch friendly. * s/type * symbol/type *symbol/ : three places in poll.h * remove blank line before EXPORT_SYMBOL() : two places in select.c Oleg: spotted missing barrier in poll_schedule_timeout() Davide: spotted missing write barrier in pollwake() Signed-off-by: Tejun Heo <[email protected]> Cc: Eric Van Hensbergen <[email protected]> Cc: Ron Minnich <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Cc: Davide Libenzi <[email protected]> Cc: Brad Boyer <[email protected]> Cc: Al Viro <[email protected]> Cc: Roland McGrath <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Davide Libenzi <[email protected]> Cc: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
67ec7d3ab7
commit
5f820f648c
4 changed files with 76 additions and 21 deletions
|
|
@ -203,7 +203,6 @@ static int poll_one(struct file *file, struct poll_wqueues *pwq)
|
|||
table = &pwq->pt;
|
||||
for (;;) {
|
||||
int mask;
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
mask = file->f_op->poll(file, table);
|
||||
if (mask & POLLIN)
|
||||
break;
|
||||
|
|
@ -212,9 +211,8 @@ static int poll_one(struct file *file, struct poll_wqueues *pwq)
|
|||
retval = -ERESTARTSYS;
|
||||
break;
|
||||
}
|
||||
schedule();
|
||||
poll_schedule(pwq, TASK_INTERRUPTIBLE);
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
poll_freewait(pwq);
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue