Fix for deadlock situation in the LinuxKPI's RCU synchronize API.
authorhselasky <hselasky@FreeBSD.org>
Mon, 21 Aug 2017 11:51:40 +0000 (11:51 +0000)
committerhselasky <hselasky@FreeBSD.org>
Mon, 21 Aug 2017 11:51:40 +0000 (11:51 +0000)
commit925995d6357e9242603c83b37479ad6079b27232
tree124d71dd8df5102c0d967c47da39ec575f9cf1f5
parent09ad5627dc007c56e1b5aab5678080a2444e53bf
Fix for deadlock situation in the LinuxKPI's RCU synchronize API.

Deadlock condition:
The return value of TDQ_LOCKPTR(td) is the same for two threads.

1) The first thread signals a wakeup while keeping the rcu_read_lock().
This invokes sched_add() which in turn will try to lock TDQ_LOCK().

2) The second thread is calling synchronize_rcu() calling mi_switch() over
and over again trying to yield(). This prevents the first thread from running
and releasing the RCU reader lock.

Solution:
Release the thread lock while yielding to allow other threads to acquire the
lock pointed to by TDQ_LOCKPTR(td).

Found by: KrishnamRaju ErapaRaju <Krishna2@chelsio.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
sys/compat/linuxkpi/common/src/linux_rcu.c