1WQ_HAS_SLEEPER(9)              Linux Networking              WQ_HAS_SLEEPER(9)
2
3
4

NAME

6       wq_has_sleeper - check if there are any waiting processes
7

SYNOPSIS

9       bool wq_has_sleeper(struct socket_wq * wq);
10

ARGUMENTS

12       wq
13           struct socket_wq
14

DESCRIPTION

16       Returns true if socket_wq has waiting processes
17
18       The purpose of the wq_has_sleeper and sock_poll_wait is to wrap the
19       memory barrier call. They were added due to the race found within the
20       tcp code.
21

CONSIDER FOLLOWING TCP CODE PATHS

23       CPU1 CPU2
24
25       sys_select receive packet ... ... __add_wait_queue update tp->rcv_nxt
26       ... ... tp->rcv_nxt check sock_def_readable ... { schedule
27       rcu_read_lock; wq = rcu_dereference(sk->sk_wq); if (wq &&
28       waitqueue_active(wq->wait)) wake_up_interruptible(wq->wait) ... }
29
30       The race for tcp fires when the __add_wait_queue changes done by CPU1
31       stay in its cache, and so does the tp->rcv_nxt update on CPU2 side. The
32       CPU1 could then endup calling schedule and sleep forever if there are
33       no more data on the socket.
34
36Kernel Hackers Manual 3.10         June 2019                 WQ_HAS_SLEEPER(9)
Impressum