mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: netdev@vger.kernel.org
Cc: dhowells@redhat.com, linux-afs@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 08/12] rxrpc: Express protocol timeouts in terms of RTT
Date: Fri, 24 Nov 2017 14:38:34 +0000	[thread overview]
Message-ID: <151153431476.27205.85643049306636998.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <151153425958.27205.13734959199482172941.stgit@warthog.procyon.org.uk>

Express protocol timeouts for data retransmission and deferred ack
generation in terms on RTT rather than specified timeouts once we have
sufficient RTT samples.

For the moment, this requires just one RTT sample to be able to use this
for ack deferral and two for data retransmission.

The data retransmission timeout is set at RTT*1.5 and the ACK deferral
timeout is set at RTT.

Note that the calculated timeout is limited to a minimum of 4ns to make
sure it doesn't happen too quickly.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/rxrpc/call_event.c |   22 ++++++++++++++++++----
 net/rxrpc/sendmsg.c    |    7 +++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index c14395d5ad8c..da91f16ac77c 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -52,7 +52,7 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
 				enum rxrpc_propose_ack_trace why)
 {
 	enum rxrpc_propose_ack_outcome outcome = rxrpc_propose_ack_use;
-	unsigned long now, ack_at, expiry = rxrpc_soft_ack_delay;
+	unsigned long expiry = rxrpc_soft_ack_delay;
 	s8 prior = rxrpc_ack_priority[ack_reason];
 
 	/* Pings are handled specially because we don't want to accidentally
@@ -116,7 +116,13 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
 		    background)
 			rxrpc_queue_call(call);
 	} else {
-		now = jiffies;
+		unsigned long now = jiffies, ack_at;
+
+		if (call->peer->rtt_usage > 0)
+			ack_at = nsecs_to_jiffies(call->peer->rtt);
+		else
+			ack_at = expiry;
+
 		ack_at = jiffies + expiry;
 		if (time_before(ack_at, call->ack_at)) {
 			WRITE_ONCE(call->ack_at, ack_at);
@@ -160,14 +166,22 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j)
 	struct sk_buff *skb;
 	unsigned long resend_at;
 	rxrpc_seq_t cursor, seq, top;
-	ktime_t now, max_age, oldest, ack_ts;
+	ktime_t now, max_age, oldest, ack_ts, timeout, min_timeo;
 	int ix;
 	u8 annotation, anno_type, retrans = 0, unacked = 0;
 
 	_enter("{%d,%d}", call->tx_hard_ack, call->tx_top);
 
+	if (call->peer->rtt_usage > 1)
+		timeout = ns_to_ktime(call->peer->rtt * 3 / 2);
+	else
+		timeout = ms_to_ktime(rxrpc_resend_timeout);
+	min_timeo = ns_to_ktime((1000000000 / HZ) * 4);
+	if (ktime_before(timeout, min_timeo))
+		timeout = min_timeo;
+
 	now = ktime_get_real();
-	max_age = ktime_sub_ms(now, rxrpc_resend_timeout * 1000 / HZ);
+	max_age = ktime_sub(now, timeout);
 
 	spin_lock_bh(&call->lock);
 
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 03e0676db28c..c56ee54fdd1f 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -226,6 +226,13 @@ static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
 	} else {
 		unsigned long now = jiffies, resend_at;
 
+		if (call->peer->rtt_usage > 1)
+			resend_at = nsecs_to_jiffies(call->peer->rtt * 3 / 2);
+		else
+			resend_at = rxrpc_resend_timeout;
+		if (resend_at < 1)
+			resend_at = 1;
+
 		resend_at = now + rxrpc_resend_timeout;
 		WRITE_ONCE(call->resend_at, resend_at);
 		rxrpc_reduce_call_timer(call, resend_at, now,

  parent reply	other threads:[~2017-11-24 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 14:37 [PATCH net-next 00/12] rxrpc: Fixes and improvements David Howells
2017-11-24 14:37 ` [PATCH net-next 01/12] rxrpc: The mutex lock returned by rxrpc_accept_call() needs releasing David Howells
2017-11-24 14:37 ` [PATCH net-next 02/12] rxrpc: Don't set upgrade by default in sendmsg() David Howells
2017-11-24 14:38 ` [PATCH net-next 03/12] rxrpc: Provide a different lockdep key for call->user_mutex for kernel calls David Howells
2017-11-24 14:38 ` [PATCH net-next 04/12] rxrpc: Delay terminal ACK transmission on a client call David Howells
2017-11-24 14:38 ` [PATCH net-next 05/12] rxrpc: Split the call params from the operation params David Howells
2017-11-24 14:38 ` [PATCH net-next 06/12] rxrpc: Fix call timeouts David Howells
2017-11-24 14:38 ` [PATCH net-next 07/12] rxrpc: Don't transmit DELAY ACKs immediately on proposal David Howells
2017-11-24 14:38 ` David Howells [this message]
2017-11-24 14:38 ` [PATCH net-next 09/12] rxrpc: Add a timeout for detecting lost ACKs/lost DATA David Howells
2017-11-24 14:38 ` [PATCH net-next 10/12] rxrpc: Add keepalive for a call David Howells
2017-11-24 14:38 ` [PATCH net-next 11/12] rxrpc: Fix service endpoint expiry David Howells
2017-11-24 14:39 ` [PATCH net-next 12/12] rxrpc: Fix conn expiry timers David Howells
2017-11-24 20:05 ` [PATCH net-next 00/12] rxrpc: Fixes and improvements David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151153431476.27205.85643049306636998.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®