]> git.karo-electronics.de Git - karo-tx-linux.git/commit
epoll can acquire recursively acquire ep->mtx on multiple "struct
authorNelson Elhage <nelhage@nelhage.com>
Wed, 24 Aug 2011 23:47:37 +0000 (09:47 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 26 Sep 2011 07:03:09 +0000 (17:03 +1000)
commit7e46ba97cebd28e855dc67696c61d7e0005751ab
tree5e560e52659e4427ef8426fd1af3d61c8d77b737
parentf1f1fa39757c06a77dc41d4dc28f41c56d78b066
epoll can acquire recursively acquire ep->mtx on multiple "struct
eventpoll"s at once in the case where one epoll fd is monitoring another
epoll fd.  This is perfectly OK, since we're careful about the lock
ordering, but it causes spurious lockdep warnings.  Annotate the recursion
using mutex_lock_nested, and add a comment explaining the nesting rules
for good measure.

Recent versions of systemd are triggering this, and it can also be
demonstrated with the following trivial test program:

--------------------8<--------------------

int main(void) {
   int e1, e2;
   struct epoll_event evt = {
       .events = EPOLLIN
   };

   e1 = epoll_create1(0);
   e2 = epoll_create1(0);
   epoll_ctl(e1, EPOLL_CTL_ADD, e2, &evt);
   return 0;
}
--------------------8<--------------------

Reported-by: Paul Bolle <pebolle@tiscali.nl>
Tested-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Nelson Elhage <nelhage@nelhage.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/eventpoll.c