Skip to contentSkip to conversation

Weird locking in __release_sock()?

DISCUSSION David Daney 2 participants 2 messages Jun 22, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

In net/core/sock.c the function __release_sock() appears to drop the socket lock, and then feed the backlogged skbs to sk_backlog_rcv().

In the case of an IPv4 TCP socket, sk_backlog_rcv() calls tcp_v4_do_rcv(), which is documented like this:

/* The socket must have it's spinlock held when we get
* here.
.
.
.
*/

Q: How can this be correct?

Perhaps I am missing something. In any event, thanks in advance shedding some light on the locking situation.

David Daney

maintainer
#1 lore raw

From: David Daney <[email protected]>
Date: Wed, 22 Jun 2011 16:31:13 -0700

Quoted 11 lines

In the case of an IPv4 TCP socket, sk_backlog_rcv() calls tcp_v4_do_rcv(), which is documented like this:

/* The socket must have it's spinlock held when we get
* here.
.
.
.
*/

Q: How can this be correct?

sk->lock.owned will be "1" while the backlog is processed.

Exclusive access to the socket is indicated by one of the following two conditions being true:

1) sk->lock.slock being held
2) sk->lock.owned being non-zero