aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-09-21 19:29:31 -0400
committerDavid Howells <dhowells@redhat.com>2016-09-22 03:49:20 -0400
commit0d4b103c008ac9f6f438d2618c155f6e868e5a67 (patch)
tree24c1d4a63195cca1ca1398ca5501d61a1df6919c
parent50235c4b5a2fb9a9690f02cd1dea6ca047d7f79e (diff)
rxrpc: Reduce the number of ACK-Requests sent
Reduce the number of ACK-Requests we set on DATA packets that we're sending to reduce network traffic. We set the flag on odd-numbered DATA packets to start off the RTT cache until we have at least three entries in it and then probe once per second thereafter to keep it topped up. This could be made tunable in future. Note that from this point, the RXRPC_REQUEST_ACK flag is set on DATA packets as we transmit them and not stored statically in the sk_buff. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--net/rxrpc/ar-internal.h1
-rw-r--r--net/rxrpc/output.c13
-rw-r--r--net/rxrpc/peer_object.c1
-rw-r--r--net/rxrpc/sendmsg.c2
4 files changed, 13 insertions, 4 deletions
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 1c4597b2c6cd..b13754a6dd7a 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -255,6 +255,7 @@ struct rxrpc_peer {
255 255
256 /* calculated RTT cache */ 256 /* calculated RTT cache */
257#define RXRPC_RTT_CACHE_SIZE 32 257#define RXRPC_RTT_CACHE_SIZE 32
258 ktime_t rtt_last_req; /* Time of last RTT request */
258 u64 rtt; /* Current RTT estimate (in nS) */ 259 u64 rtt; /* Current RTT estimate (in nS) */
259 u64 rtt_sum; /* Sum of cache contents */ 260 u64 rtt_sum; /* Sum of cache contents */
260 u64 rtt_cache[RXRPC_RTT_CACHE_SIZE]; /* Determined RTT cache */ 261 u64 rtt_cache[RXRPC_RTT_CACHE_SIZE]; /* Determined RTT cache */
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index db01fbb70d23..282cb1e36d06 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -270,6 +270,12 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb)
270 msg.msg_controllen = 0; 270 msg.msg_controllen = 0;
271 msg.msg_flags = 0; 271 msg.msg_flags = 0;
272 272
273 /* If our RTT cache needs working on, request an ACK. */
274 if ((call->peer->rtt_usage < 3 && sp->hdr.seq & 1) ||
275 ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000),
276 ktime_get_real()))
277 whdr.flags |= RXRPC_REQUEST_ACK;
278
273 if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) { 279 if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
274 static int lose; 280 static int lose;
275 if ((lose++ & 7) == 7) { 281 if ((lose++ & 7) == 7) {
@@ -301,11 +307,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb)
301 307
302done: 308done:
303 if (ret >= 0) { 309 if (ret >= 0) {
304 skb->tstamp = ktime_get_real(); 310 ktime_t now = ktime_get_real();
311 skb->tstamp = now;
305 smp_wmb(); 312 smp_wmb();
306 sp->hdr.serial = serial; 313 sp->hdr.serial = serial;
307 if (whdr.flags & RXRPC_REQUEST_ACK) 314 if (whdr.flags & RXRPC_REQUEST_ACK) {
315 call->peer->rtt_last_req = now;
308 trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, serial); 316 trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, serial);
317 }
309 } 318 }
310 _leave(" = %d [%u]", ret, call->peer->maxdata); 319 _leave(" = %d [%u]", ret, call->peer->maxdata);
311 return ret; 320 return ret;
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index f3e5766910fd..941b724d523b 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -244,6 +244,7 @@ static void rxrpc_init_peer(struct rxrpc_peer *peer, unsigned long hash_key)
244 peer->hash_key = hash_key; 244 peer->hash_key = hash_key;
245 rxrpc_assess_MTU_size(peer); 245 rxrpc_assess_MTU_size(peer);
246 peer->mtu = peer->if_mtu; 246 peer->mtu = peer->if_mtu;
247 peer->rtt_last_req = ktime_get_real();
247 248
248 switch (peer->srx.transport.family) { 249 switch (peer->srx.transport.family) {
249 case AF_INET: 250 case AF_INET:
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 607223f4f871..ca7c3be60ad2 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -299,8 +299,6 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
299 else if (call->tx_top - call->tx_hard_ack < 299 else if (call->tx_top - call->tx_hard_ack <
300 call->tx_winsize) 300 call->tx_winsize)
301 sp->hdr.flags |= RXRPC_MORE_PACKETS; 301 sp->hdr.flags |= RXRPC_MORE_PACKETS;
302 if (seq & 1)
303 sp->hdr.flags |= RXRPC_REQUEST_ACK;
304 302
305 ret = conn->security->secure_packet( 303 ret = conn->security->secure_packet(
306 call, skb, skb->mark, skb->head); 304 call, skb, skb->mark, skb->head);