Skip to content

Commit 0e71c55

Browse files
edumazetdavem330
authored andcommitted
tcp: speedup SIOCINQ ioctl
SIOCINQ can use the lock_sock_fast() version to avoid double acquisition of socket lock. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 354e4aa commit 0e71c55

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv4/tcp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,14 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
536536
{
537537
struct tcp_sock *tp = tcp_sk(sk);
538538
int answ;
539+
bool slow;
539540

540541
switch (cmd) {
541542
case SIOCINQ:
542543
if (sk->sk_state == TCP_LISTEN)
543544
return -EINVAL;
544545

545-
lock_sock(sk);
546+
slow = lock_sock_fast(sk);
546547
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))
547548
answ = 0;
548549
else if (sock_flag(sk, SOCK_URGINLINE) ||
@@ -557,7 +558,7 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
557558
answ--;
558559
} else
559560
answ = tp->urg_seq - tp->copied_seq;
560-
release_sock(sk);
561+
unlock_sock_fast(sk, slow);
561562
break;
562563
case SIOCATMARK:
563564
answ = tp->urg_data && tp->urg_seq == tp->copied_seq;

0 commit comments

Comments
 (0)