All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] inet: minor optimization for backlog setting in listen(2)
@ 2018-11-07 11:20 Yafang Shao
  2018-11-07 11:20 ` [PATCH net-next] tcp: minor optimization in tcp ack fast path processing Yafang Shao
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yafang Shao @ 2018-11-07 11:20 UTC (permalink / raw)
  To: davem, edumazet; +Cc: netdev, linux-kernel, Yafang Shao

Set the backlog earlier in inet_dccp_listen() and inet_listen(),
then we can avoid the redundant setting.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 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(-)

diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 43733ac..658cd32b 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -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:
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1fbe2f8..39066cd 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -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:
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 15e7f79..860e22a 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -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);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next] tcp: minor optimization in tcp ack fast path processing
  2018-11-07 11:20 [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Yafang Shao
@ 2018-11-07 11:20 ` Yafang Shao
  2018-11-07 15:16   ` Eric Dumazet
  2018-11-07 18:03 ` [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Eric Dumazet
  2018-11-08  6:31 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Yafang Shao @ 2018-11-07 11:20 UTC (permalink / raw)
  To: davem, edumazet; +Cc: netdev, linux-kernel, Yafang Shao, Joe Perches

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 <joe@perches.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/ipv4/tcp_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 2868ef2..0167015 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -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.
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] tcp: minor optimization in tcp ack fast path processing
  2018-11-07 11:20 ` [PATCH net-next] tcp: minor optimization in tcp ack fast path processing Yafang Shao
@ 2018-11-07 15:16   ` Eric Dumazet
  2018-11-08  1:45     ` Yafang Shao
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2018-11-07 15:16 UTC (permalink / raw)
  To: Yafang Shao, davem, edumazet; +Cc: netdev, linux-kernel, Joe Perches



On 11/07/2018 03:20 AM, Yafang Shao wrote:
> 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 <joe@perches.com>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>  net/ipv4/tcp_input.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 2868ef2..0167015 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -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)  {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] inet: minor optimization for backlog setting in listen(2)
  2018-11-07 11:20 [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Yafang Shao
  2018-11-07 11:20 ` [PATCH net-next] tcp: minor optimization in tcp ack fast path processing Yafang Shao
@ 2018-11-07 18:03 ` Eric Dumazet
  2018-11-08  6:31 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2018-11-07 18:03 UTC (permalink / raw)
  To: Yafang Shao, davem, edumazet; +Cc: netdev, linux-kernel



On 11/07/2018 03:20 AM, Yafang Shao wrote:
> Set the backlog earlier in inet_dccp_listen() and inet_listen(),
> then we can avoid the redundant setting.
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>

Reviewed-by: Eric Dumazet <edumazet@google.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] tcp: minor optimization in tcp ack fast path processing
  2018-11-07 15:16   ` Eric Dumazet
@ 2018-11-08  1:45     ` Yafang Shao
  0 siblings, 0 replies; 6+ messages in thread
From: Yafang Shao @ 2018-11-08  1:45 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, Eric Dumazet, netdev, LKML, Joe Perches

On Wed, Nov 7, 2018 at 11:16 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 11/07/2018 03:20 AM, Yafang Shao wrote:
> > 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 <joe@perches.com>
> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> > ---
> >  net/ipv4/tcp_input.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> > index 2868ef2..0167015 100644
> > --- a/net/ipv4/tcp_input.c
> > +++ b/net/ipv4/tcp_input.c
> > @@ -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)  {
>

That's better.
Will change it.


Thanks
Yafang

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] inet: minor optimization for backlog setting in listen(2)
  2018-11-07 11:20 [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Yafang Shao
  2018-11-07 11:20 ` [PATCH net-next] tcp: minor optimization in tcp ack fast path processing Yafang Shao
  2018-11-07 18:03 ` [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Eric Dumazet
@ 2018-11-08  6:31 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-11-08  6:31 UTC (permalink / raw)
  To: laoar.shao; +Cc: edumazet, netdev, linux-kernel

From: Yafang Shao <laoar.shao@gmail.com>
Date: Wed,  7 Nov 2018 19:20:16 +0800

> Set the backlog earlier in inet_dccp_listen() and inet_listen(),
> then we can avoid the redundant setting.
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-11-08  6:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 11:20 [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Yafang Shao
2018-11-07 11:20 ` [PATCH net-next] tcp: minor optimization in tcp ack fast path processing Yafang Shao
2018-11-07 15:16   ` Eric Dumazet
2018-11-08  1:45     ` Yafang Shao
2018-11-07 18:03 ` [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Eric Dumazet
2018-11-08  6:31 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.