---
name: "skwq_has_sleeper"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/skwq_has_sleeper"
---

# skwq\_has\_sleeper(9)

check if there are any waiting processes

## NAME

skwq\_has\_sleeper - check if there are any waiting processes

## SYNOPSIS

**bool skwq\_has\_sleeper(struct socket\_wq \*** *wq***);**

## ARGUMENTS

*wq*

struct socket\_wq

## DESCRIPTION

Returns true if socket\_wq has waiting processes

The purpose of the skwq\_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.

Consider following tcp code paths:

CPU1 CPU2

sys\_select receive packet ... ... \_\_add\_wait\_queue update tp-\>rcv\_nxt ... ... tp-\>rcv\_nxt check sock\_def\_readable ... { schedule **rcu\_read\_lock**; wq = rcu\_dereference(sk-\>sk\_wq); if (wq && waitqueue\_active(wq-\>wait)) wake\_up\_interruptible(wq-\>wait) ... }

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.

## COPYRIGHT
