Skip to content

Commit 344b0d8

Browse files
dhowellsgregkh
authored andcommitted
rxrpc: Unlock new call in rxrpc_new_incoming_call() rather than the caller
[ Upstream commit f33121c ] 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>
1 parent f54802b commit 344b0d8

2 files changed

Lines changed: 28 additions & 26 deletions

File tree

net/rxrpc/call_accept.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx)
239239
kfree(b);
240240
}
241241

242+
/*
243+
* Ping the other end to fill our RTT cache and to retrieve the rwind
244+
* and MTU parameters.
245+
*/
246+
static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)
247+
{
248+
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
249+
ktime_t now = skb->tstamp;
250+
251+
if (call->peer->rtt_usage < 3 ||
252+
ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now))
253+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
254+
true, true,
255+
rxrpc_propose_ack_ping_for_params);
256+
}
257+
242258
/*
243259
* Allocate a new incoming call from the prealloc pool, along with a connection
244260
* and a peer as necessary.
@@ -346,9 +362,7 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
346362
sp->hdr.seq, RX_INVALID_OPERATION, ESHUTDOWN);
347363
skb->mark = RXRPC_SKB_MARK_REJECT_ABORT;
348364
skb->priority = RX_INVALID_OPERATION;
349-
_leave(" = NULL [close]");
350-
call = NULL;
351-
goto out;
365+
goto no_call;
352366
}
353367

354368
/* 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,
361375
call = rxrpc_alloc_incoming_call(rx, local, peer, conn, skb);
362376
if (!call) {
363377
skb->mark = RXRPC_SKB_MARK_REJECT_BUSY;
364-
_leave(" = NULL [busy]");
365-
call = NULL;
366-
goto out;
378+
goto no_call;
367379
}
368380

369381
trace_rxrpc_receive(call, rxrpc_receive_incoming,
@@ -432,10 +444,18 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
432444
*/
433445
rxrpc_put_call(call, rxrpc_call_put);
434446

435-
_leave(" = %p{%d}", call, call->debug_id);
436-
out:
437447
spin_unlock(&rx->incoming_lock);
448+
449+
rxrpc_send_ping(call, skb);
450+
mutex_unlock(&call->user_mutex);
451+
452+
_leave(" = %p{%d}", call, call->debug_id);
438453
return call;
454+
455+
no_call:
456+
spin_unlock(&rx->incoming_lock);
457+
_leave(" = NULL [%u]", skb->mark);
458+
return NULL;
439459
}
440460

441461
/*

net/rxrpc/input.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,6 @@ static void rxrpc_congestion_management(struct rxrpc_call *call,
192192
goto out_no_clear_ca;
193193
}
194194

195-
/*
196-
* Ping the other end to fill our RTT cache and to retrieve the rwind
197-
* and MTU parameters.
198-
*/
199-
static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)
200-
{
201-
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
202-
ktime_t now = skb->tstamp;
203-
204-
if (call->peer->rtt_usage < 3 ||
205-
ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now))
206-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
207-
true, true,
208-
rxrpc_propose_ack_ping_for_params);
209-
}
210-
211195
/*
212196
* Apply a hard ACK by advancing the Tx window.
213197
*/
@@ -1396,8 +1380,6 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
13961380
call = rxrpc_new_incoming_call(local, rx, skb);
13971381
if (!call)
13981382
goto reject_packet;
1399-
rxrpc_send_ping(call, skb);
1400-
mutex_unlock(&call->user_mutex);
14011383
}
14021384

14031385
/* Process a call packet; this either discards or passes on the ref

0 commit comments

Comments
 (0)