freebsd-dev/sys/dev/netmap
Vincenzo Maffione 19c4ec08ad netmap: fix lock order reversal related to kqueue usage
When using poll(), select() or kevent() on netmap file descriptors,
netmap executes the equivalent of NIOCTXSYNC and NIOCRXSYNC commands,
before collecting the events that are ready. In other words, the
poll/kevent callback has side effects. This is done to avoid the
overhead of two system call per iteration (e.g., poll() + ioctl(NIOC*XSYNC)).

When the kqueue subsystem invokes the kqueue(9) f_event callback
(netmap_knrw), it holds the lock of the struct knlist object associated
to the netmap port (the lock is provided at initialization, by calling
knlist_init_mtx).
However, netmap_knrw() may need to wake up another netmap port (or even
the same one), which means that it may need to call knote().
Since knote() needs the lock of the struct knlist object associated to
the to-be-wake-up netmap port, it is possible to have a lock order reversal
problem (AB/BA deadlock).

This change prevents the deadlock by executing the knote() call in a
per-selinfo taskqueue, where it is possible to hold a mutex.

Reviewed by:	aleksandr.fedorov_itglobal.com
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18956
2019-01-30 15:51:55 +00:00
..
if_ptnet.c netmap: improvements to the netmap kloop (CSB mode) 2019-01-23 14:51:36 +00:00
if_re_netmap.h netmap: align codebase to the current upstream (commit id 3fb001303718146) 2018-04-12 07:20:50 +00:00
if_vtnet_netmap.h netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_bdg.c netmap: add notifications on kloop stop 2019-01-29 10:28:50 +00:00
netmap_bdg.h netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_freebsd.c netmap: fix lock order reversal related to kqueue usage 2019-01-30 15:51:55 +00:00
netmap_generic.c netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_kern.h netmap: fix lock order reversal related to kqueue usage 2019-01-30 15:51:55 +00:00
netmap_kloop.c netmap: add notifications on kloop stop 2019-01-29 10:28:50 +00:00
netmap_legacy.c netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_mbq.c sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
netmap_mbq.h sys/dev: further adoption of SPDX licensing ID tags. 2017-11-27 14:52:40 +00:00
netmap_mem2.c netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_mem2.h netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_monitor.c netmap: fix crash with monitors and VALE ports 2019-01-24 22:09:26 +00:00
netmap_null.c netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_offloadings.c netmap: align codebase to upstream version v11.4 2018-04-09 09:24:26 +00:00
netmap_pipe.c netmap: pipes: make sure both ends use the same number of slots 2018-12-21 11:32:55 +00:00
netmap_pt.c netmap: pull fix for 32-bit support from upstream 2018-05-18 03:38:17 +00:00
netmap_vale.c netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap.c netmap: fix lock order reversal related to kqueue usage 2019-01-30 15:51:55 +00:00