[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: src/sys/netipsec
Module Name: src
Committed By: ozaki-r
Date: Wed Sep 27 07:27:29 UTC 2017
Fix deadlock between pserialize_perform and localcount_drain
A typical ussage of localcount_drain looks like this:
item = remove_from_list();
localcount_drain(&item->localcount, &cv, &mtx);
This sequence can cause a deadlock which happens for example on the following
- Thread A calls localcount_drain which calls xc_broadcast after releasing
a specified mutex
- Thread B enters the sequence and calls pserialize_perform with holding
the mutex while pserialize_perform also calls xc_broadcast
- Thread C (xc_thread) that calls an xcall callback of localcount_drain tries
to hold the mutex
xc_broadcast of thread B doesn't start until xc_broadcast of thread A
finishes, which is a feature of xcall(9). This means that pserialize_perform
never complete until xc_broadcast of thread A finishes. On the other hand,
thread C that is a callee of xc_broadcast of thread A sticks on the mutex.
Finally the threads block each other (A blocks B, B blocks C and C blocks A).
A possible fix is to serialize executions of the above sequence by another
mutex, but adding another mutex makes the code complex, so fix the deadlock
by another way; the fix is to release the mutex before pserialize_perform
and instead use a condvar to prevent pserialize_perform from being called
Note that the deadlock has happened only if NET_MPSAFE is enabled.
To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/sys/netipsec/key.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Main Index |
Thread Index |