• Tejun Heo's avatar
    poll: allow f_op->poll to sleep · 5f820f64
    Tejun Heo authored
    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: default avatarTejun Heo <tj@kernel.org>
    Cc: Eric Van Hensbergen <ericvh@gmail.com>
    Cc: Ron Minnich <rminnich@sandia.gov>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Christoph Hellwig <hch@infradead.org>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
    Cc: Davide Libenzi <davidel@xmailserver.org>
    Cc: Brad Boyer <flar@allandria.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Roland McGrath <roland@redhat.com>
    Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Cc: Davide Libenzi <davidel@xmailserver.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    5f820f64
v4l1-compat.c 31.2 KB