]> git.baikalelectronics.ru Git - kernel.git/commit
tipc: fix race/inefficiencies in poll/wait behaviour
authorYing Xue <ying.xue@windriver.com>
Tue, 21 Aug 2012 03:16:57 +0000 (11:16 +0800)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Wed, 21 Nov 2012 19:54:31 +0000 (14:54 -0500)
commitd213dd49a6c4838a64153e30b711f9a82df1dc2d
tree399a156cc2466cfe5526176bac8a0f7e8723a9e8
parent3945def9257055316085fe1357dc49fdb834c988
tipc: fix race/inefficiencies in poll/wait behaviour

When an application blocks at poll/select on a TIPC socket
while requesting a specific event mask, both the filter_rcv() and
wakeupdispatch() case will wake it up unconditionally whenever
the state changes (i.e an incoming message arrives, or congestion
has subsided).  No mask is used.

To avoid this, we populate sk->sk_data_ready and sk->sk_write_space
with tipc_data_ready and tipc_write_space respectively, which makes
tipc more in alignment with the rest of the networking code.  These
pass the exact set of possible events to the waker in fs/select.c
hence avoiding waking up blocked processes unnecessarily.

In doing so, we uncover another issue -- that there needs to be a
memory barrier in these poll/receive callbacks, otherwise we are
subject to the the same race as documented above wq_has_sleeper()
[in commit 41763456 "net: adding memory barrier to the poll and
receive callbacks"].  So we need to replace poll_wait() with
sock_poll_wait() and use rcu protection for the sk->sk_wq pointer
in these two new functions.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
net/tipc/socket.c