'\" t .\" Title: wq_has_sleeper .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" Date: May 2018 .\" Manual: Linux Networking .\" Source: Kernel Hackers Manual 3.16.56 .\" Language: English .\" .TH "WQ_HAS_SLEEPER" "9" "May 2018" "Kernel Hackers Manual 3\&.16\&" "Linux Networking" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" wq_has_sleeper \- check if there are any waiting processes .SH "SYNOPSIS" .HP \w'bool\ wq_has_sleeper('u .BI "bool wq_has_sleeper(struct\ socket_wq\ *\ " "wq" ");" .SH "ARGUMENTS" .PP \fIwq\fR .RS 4 struct socket_wq .RE .SH "DESCRIPTION" .PP Returns true if socket_wq has waiting processes .PP The purpose of the wq_has_sleeper and sock_poll_wait is to wrap the memory barrier call\&. They were added due to the race found within the tcp code\&. .SH "CONSIDER FOLLOWING TCP CODE PATHS" .PP .PP CPU1 CPU2 .PP sys_select receive packet \&.\&.\&. \&.\&.\&. __add_wait_queue update tp\->rcv_nxt \&.\&.\&. \&.\&.\&. tp\->rcv_nxt check sock_def_readable \&.\&.\&. { schedule \fBrcu_read_lock\fR; wq = rcu_dereference(sk\->sk_wq); if (wq && waitqueue_active(wq\->wait)) wake_up_interruptible(wq\->wait) \&.\&.\&. } .PP The race for tcp fires when the __add_wait_queue changes done by CPU1 stay in its cache, and so does the tp\->rcv_nxt update on CPU2 side\&. The CPU1 could then endup calling schedule and sleep forever if there are no more data on the socket\&. .SH "COPYRIGHT" .br