All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.4 06/26] rxrpc: Unlock new call in rxrpc_new_incoming_call() rather than the caller
@ 2020-01-10 22:04 Sasha Levin
  2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 07/26] rxrpc: Don't take call->user_mutex in rxrpc_new_incoming_call() Sasha Levin
                   ` (19 more replies)
  0 siblings, 20 replies; 25+ messages in thread
From: Sasha Levin @ 2020-01-10 22:04 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: David Howells, Peter Zijlstra, Ingo Molnar, Will Deacon,
	Davidlohr Bueso, Sasha Levin, linux-afs, netdev

From: David Howells <dhowells@redhat.com>

[ Upstream commit f33121cbe91973a08e68e4bde8c3f7e6e4e351c1 ]

Move the unlock and the ping transmission for a new incoming call into
rxrpc_new_incoming_call() rather than doing it in the caller.  This makes
it clearer to see what's going on.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
cc: Ingo Molnar <mingo@redhat.com>
cc: Will Deacon <will@kernel.org>
cc: Davidlohr Bueso <dave@stgolabs.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/rxrpc/call_accept.c | 36 ++++++++++++++++++++++++++++--------
 net/rxrpc/input.c       | 18 ------------------
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index 135bf5cd8dd5..3685b1732f65 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -239,6 +239,22 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx)
 	kfree(b);
 }
 
+/*
+ * Ping the other end to fill our RTT cache and to retrieve the rwind
+ * and MTU parameters.
+ */
+static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)
+{
+	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
+	ktime_t now = skb->tstamp;
+
+	if (call->peer->rtt_usage < 3 ||
+	    ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now))
+		rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
+				  true, true,
+				  rxrpc_propose_ack_ping_for_params);
+}
+
 /*
  * Allocate a new incoming call from the prealloc pool, along with a connection
  * and a peer as necessary.
@@ -346,9 +362,7 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
 				  sp->hdr.seq, RX_INVALID_OPERATION, ESHUTDOWN);
 		skb->mark = RXRPC_SKB_MARK_REJECT_ABORT;
 		skb->priority = RX_INVALID_OPERATION;
-		_leave(" = NULL [close]");
-		call = NULL;
-		goto out;
+		goto no_call;
 	}
 
 	/* The peer, connection and call may all have sprung into existence due
@@ -361,9 +375,7 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
 	call = rxrpc_alloc_incoming_call(rx, local, peer, conn, skb);
 	if (!call) {
 		skb->mark = RXRPC_SKB_MARK_REJECT_BUSY;
-		_leave(" = NULL [busy]");
-		call = NULL;
-		goto out;
+		goto no_call;
 	}
 
 	trace_rxrpc_receive(call, rxrpc_receive_incoming,
@@ -432,10 +444,18 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
 	 */
 	rxrpc_put_call(call, rxrpc_call_put);
 
-	_leave(" = %p{%d}", call, call->debug_id);
-out:
 	spin_unlock(&rx->incoming_lock);
+
+	rxrpc_send_ping(call, skb);
+	mutex_unlock(&call->user_mutex);
+
+	_leave(" = %p{%d}", call, call->debug_id);
 	return call;
+
+no_call:
+	spin_unlock(&rx->incoming_lock);
+	_leave(" = NULL [%u]", skb->mark);
+	return NULL;
 }
 
 /*
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 157be1ff8697..86bd133b4fa0 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -192,22 +192,6 @@ static void rxrpc_congestion_management(struct rxrpc_call *call,
 	goto out_no_clear_ca;
 }
 
-/*
- * Ping the other end to fill our RTT cache and to retrieve the rwind
- * and MTU parameters.
- */
-static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)
-{
-	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
-	ktime_t now = skb->tstamp;
-
-	if (call->peer->rtt_usage < 3 ||
-	    ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now))
-		rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
-				  true, true,
-				  rxrpc_propose_ack_ping_for_params);
-}
-
 /*
  * Apply a hard ACK by advancing the Tx window.
  */
@@ -1396,8 +1380,6 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
 		call = rxrpc_new_incoming_call(local, rx, skb);
 		if (!call)
 			goto reject_packet;
-		rxrpc_send_ping(call, skb);
-		mutex_unlock(&call->user_mutex);
 	}
 
 	/* Process a call packet; this either discards or passes on the ref
-- 
2.20.1


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

end of thread, other threads:[~2020-01-10 22:08 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 22:04 [PATCH AUTOSEL 5.4 06/26] rxrpc: Unlock new call in rxrpc_new_incoming_call() rather than the caller Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 07/26] rxrpc: Don't take call->user_mutex in rxrpc_new_incoming_call() Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 08/26] rxrpc: Fix missing security check on incoming calls Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 09/26] dmaengine: k3dma: Avoid null pointer traversal Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 10/26] s390/qeth: fix qdio teardown after early init error Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 11/26] s390/qeth: lock the card while changing its hsuid Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 12/26] s390/qeth: fix false reporting of VNIC CHAR config failure Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 13/26] s390/qeth: Fix vnicc_is_in_use if rx_bcast not set Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 14/26] s390/qeth: vnicc Fix init to default Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 15/26] s390/qeth: fix initialization on old HW Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 16/26] hsr: add hsr root debugfs directory Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 17/26] hsr: rename debugfs file when interface name is changed Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 18/26] hsr: reset network header when supervision frame is created Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 19/26] ioat: ioat_alloc_ring() failure handling Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 20/26] drm/amdgpu: enable gfxoff for raven1 refresh Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 21/26] hsr: fix slab-out-of-bounds Read in hsr_debugfs_rename() Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 22/26] media: intel-ipu3: Align struct ipu3_uapi_awb_fr_config_s to 32 bytes Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 23/26] kbuild/deb-pkg: annotate libelf-dev dependency as :native Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 24/26] hexagon: parenthesize registers in asm predicates Sasha Levin
2020-01-10 22:05   ` Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 25/26] hexagon: work around compiler crash Sasha Levin
2020-01-10 22:05 ` [PATCH AUTOSEL 5.4 26/26] ocfs2: call journal flush to mark journal as empty after journal recovery when mount Sasha Levin

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.