All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps
@ 2016-04-28  3:38 Soheil Hassas Yeganeh
  2016-04-28  3:39 ` [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp Soheil Hassas Yeganeh
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Soheil Hassas Yeganeh @ 2016-04-28  3:38 UTC (permalink / raw)
  To: davem, netdev
  Cc: kafai, willemb, edumazet, ycheng, ncardwell,
	Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

v2:
- Fully remove SKBTX_ACK_TSTAMP, as suggested by Willem de Bruijn.

This patch series aims at removing redundant checks and fields
for ack timestamps for TCP.

Soheil Hassas Yeganeh (2):
  tcp: remove an unnecessary check in tcp_tx_timestamp
  tcp: remove SKBTX_ACK_TSTAMP since it is redundant

 include/linux/skbuff.h |  6 +-----
 net/ipv4/tcp.c         |  7 ++++---
 net/ipv4/tcp_input.c   |  3 +--
 net/ipv4/tcp_output.c  | 17 +++++++++++------
 net/socket.c           |  3 ---
 5 files changed, 17 insertions(+), 19 deletions(-)

-- 
2.8.0.rc3.226.g39d4020

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

* [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp
  2016-04-28  3:38 [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps Soheil Hassas Yeganeh
@ 2016-04-28  3:39 ` Soheil Hassas Yeganeh
  2016-04-28  4:35   ` Eric Dumazet
  2016-04-28  3:39 ` [PATCH v2 net-next 2/2] tcp: remove SKBTX_ACK_TSTAMP since it is redundant Soheil Hassas Yeganeh
  2016-04-28 20:06 ` [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Soheil Hassas Yeganeh @ 2016-04-28  3:39 UTC (permalink / raw)
  To: davem, netdev
  Cc: kafai, willemb, edumazet, ycheng, ncardwell,
	Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

Remove the redundant check for sk->sk_tsflags in tcp_tx_timestamp.

tcp_tx_timestamp() receives the tsflags as a parameter. As a
result the "sk->sk_tsflags || tsflags" is redundant, since
tsflags already includes sk->sk_tsflags plus overrides from
control messages.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
---
 net/ipv4/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4d73858..3c542dc 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -430,7 +430,7 @@ EXPORT_SYMBOL(tcp_init_sock);
 
 static void tcp_tx_timestamp(struct sock *sk, u16 tsflags, struct sk_buff *skb)
 {
-	if (sk->sk_tsflags || tsflags) {
+	if (tsflags) {
 		struct skb_shared_info *shinfo = skb_shinfo(skb);
 		struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
 
-- 
2.8.0.rc3.226.g39d4020

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

* [PATCH v2 net-next 2/2] tcp: remove SKBTX_ACK_TSTAMP since it is redundant
  2016-04-28  3:38 [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps Soheil Hassas Yeganeh
  2016-04-28  3:39 ` [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp Soheil Hassas Yeganeh
@ 2016-04-28  3:39 ` Soheil Hassas Yeganeh
  2016-04-28  4:37   ` Eric Dumazet
  2016-04-28 20:06 ` [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Soheil Hassas Yeganeh @ 2016-04-28  3:39 UTC (permalink / raw)
  To: davem, netdev
  Cc: kafai, willemb, edumazet, ycheng, ncardwell,
	Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

The SKBTX_ACK_TSTAMP flag is set in skb_shinfo->tx_flags when
the timestamp of the TCP acknowledgement should be reported on
error queue. Since accessing skb_shinfo is likely to incur a
cache-line miss at the time of receiving the ack, the
txstamp_ack bit was added in tcp_skb_cb, which is set iff
the SKBTX_ACK_TSTAMP flag is set for an skb. This makes
SKBTX_ACK_TSTAMP flag redundant.

Remove the SKBTX_ACK_TSTAMP and instead use the txstamp_ack bit
everywhere.

Note that this frees one bit in shinfo->tx_flags.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Suggested-by: Willem de Bruijn <willemb@google.com>
---
 include/linux/skbuff.h |  6 +-----
 net/ipv4/tcp.c         |  5 +++--
 net/ipv4/tcp_input.c   |  3 +--
 net/ipv4/tcp_output.c  | 17 +++++++++++------
 net/socket.c           |  3 ---
 5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index da0ace3..ae30555 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -382,14 +382,10 @@ enum {
 
 	/* generate software time stamp when entering packet scheduling */
 	SKBTX_SCHED_TSTAMP = 1 << 6,
-
-	/* generate software timestamp on peer data acknowledgment */
-	SKBTX_ACK_TSTAMP = 1 << 7,
 };
 
 #define SKBTX_ANY_SW_TSTAMP	(SKBTX_SW_TSTAMP    | \
-				 SKBTX_SCHED_TSTAMP | \
-				 SKBTX_ACK_TSTAMP)
+				 SKBTX_SCHED_TSTAMP)
 #define SKBTX_ANY_TSTAMP	(SKBTX_HW_TSTAMP | SKBTX_ANY_SW_TSTAMP)
 
 /*
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3c542dc..8e05eb6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -435,9 +435,10 @@ static void tcp_tx_timestamp(struct sock *sk, u16 tsflags, struct sk_buff *skb)
 		struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
 
 		sock_tx_timestamp(sk, tsflags, &shinfo->tx_flags);
-		if (shinfo->tx_flags & SKBTX_ANY_TSTAMP)
+		if (tsflags & SOF_TIMESTAMPING_TX_ACK)
+			tcb->txstamp_ack = 1;
+		if (tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK)
 			shinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1;
-		tcb->txstamp_ack = !!(shinfo->tx_flags & SKBTX_ACK_TSTAMP);
 	}
 }
 
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 967520d..2f3fd92 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3087,8 +3087,7 @@ static void tcp_ack_tstamp(struct sock *sk, struct sk_buff *skb,
 		return;
 
 	shinfo = skb_shinfo(skb);
-	if ((shinfo->tx_flags & SKBTX_ACK_TSTAMP) &&
-	    !before(shinfo->tskey, prior_snd_una) &&
+	if (!before(shinfo->tskey, prior_snd_una) &&
 	    before(shinfo->tskey, tcp_sk(sk)->snd_una))
 		__skb_tstamp_tx(skb, NULL, sk, SCM_TSTAMP_ACK);
 }
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 9d3b4b3..ace183c 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1111,11 +1111,17 @@ static void tcp_adjust_pcount(struct sock *sk, const struct sk_buff *skb, int de
 	tcp_verify_left_out(tp);
 }
 
+static bool tcp_has_tx_tstamp(const struct sk_buff *skb)
+{
+	return TCP_SKB_CB(skb)->txstamp_ack ||
+		(skb_shinfo(skb)->tx_flags & SKBTX_ANY_TSTAMP);
+}
+
 static void tcp_fragment_tstamp(struct sk_buff *skb, struct sk_buff *skb2)
 {
 	struct skb_shared_info *shinfo = skb_shinfo(skb);
 
-	if (unlikely(shinfo->tx_flags & SKBTX_ANY_TSTAMP) &&
+	if (unlikely(tcp_has_tx_tstamp(skb)) &&
 	    !before(shinfo->tskey, TCP_SKB_CB(skb2)->seq)) {
 		struct skb_shared_info *shinfo2 = skb_shinfo(skb2);
 		u8 tsflags = shinfo->tx_flags & SKBTX_ANY_TSTAMP;
@@ -2446,13 +2452,12 @@ u32 __tcp_select_window(struct sock *sk)
 void tcp_skb_collapse_tstamp(struct sk_buff *skb,
 			     const struct sk_buff *next_skb)
 {
-	const struct skb_shared_info *next_shinfo = skb_shinfo(next_skb);
-	u8 tsflags = next_shinfo->tx_flags & SKBTX_ANY_TSTAMP;
-
-	if (unlikely(tsflags)) {
+	if (unlikely(tcp_has_tx_tstamp(next_skb))) {
+		const struct skb_shared_info *next_shinfo =
+			skb_shinfo(next_skb);
 		struct skb_shared_info *shinfo = skb_shinfo(skb);
 
-		shinfo->tx_flags |= tsflags;
+		shinfo->tx_flags |= next_shinfo->tx_flags & SKBTX_ANY_TSTAMP;
 		shinfo->tskey = next_shinfo->tskey;
 		TCP_SKB_CB(skb)->txstamp_ack |=
 			TCP_SKB_CB(next_skb)->txstamp_ack;
diff --git a/net/socket.c b/net/socket.c
index 5dbb0bb..7789d79 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -600,9 +600,6 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags)
 	if (tsflags & SOF_TIMESTAMPING_TX_SCHED)
 		flags |= SKBTX_SCHED_TSTAMP;
 
-	if (tsflags & SOF_TIMESTAMPING_TX_ACK)
-		flags |= SKBTX_ACK_TSTAMP;
-
 	*tx_flags = flags;
 }
 EXPORT_SYMBOL(__sock_tx_timestamp);
-- 
2.8.0.rc3.226.g39d4020

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

* Re: [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp
  2016-04-28  3:39 ` [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp Soheil Hassas Yeganeh
@ 2016-04-28  4:35   ` Eric Dumazet
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2016-04-28  4:35 UTC (permalink / raw)
  To: Soheil Hassas Yeganeh
  Cc: davem, netdev, kafai, willemb, edumazet, ycheng, ncardwell,
	Soheil Hassas Yeganeh

On Wed, 2016-04-27 at 23:39 -0400, Soheil Hassas Yeganeh wrote:
> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> Remove the redundant check for sk->sk_tsflags in tcp_tx_timestamp.
> 
> tcp_tx_timestamp() receives the tsflags as a parameter. As a
> result the "sk->sk_tsflags || tsflags" is redundant, since
> tsflags already includes sk->sk_tsflags plus overrides from
> control messages.
> 
> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
> ---

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

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

* Re: [PATCH v2 net-next 2/2] tcp: remove SKBTX_ACK_TSTAMP since it is redundant
  2016-04-28  3:39 ` [PATCH v2 net-next 2/2] tcp: remove SKBTX_ACK_TSTAMP since it is redundant Soheil Hassas Yeganeh
@ 2016-04-28  4:37   ` Eric Dumazet
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2016-04-28  4:37 UTC (permalink / raw)
  To: Soheil Hassas Yeganeh
  Cc: davem, netdev, kafai, willemb, edumazet, ycheng, ncardwell,
	Soheil Hassas Yeganeh

On Wed, 2016-04-27 at 23:39 -0400, Soheil Hassas Yeganeh wrote:
> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> The SKBTX_ACK_TSTAMP flag is set in skb_shinfo->tx_flags when
> the timestamp of the TCP acknowledgement should be reported on
> error queue. Since accessing skb_shinfo is likely to incur a
> cache-line miss at the time of receiving the ack, the
> txstamp_ack bit was added in tcp_skb_cb, which is set iff
> the SKBTX_ACK_TSTAMP flag is set for an skb. This makes
> SKBTX_ACK_TSTAMP flag redundant.
> 
> Remove the SKBTX_ACK_TSTAMP and instead use the txstamp_ack bit
> everywhere.
> 
> Note that this frees one bit in shinfo->tx_flags.
> 
> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
> Acked-by: Martin KaFai Lau <kafai@fb.com>
> Suggested-by: Willem de Bruijn <willemb@google.com>
> ---

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

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

* Re: [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps
  2016-04-28  3:38 [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps Soheil Hassas Yeganeh
  2016-04-28  3:39 ` [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp Soheil Hassas Yeganeh
  2016-04-28  3:39 ` [PATCH v2 net-next 2/2] tcp: remove SKBTX_ACK_TSTAMP since it is redundant Soheil Hassas Yeganeh
@ 2016-04-28 20:06 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-04-28 20:06 UTC (permalink / raw)
  To: soheil.kdev; +Cc: netdev, kafai, willemb, edumazet, ycheng, ncardwell, soheil

From: Soheil Hassas Yeganeh <soheil.kdev@gmail.com>
Date: Wed, 27 Apr 2016 23:38:59 -0400

> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> v2:
> - Fully remove SKBTX_ACK_TSTAMP, as suggested by Willem de Bruijn.
> 
> This patch series aims at removing redundant checks and fields
> for ack timestamps for TCP.

Series applied, thank you.

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

end of thread, other threads:[~2016-04-28 20:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28  3:38 [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps Soheil Hassas Yeganeh
2016-04-28  3:39 ` [PATCH v2 net-next 1/2] tcp: remove an unnecessary check in tcp_tx_timestamp Soheil Hassas Yeganeh
2016-04-28  4:35   ` Eric Dumazet
2016-04-28  3:39 ` [PATCH v2 net-next 2/2] tcp: remove SKBTX_ACK_TSTAMP since it is redundant Soheil Hassas Yeganeh
2016-04-28  4:37   ` Eric Dumazet
2016-04-28 20:06 ` [PATCH v2 net-next 0/2] tcp: simplify ack tx timestamps 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.