android_kernel_xiaomi_sm8350/include
Peter Zijlstra 0ccf831cbe lockdep: annotate epoll
On Sat, 2008-01-05 at 13:35 -0800, Davide Libenzi wrote:

> I remember I talked with Arjan about this time ago. Basically, since 1)
> you can drop an epoll fd inside another epoll fd 2) callback-based wakeups
> are used, you can see a wake_up() from inside another wake_up(), but they
> will never refer to the same lock instance.
> Think about:
>
> 	dfd = socket(...);
> 	efd1 = epoll_create();
> 	efd2 = epoll_create();
> 	epoll_ctl(efd1, EPOLL_CTL_ADD, dfd, ...);
> 	epoll_ctl(efd2, EPOLL_CTL_ADD, efd1, ...);
>
> When a packet arrives to the device underneath "dfd", the net code will
> issue a wake_up() on its poll wake list. Epoll (efd1) has installed a
> callback wakeup entry on that queue, and the wake_up() performed by the
> "dfd" net code will end up in ep_poll_callback(). At this point epoll
> (efd1) notices that it may have some event ready, so it needs to wake up
> the waiters on its poll wait list (efd2). So it calls ep_poll_safewake()
> that ends up in another wake_up(), after having checked about the
> recursion constraints. That are, no more than EP_MAX_POLLWAKE_NESTS, to
> avoid stack blasting. Never hit the same queue, to avoid loops like:
>
> 	epoll_ctl(efd2, EPOLL_CTL_ADD, efd1, ...);
> 	epoll_ctl(efd3, EPOLL_CTL_ADD, efd2, ...);
> 	epoll_ctl(efd4, EPOLL_CTL_ADD, efd3, ...);
> 	epoll_ctl(efd1, EPOLL_CTL_ADD, efd4, ...);
>
> The code "if (tncur->wq == wq || ..." prevents re-entering the same
> queue/lock.

Since the epoll code is very careful to not nest same instance locks
allow the recursion.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Tested-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 09:44:07 -08:00
..
acpi include/acpi/: Spelling fixes 2008-02-03 17:07:16 +02:00
asm-alpha
asm-arm Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-02-04 15:29:53 -08:00
asm-avr32
asm-blackfin
asm-cris
asm-frv include/asm-frv/: Spelling fixes 2008-02-03 17:34:55 +02:00
asm-generic x86: fix RTC lockdep warning: potential hardirq recursion 2008-02-04 16:48:10 +01:00
asm-h8300
asm-ia64 asm-*/compat.h: fix typo in comment 2008-02-03 16:32:51 +02:00
asm-m32r
asm-m68k
asm-m68knommu include/asm-m68knommu/: Spelling fixes 2008-02-03 17:38:04 +02:00
asm-mips include/asm-mips/: Spelling fixes 2008-02-03 16:57:20 +02:00
asm-parisc include/asm-parisc/: Spelling fixes 2008-02-03 17:00:11 +02:00
asm-powerpc asm-*/compat.h: fix typo in comment 2008-02-03 16:32:51 +02:00
asm-ppc
asm-s390 asm-*/compat.h: fix typo in comment 2008-02-03 16:32:51 +02:00
asm-sh
asm-sparc
asm-sparc64 asm-*/compat.h: fix typo in comment 2008-02-03 16:32:51 +02:00
asm-um
asm-v850
asm-x86 Merge git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86 2008-02-04 09:16:03 -08:00
asm-xtensa
crypto
keys
linux lockdep: annotate epoll 2008-02-05 09:44:07 -08:00
math-emu
media include/media/: Spelling fixes 2008-02-03 17:19:47 +02:00
mtd
net [IPV6]: Reorg struct ifmcaddr6 to save some bytes 2008-02-03 04:28:54 -08:00
pcmcia
rdma
rxrpc
scsi include/scsi/: Spelling fixes 2008-02-03 17:47:00 +02:00
sound
video
xen
Kbuild