aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/eventpoll.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ca300071e79c..23c220774d1b 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -427,6 +427,31 @@ out_unlock:
427 return error; 427 return error;
428} 428}
429 429
430/*
431 * As described in commit 0ccf831cb lockdep: annotate epoll
432 * the use of wait queues used by epoll is done in a very controlled
433 * manner. Wake ups can nest inside each other, but are never done
434 * with the same locking. For example:
435 *
436 * dfd = socket(...);
437 * efd1 = epoll_create();
438 * efd2 = epoll_create();
439 * epoll_ctl(efd1, EPOLL_CTL_ADD, dfd, ...);
440 * epoll_ctl(efd2, EPOLL_CTL_ADD, efd1, ...);
441 *
442 * When a packet arrives to the device underneath "dfd", the net code will
443 * issue a wake_up() on its poll wake list. Epoll (efd1) has installed a
444 * callback wakeup entry on that queue, and the wake_up() performed by the
445 * "dfd" net code will end up in ep_poll_callback(). At this point epoll
446 * (efd1) notices that it may have some event ready, so it needs to wake up
447 * the waiters on its poll wait list (efd2). So it calls ep_poll_safewake()
448 * that ends up in another wake_up(), after having checked about the
449 * recursion constraints. That are, no more than EP_MAX_POLLWAKE_NESTS, to
450 * avoid stack blasting.
451 *
452 * When CONFIG_DEBUG_LOCK_ALLOC is enabled, make sure lockdep can handle
453 * this special case of epoll.
454 */
430#ifdef CONFIG_DEBUG_LOCK_ALLOC 455#ifdef CONFIG_DEBUG_LOCK_ALLOC
431static inline void ep_wake_up_nested(wait_queue_head_t *wqueue, 456static inline void ep_wake_up_nested(wait_queue_head_t *wqueue,
432 unsigned long events, int subclass) 457 unsigned long events, int subclass)