inet: minor optimization for backlog setting in listen(2)
Subsystems (3)
PATCH 1/1 inet: minor optimization for backlog setting in listen(2)
Set the backlog earlier in inet_dccp_listen() and inet_listen(), then we can avoid the redundant setting.
--- net/dccp/proto.c | 2 +- net/ipv4/af_inet.c | 2 +- net/ipv4/inet_connection_sock.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-)
net/dccp/proto.c +1 -1
@@ -948,6 +948,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)if (!((1 << old_state) & (DCCPF_CLOSED |DCCPF_LISTEN ))) goto out; + sk->sk_max_ack_backlog = backlog;/* Really, if the socket is already in listen state * we can only allow the backlog to be adjusted. */
@@ -960,7 +961,6 @@ int inet_dccp_listen(struct socket *sock, int backlog)if (err) goto out; } - sk->sk_max_ack_backlog = backlog; err =0 ; out:
net/ipv4/af_inet.c +1 -1
@@ -208,6 +208,7 @@ int inet_listen(struct socket *sock, int backlog)if (!((1 << old_state) & (TCPF_CLOSE |TCPF_LISTEN ))) goto out; + sk->sk_max_ack_backlog = backlog;/* Really, if the socket is already in listen state * we can only allow the backlog to be adjusted. */
@@ -231,7 +232,6 @@ int inet_listen(struct socket *sock, int backlog) goto out;tcp_call_bpf (sk,BPF_SOCK_OPS_TCP_LISTEN_CB ,0 ,NULL ); } - sk->sk_max_ack_backlog = backlog; err =0 ; out:
net/ipv4/inet_connection_sock.c +0 -1
@@ -874,7 +874,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog)reqsk_queue_alloc (&icsk->icsk_accept_queue); - sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog =0 ;inet_csk_delack_init (sk);
Signature · 1 line
1.8.3.1
PATCH 1/1 tcp: minor optimization in tcp ack fast path processing
Bitwise operation is a little faster.
So I replace after() with (flag & FLAG_SND_UNA_ADVANCED) as this flag is already set before.
--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
@@ -3610,7 +3610,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)if (flag &FLAG_UPDATE_TS_RECENT )tcp_replace_ts_recent (tp,TCP_SKB_CB (skb)->seq); -if (!(flag &FLAG_SLOWPATH ) &&after (ack, prior_snd_una)) { +if (!(flag &FLAG_SLOWPATH ) && (flag &FLAG_SND_UNA_ADVANCED )) {/* Window is constant, pure forward advance. * No more checks are required. * Note, we use the fact that SND.UNA>=SND.WL2.
Signature · 1 line
1.8.3.1
Re: [PATCH net-next] tcp: minor optimization in tcp ack fast path processing
Quoted 18 lines · Yafang Shao
Bitwise operation is a little faster.
So I replace
after()with (flag &FLAG_SND_UNA_ADVANCED) as this flag is already set before.Cc Joe Perches <[email protected]>Signed-off-by Yafang Shao <[email protected]>--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/tcp_input.c +0
-0
net/ipv4/tcp_input.c static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) · line 3616
Quoted 8 lines
net/ipv4/tcp_input.c +1
-1@@ -3610,7 +3610,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)if (flag &FLAG_UPDATE_TS_RECENT )tcp_replace_ts_recent (tp,TCP_SKB_CB (skb)->seq); -if (!(flag &FLAG_SLOWPATH ) &&after (ack, prior_snd_una)) { +if (!(flag &FLAG_SLOWPATH ) && (flag &FLAG_SND_UNA_ADVANCED )) {/* Window is constant, pure forward advance. * No more checks are required. * Note, we use the fact that SND.UNA>=SND.WL2.
What about reducing this to a single conditional jump ?
if ((flag & (FLAG_SLOWPATH | FLAG_SND_UNA_ADVANCED)) == FLAG_SND_UNA_ADVANCED) {
Re: [PATCH net-next] tcp: minor optimization in tcp ack fast path processing
Quoted 33 lines · Eric Dumazet
Quoted 18 lines · Yafang Shao
Bitwise operation is a little faster.
So I replace
after()with (flag &FLAG_SND_UNA_ADVANCED) as this flag is already set before.Cc Joe Perches <[email protected]>Signed-off-by Yafang Shao <[email protected]>--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/tcp_input.c +0
-0net/ipv4/tcp_input.c static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) · line 3616
Quoted 8 lines
net/ipv4/tcp_input.c +1
-1@@ -3610,7 +3610,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)if (flag &FLAG_UPDATE_TS_RECENT )tcp_replace_ts_recent (tp,TCP_SKB_CB (skb)->seq); -if (!(flag &FLAG_SLOWPATH ) &&after (ack, prior_snd_una)) { +if (!(flag &FLAG_SLOWPATH ) && (flag &FLAG_SND_UNA_ADVANCED )) {/* Window is constant, pure forward advance. * No more checks are required. * Note, we use the fact that SND.UNA>=SND.WL2. What about reducing this to a single conditional jump ?
Quoted 2 lines
if ((flag & (
FLAG_SLOWPATH|FLAG_SND_UNA_ADVANCED)) ==FLAG_SND_UNA_ADVANCED) {
That's better.
Will change it.
Thanks
Yafang
Quoted 6 lines · Yafang Shao
Set the backlog earlier in
inet_dccp_listen()andinet_listen(), then we can avoid the redundant setting.Signed-off-by Yafang Shao <[email protected]>---
From: Yafang Shao <[email protected]>
Date: Wed, 7 Nov 2018 19:20:16 +0800
Quoted 4 lines
Set the backlog earlier in
inet_dccp_listen()andinet_listen(), then we can avoid the redundant setting.Signed-off-by Yafang Shao <[email protected]>
Applied.