diff mbox

[2/3] tcp: Remove unrequired operations in tcp_push()

Message ID 20091209082619.19055.10563.sendpatchset@localhost.localdomain
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Krishna Kumar Dec. 9, 2009, 8:26 a.m. UTC
From: Krishna Kumar <krkumar2@in.ibm.com>

Remove unrequired operations in tcp_push()

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---
 net/ipv4/tcp.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Ilpo Järvinen Dec. 10, 2009, 8:10 a.m. UTC | #1
On Wed, 9 Dec 2009, Krishna Kumar wrote:

> From: Krishna Kumar <krkumar2@in.ibm.com>
> 
> Remove unrequired operations in tcp_push()
> 
> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
> ---
>  net/ipv4/tcp.c |   15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff -ruNp org/net/ipv4/tcp.c new/net/ipv4/tcp.c
> --- org/net/ipv4/tcp.c	2009-12-04 18:16:10.000000000 +0530
> +++ new/net/ipv4/tcp.c	2009-12-09 10:01:35.000000000 +0530
> @@ -536,8 +536,7 @@ static inline void skb_entail(struct soc
>  		tp->nonagle &= ~TCP_NAGLE_PUSH;
>  }
>  
> -static inline void tcp_mark_urg(struct tcp_sock *tp, int flags,
> -				struct sk_buff *skb)
> +static inline void tcp_mark_urg(struct tcp_sock *tp, int flags)
>  {
>  	if (flags & MSG_OOB)
>  		tp->snd_up = tp->write_seq;
> @@ -546,13 +545,15 @@ static inline void tcp_mark_urg(struct t
>  static inline void tcp_push(struct sock *sk, int flags, int mss_now,
>  			    int nonagle)
>  {
> -	struct tcp_sock *tp = tcp_sk(sk);
> -
>  	if (tcp_send_head(sk)) {
> -		struct sk_buff *skb = tcp_write_queue_tail(sk);
> -		if (!(flags & MSG_MORE) || forced_push(tp))
> +		struct tcp_sock *tp = tcp_sk(sk);
> +
> +		if (!(flags & MSG_MORE) || forced_push(tp)) {
> +			struct sk_buff *skb = tcp_write_queue_tail(sk);
> +
>  			tcp_mark_push(tp, skb);

I suppose one could kill the temporary variable completely then?

> -		tcp_mark_urg(tp, flags, skb);
> +		}
> +		tcp_mark_urg(tp, flags);
>  		__tcp_push_pending_frames(sk, mss_now,
>  					  (flags & MSG_MORE) ? TCP_NAGLE_CORK : nonagle);
>  	}
Krishna Kumar Dec. 10, 2009, 9:06 a.m. UTC | #2
"Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> wrote on 12/10/2009 01:40:51
PM:

> Re: [PATCH 2/3] tcp: Remove unrequired operations in tcp_push()
>
>
> >  static inline void tcp_push(struct sock *sk, int flags, int mss_now,
> >               int nonagle)
> >  {
> > -   struct tcp_sock *tp = tcp_sk(sk);
> > -
> >     if (tcp_send_head(sk)) {
> > -      struct sk_buff *skb = tcp_write_queue_tail(sk);
> > -      if (!(flags & MSG_MORE) || forced_push(tp))
> > +      struct tcp_sock *tp = tcp_sk(sk);
> > +
> > +      if (!(flags & MSG_MORE) || forced_push(tp)) {
> > +         struct sk_buff *skb = tcp_write_queue_tail(sk);
> > +
> >           tcp_mark_push(tp, skb);
>
> I suppose one could kill the temporary variable completely then?

I did consider that, but kept it this way for readability reasons.
Should I change it?

Thanks,

- KK

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ilpo Järvinen Dec. 10, 2009, 10:26 a.m. UTC | #3
On Thu, 10 Dec 2009, Krishna Kumar2 wrote:

> "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> wrote on 12/10/2009 01:40:51
> PM:
> 
> > Re: [PATCH 2/3] tcp: Remove unrequired operations in tcp_push()
> >
> >
> > >  static inline void tcp_push(struct sock *sk, int flags, int mss_now,
> > >               int nonagle)
> > >  {
> > > -   struct tcp_sock *tp = tcp_sk(sk);
> > > -
> > >     if (tcp_send_head(sk)) {
> > > -      struct sk_buff *skb = tcp_write_queue_tail(sk);
> > > -      if (!(flags & MSG_MORE) || forced_push(tp))
> > > +      struct tcp_sock *tp = tcp_sk(sk);
> > > +
> > > +      if (!(flags & MSG_MORE) || forced_push(tp)) {
> > > +         struct sk_buff *skb = tcp_write_queue_tail(sk);
> > > +
> > >           tcp_mark_push(tp, skb);
> >
> > I suppose one could kill the temporary variable completely then?
> 
> I did consider that, but kept it this way for readability reasons.
> Should I change it?

Honestly that doesn't look that fuzzy code even if you'd stick it into the 
tcp_mark_push line (nor should be even close to 80 limit). ...I was even 
thinking of getting totally rid of that skb arg of tcp_mark_push as I 
think it's always tcp_write_queue_tail(sk) that is put there.
Krishna Kumar Dec. 10, 2009, 11:59 a.m. UTC | #4
"Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> wrote on 12/10/2009 03:56:59
PM:

> Re: [PATCH 2/3] tcp: Remove unrequired operations in tcp_push()
>
> On Thu, 10 Dec 2009, Krishna Kumar2 wrote:
>
> > "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> wrote on 12/10/2009
01:40:51
> > PM:
> >
> > > Re: [PATCH 2/3] tcp: Remove unrequired operations in tcp_push()
> > >
> > >
> > > >  static inline void tcp_push(struct sock *sk, int flags, int
mss_now,
> > > >               int nonagle)
> > > >  {
> > > > -   struct tcp_sock *tp = tcp_sk(sk);
> > > > -
> > > >     if (tcp_send_head(sk)) {
> > > > -      struct sk_buff *skb = tcp_write_queue_tail(sk);
> > > > -      if (!(flags & MSG_MORE) || forced_push(tp))
> > > > +      struct tcp_sock *tp = tcp_sk(sk);
> > > > +
> > > > +      if (!(flags & MSG_MORE) || forced_push(tp)) {
> > > > +         struct sk_buff *skb = tcp_write_queue_tail(sk);
> > > > +
> > > >           tcp_mark_push(tp, skb);
> > >
> > > I suppose one could kill the temporary variable completely then?
> >
> > I did consider that, but kept it this way for readability reasons.
> > Should I change it?
>
> Honestly that doesn't look that fuzzy code even if you'd stick it into
the
> tcp_mark_push line (nor should be even close to 80 limit). ...I was even
> thinking of getting totally rid of that skb arg of tcp_mark_push as I
> think it's always tcp_write_queue_tail(sk) that is put there.

Yes, the skb is always the one at the tail. But in 4/5 cases, the
skb pointer is already available, so may be OK to pass the skb. I
will resubmit with the change you suggested (remove the temporary
variable).

Also, for the NETIF_F_SG patch, I will try to put a meaningful
explanation and resubmit.

Thanks for your review,

- KK

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ilpo Järvinen Dec. 10, 2009, 12:03 p.m. UTC | #5
On Thu, 10 Dec 2009, Krishna Kumar2 wrote:

> "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> wrote on 12/10/2009 03:56:59
> PM:
> 
> > Re: [PATCH 2/3] tcp: Remove unrequired operations in tcp_push()
> >
> > On Thu, 10 Dec 2009, Krishna Kumar2 wrote:
> >
> > > "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi> wrote on 12/10/2009
> 01:40:51
> > > PM:
> > >
> > > > Re: [PATCH 2/3] tcp: Remove unrequired operations in tcp_push()
> > > >
> > > >
> > > > >  static inline void tcp_push(struct sock *sk, int flags, int
> mss_now,
> > > > >               int nonagle)
> > > > >  {
> > > > > -   struct tcp_sock *tp = tcp_sk(sk);
> > > > > -
> > > > >     if (tcp_send_head(sk)) {
> > > > > -      struct sk_buff *skb = tcp_write_queue_tail(sk);
> > > > > -      if (!(flags & MSG_MORE) || forced_push(tp))
> > > > > +      struct tcp_sock *tp = tcp_sk(sk);
> > > > > +
> > > > > +      if (!(flags & MSG_MORE) || forced_push(tp)) {
> > > > > +         struct sk_buff *skb = tcp_write_queue_tail(sk);
> > > > > +
> > > > >           tcp_mark_push(tp, skb);
> > > >
> > > > I suppose one could kill the temporary variable completely then?
> > >
> > > I did consider that, but kept it this way for readability reasons.
> > > Should I change it?
> >
> > Honestly that doesn't look that fuzzy code even if you'd stick it into
> the
> > tcp_mark_push line (nor should be even close to 80 limit). ...I was even
> > thinking of getting totally rid of that skb arg of tcp_mark_push as I
> > think it's always tcp_write_queue_tail(sk) that is put there.
> 
> Yes, the skb is always the one at the tail. But in 4/5 cases, the
> skb pointer is already available, so may be OK to pass the skb.

...which was exactly why I didn't immediately suggest it :-).

> Also, for the NETIF_F_SG patch, I will try to put a meaningful
> explanation and resubmit.

Thanks.
diff mbox

Patch

diff -ruNp org/net/ipv4/tcp.c new/net/ipv4/tcp.c
--- org/net/ipv4/tcp.c	2009-12-04 18:16:10.000000000 +0530
+++ new/net/ipv4/tcp.c	2009-12-09 10:01:35.000000000 +0530
@@ -536,8 +536,7 @@  static inline void skb_entail(struct soc
 		tp->nonagle &= ~TCP_NAGLE_PUSH;
 }
 
-static inline void tcp_mark_urg(struct tcp_sock *tp, int flags,
-				struct sk_buff *skb)
+static inline void tcp_mark_urg(struct tcp_sock *tp, int flags)
 {
 	if (flags & MSG_OOB)
 		tp->snd_up = tp->write_seq;
@@ -546,13 +545,15 @@  static inline void tcp_mark_urg(struct t
 static inline void tcp_push(struct sock *sk, int flags, int mss_now,
 			    int nonagle)
 {
-	struct tcp_sock *tp = tcp_sk(sk);
-
 	if (tcp_send_head(sk)) {
-		struct sk_buff *skb = tcp_write_queue_tail(sk);
-		if (!(flags & MSG_MORE) || forced_push(tp))
+		struct tcp_sock *tp = tcp_sk(sk);
+
+		if (!(flags & MSG_MORE) || forced_push(tp)) {
+			struct sk_buff *skb = tcp_write_queue_tail(sk);
+
 			tcp_mark_push(tp, skb);
-		tcp_mark_urg(tp, flags, skb);
+		}
+		tcp_mark_urg(tp, flags);
 		__tcp_push_pending_frames(sk, mss_now,
 					  (flags & MSG_MORE) ? TCP_NAGLE_CORK : nonagle);
 	}