FAILED: patch "[PATCH] rxrpc: Fix irq-disabled in local_bh_enable()" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x e4d2878369d590bf8455e3678a644e503172eafa
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026073013-sanding-unlined-9b91@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e4d2878369d590bf8455e3678a644e503172eafa Mon Sep 17 00:00:00 2001
From: David Howells <[email protected]>
Date: Thu, 17 Jul 2025 08:43:41 +0100
Subject: [PATCH] rxrpc: Fix irq-disabled in local_bh_enable()
The rxrpc_assess_MTU_size() function calls down into the IP layer to find out the MTU size for a route. When accepting an incoming call, this is called from rxrpc_new_incoming_call() which holds interrupts disabled across the code that calls down to it. Unfortunately, the IP layer uses local_bh_enable() which, config dependent, throws a warning if IRQs are enabled:
WARNING: CPU: 1 PID: 5544 at kernel/softirq.c:387 __local_bh_enable_ip+0x43/0xd0 ... RIP: 0010:__local_bh_enable_ip+0x43/0xd0 ... Call Trace: <TASK> rt_cache_route+0x7e/0xa0 rt_set_nexthop.isra.0+0x3b3/0x3f0 __mkroute_output+0x43a/0x460 ip_route_output_key_hash+0xf7/0x140 ip_route_output_flow+0x1b/0x90 rxrpc_assess_MTU_size.isra.0+0x2a0/0x590 rxrpc_new_incoming_peer+0x46/0x120 rxrpc_alloc_incoming_call+0x1b1/0x400 rxrpc_new_incoming_call+0x1da/0x5e0 rxrpc_input_packet+0x827/0x900 rxrpc_io_thread+0x403/0xb60 kthread+0x2f7/0x310 ret_from_fork+0x2a/0x230 ret_from_fork_asm+0x1a/0x30 ... hardirqs last enabled at (23): _raw_spin_unlock_irq+0x24/0x50 hardirqs last disabled at (24): _raw_read_lock_irq+0x17/0x70 softirqs last enabled at (0): copy_process+0xc61/0x2730 softirqs last disabled at (25): rt_add_uncached_list+0x3c/0x90
Fix this by moving the call to rxrpc_assess_MTU_size() out of rxrpc_init_peer() and further up the stack where it can be done without interrupts disabled.
It shouldn't be a problem for rxrpc_new_incoming_call() to do it after the locks are dropped as pmtud is going to be performed by the I/O thread - and we're in the I/O thread at this point.
net/rxrpc/ar-internal.h +1 -0
@@ -1383,6 +1383,7 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *, const struct sockaddr_rxrpc *);struct rxrpc_peer *rxrpc_lookup_peer (struct rxrpc_local *local,struct sockaddr_rxrpc *srx,gfp_t gfp); +void rxrpc_assess_MTU_size (struct rxrpc_local *local,struct rxrpc_peer *peer);struct rxrpc_peer *rxrpc_alloc_peer (struct rxrpc_local *,gfp_t ,enum rxrpc_peer_trace );void rxrpc_new_incoming_peer (struct rxrpc_local *local,struct rxrpc_peer *peer);
net/rxrpc/call_accept.c +1 -0
@@ -406,6 +406,7 @@ bool rxrpc_new_incoming_call(struct rxrpc_local *local,spin_unlock (&rx->incoming_lock);read_unlock_irq (&local->services_lock); +rxrpc_assess_MTU_size (local, call->peer);if (hlist_unhashed (&call->error_link)) {spin_lock_irq (&call->peer->lock);
net/rxrpc/peer_object.c +2 -4
@@ -149,8 +149,7 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *local,* assess the MTU size for the network interface through which this peer is * reached */ -static void rxrpc_assess_MTU_size (struct rxrpc_local *local, -struct rxrpc_peer *peer) +void rxrpc_assess_MTU_size (struct rxrpc_local *local,struct rxrpc_peer *peer) {struct net *net = local->net;struct dst_entry *dst;
@@ -277,8 +276,6 @@ static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, peer->hdrsize +=sizeof (struct rxrpc_wire_header ); peer->max_data = peer->if_mtu - peer->hdrsize; - -rxrpc_assess_MTU_size (local, peer); }/*
@@ -297,6 +294,7 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local,if (peer) {memcpy (&peer->srx, srx,sizeof (*srx));rxrpc_init_peer (local, peer, hash_key); +rxrpc_assess_MTU_size (local, peer); }_leave (" = %p" , peer);
Sasha Levin
maintainerPATCH 1/1 rxrpc: Fix irq-disabled in local_bh_enable()
From: David Howells <[email protected]>
[ Upstream commit e4d2878369d590bf8455e3678a644e503172eafa ]
The rxrpc_assess_MTU_size() function calls down into the IP layer to find out the MTU size for a route. When accepting an incoming call, this is called from rxrpc_new_incoming_call() which holds interrupts disabled across the code that calls down to it. Unfortunately, the IP layer uses local_bh_enable() which, config dependent, throws a warning if IRQs are enabled:
WARNING: CPU: 1 PID: 5544 at kernel/softirq.c:387 __local_bh_enable_ip+0x43/0xd0 ... RIP: 0010:__local_bh_enable_ip+0x43/0xd0 ... Call Trace: <TASK> rt_cache_route+0x7e/0xa0 rt_set_nexthop.isra.0+0x3b3/0x3f0 __mkroute_output+0x43a/0x460 ip_route_output_key_hash+0xf7/0x140 ip_route_output_flow+0x1b/0x90 rxrpc_assess_MTU_size.isra.0+0x2a0/0x590 rxrpc_new_incoming_peer+0x46/0x120 rxrpc_alloc_incoming_call+0x1b1/0x400 rxrpc_new_incoming_call+0x1da/0x5e0 rxrpc_input_packet+0x827/0x900 rxrpc_io_thread+0x403/0xb60 kthread+0x2f7/0x310 ret_from_fork+0x2a/0x230 ret_from_fork_asm+0x1a/0x30 ... hardirqs last enabled at (23): _raw_spin_unlock_irq+0x24/0x50 hardirqs last disabled at (24): _raw_read_lock_irq+0x17/0x70 softirqs last enabled at (0): copy_process+0xc61/0x2730 softirqs last disabled at (25): rt_add_uncached_list+0x3c/0x90
Fix this by moving the call to rxrpc_assess_MTU_size() out of rxrpc_init_peer() and further up the stack where it can be done without interrupts disabled.
It shouldn't be a problem for rxrpc_new_incoming_call() to do it after the locks are dropped as pmtud is going to be performed by the I/O thread - and we're in the I/O thread at this point.
--- net/rxrpc/ar-internal.h | 1 + net/rxrpc/call_accept.c | 1 + net/rxrpc/peer_object.c | 12 +++++++----- 3 files changed, 9 insertions(+), 5 deletions(-)
net/rxrpc/ar-internal.h +1 -0
@@ -1180,6 +1180,7 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *, const struct sockaddr_rxrpc *);struct rxrpc_peer *rxrpc_lookup_peer (struct rxrpc_local *local,struct sockaddr_rxrpc *srx,gfp_t gfp); +void rxrpc_assess_MTU_size (struct rxrpc_local *local,struct rxrpc_peer *peer);struct rxrpc_peer *rxrpc_alloc_peer (struct rxrpc_local *,gfp_t ,enum rxrpc_peer_trace );void rxrpc_new_incoming_peer (struct rxrpc_local *local,struct rxrpc_peer *peer);
net/rxrpc/call_accept.c +1 -0
@@ -407,6 +407,7 @@ bool rxrpc_new_incoming_call(struct rxrpc_local *local,spin_unlock (&rx->incoming_lock);read_unlock_irq (&local->services_lock); +rxrpc_assess_MTU_size (local, call->peer);if (hlist_unhashed (&call->error_link)) {spin_lock_irq (&call->peer->lock);
net/rxrpc/peer_object.c +7 -5
@@ -149,8 +149,7 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *local,* assess the MTU size for the network interface through which this peer is * reached */ -static void rxrpc_assess_MTU_size (struct rxrpc_local *local, -struct rxrpc_peer *peer) +void rxrpc_assess_MTU_size (struct rxrpc_local *local,struct rxrpc_peer *peer) {struct net *net = local->net;struct dst_entry *dst;
@@ -162,6 +161,8 @@ static void rxrpc_assess_MTU_size(struct rxrpc_local *local,#endif peer->if_mtu =1500 ; + peer->mtu = peer->if_mtu; + peer->maxdata = peer->mtu - peer->hdrsize;memset (&fl,0 ,sizeof (fl));switch (peer->srx.transport.family) {
@@ -201,6 +202,9 @@ static void rxrpc_assess_MTU_size(struct rxrpc_local *local, peer->if_mtu =dst_mtu (dst);dst_release (dst); + peer->mtu = peer->if_mtu; + peer->maxdata = peer->mtu - peer->hdrsize; +_leave (" [if_mtu %u]" , peer->if_mtu); }
@@ -242,8 +246,6 @@ static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, unsigned long hash_key) { peer->hash_key = hash_key; -rxrpc_assess_MTU_size (local, peer); - peer->mtu = peer->if_mtu; peer->rtt_last_req =ktime_get_real ();switch (peer->srx.transport.family) {
@@ -268,7 +270,6 @@ static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, } peer->hdrsize +=sizeof (struct rxrpc_wire_header ); - peer->maxdata = peer->mtu - peer->hdrsize; }/*
@@ -287,6 +288,7 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local,if (peer) {memcpy (&peer->srx, srx,sizeof (*srx));rxrpc_init_peer (local, peer, hash_key); +rxrpc_assess_MTU_size (local, peer); }_leave (" = %p" , peer);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/5 rxrpc: Generate rtt_min
In reply to [email protected]From: David Howells <[email protected]>
[ Upstream commit c637bd066841de6d0a204898a62f1d9bb8fa1b7f ]
Generate rtt_min as this is required by RACK-TLP.
Stable-dep-of: e4d2878369d5 ("rxrpc: Fix irq-disabled in local_bh_enable()")
--- lib/win_minmax.c | 1 + net/rxrpc/ar-internal.h | 2 ++ net/rxrpc/rtt.c | 20 ++++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-)
lib/win_minmax.c +1 -0
@@ -97,3 +97,4 @@ u32 minmax_running_min(struct minmax *m, u32 win, u32 t, u32 meas)return minmax_subwin_update (m, win, &val); } +EXPORT_SYMBOL (minmax_running_min);
net/rxrpc/ar-internal.h +2 -0
@@ -349,6 +349,8 @@ struct rxrpc_peer {spinlock_t rtt_input_lock;/* RTT lock for input routine */ ktime_t rtt_last_req;/* Time of last RTT request */ unsigned int rtt_count;/* Number of samples we've got */ +unsigned int rtt_taken;/* Number of samples taken (wrapping) */ +struct minmax min_rtt;/* Estimated minimum RTT */ u32 srtt_us;/* smoothed round trip time << 3 in usecs */ u32 mdev_us;/* medium deviation */
net/rxrpc/rtt.c +16 -4
@@ -127,16 +127,27 @@ static void rxrpc_set_rto(struct rxrpc_peer *peer) peer->rto_us =rxrpc_bound_rto (rto); } -static void rxrpc_ack_update_rtt (struct rxrpc_peer *peer,long rtt_us) +static void rxrpc_update_rtt_min (struct rxrpc_peer *peer,ktime_t resp_time,long rtt_us) +{ +/* Window size 5mins in approx usec (ipv4.sysctl_tcp_min_rtt_wlen) */ +u32 wlen_us =5ULL *NSEC_PER_SEC /1024 ; + +minmax_running_min (&peer->min_rtt, wlen_us, resp_time /1024 , + (u32 )rtt_us ? :jiffies_to_usecs (1 )); +} + +static void rxrpc_ack_update_rtt (struct rxrpc_peer *peer,ktime_t resp_time,long rtt_us) {if (rtt_us <0 )return ; -//rxrpc_update_rtt_min(peer, rtt_us); +/* Update RACK min RTT [RFC8985 6.1 Step 1]. */ +rxrpc_update_rtt_min (peer, resp_time, rtt_us); +rxrpc_rtt_estimator (peer, rtt_us);rxrpc_set_rto (peer); -/* RFC6298: only reset backoff on valid RTT measurement. */ +/* Only reset backoff on valid RTT measurement [RFC6298]. */ peer->backoff =0 ; }
@@ -157,9 +168,10 @@ void rxrpc_peer_add_rtt(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,return ;spin_lock (&peer->rtt_input_lock); -rxrpc_ack_update_rtt (peer, rtt_us); +rxrpc_ack_update_rtt (peer, resp_time, rtt_us);if (peer->rtt_count <3 ) peer->rtt_count++; + peer->rtt_taken++;spin_unlock (&peer->rtt_input_lock); trace_rxrpc_rtt_rx(call, why, rtt_slot, send_serial, resp_serial,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/5 rxrpc: Adjust the rxrpc_rtt_rx tracepoint
From: David Howells <[email protected]>
[ Upstream commit 93dfca65a1df42a3c8b1094299dc42ab8f18e5c8 ]
Adjust the rxrpc_rtt_rx tracepoint in the following ways:
(1) Display the collected RTT sample in the rxrpc_rtt_rx trace.
(2) Move the division of srtt by 8 to the TP_printk() rather doing it before invoking the trace point.
(3) Display the min_rtt value.
Stable-dep-of: e4d2878369d5 ("rxrpc: Fix irq-disabled in local_bh_enable()")
--- include/trace/events/rxrpc.h | 14 ++++++++++---- net/rxrpc/input.c | 4 ++-- net/rxrpc/rtt.c | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-)
include/trace/events/rxrpc.h +10 -4
@@ -1308,9 +1308,9 @@ TRACE_EVENT(rxrpc_rtt_rx, TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why, int slot, rxrpc_serial_t send_serial, rxrpc_serial_t resp_serial, - u32 rtt, u32 rto), + u32 rtt, u32 srtt, u32 rto), -TP_ARGS (call, why, slot, send_serial, resp_serial, rtt, rto), +TP_ARGS (call, why, slot, send_serial, resp_serial, rtt, srtt, rto),TP_STRUCT__entry ( __field(unsigned int, call)
@@ -1319,7 +1319,9 @@ TRACE_EVENT(rxrpc_rtt_rx, __field(rxrpc_serial_t, send_serial) __field(rxrpc_serial_t, resp_serial) __field(u32, rtt) + __field(u32, srtt) __field(u32, rto) +__field (u32, min_rtt) ), TP_fast_assign(
@@ -1329,17 +1331,21 @@ TRACE_EVENT(rxrpc_rtt_rx, __entry->send_serial = send_serial; __entry->resp_serial = resp_serial; __entry->rtt = rtt; + __entry->srtt = srtt; __entry->rto = rto; + __entry->min_rtt =minmax_get (&call->peer->min_rtt) ), -TP_printk ("c=%08x [%d] %s sr=%08x rr=%08x rtt=%u rto=%u" , +TP_printk ("c=%08x [%d] %s sr=%08x rr=%08x rtt=%u srtt=%u rto=%u min=%u" , __entry->call, __entry->slot,__print_symbolic (__entry->why, rxrpc_rtt_rx_traces), __entry->send_serial, __entry->resp_serial, __entry->rtt, - __entry->rto) + __entry->srtt /8 , + __entry->rto, + __entry->min_rtt) ); TRACE_EVENT(rxrpc_timer_set,
net/rxrpc/input.c +2 -2
@@ -674,7 +674,7 @@ static void rxrpc_complete_rtt_probe(struct rxrpc_call *call,*/ if (after (acked_serial, orig_serial)) {trace_rxrpc_rtt_rx (call, rxrpc_rtt_rx_obsolete, i, - orig_serial, acked_serial,0 ,0 ); + orig_serial, acked_serial,0 ,0 ,0 );clear_bit (i +RXRPC_CALL_RTT_PEND_SHIFT , &call->rtt_avail);smp_wmb ();set_bit (i, &call->rtt_avail);
@@ -682,7 +682,7 @@ static void rxrpc_complete_rtt_probe(struct rxrpc_call *call, }if (!matched) -trace_rxrpc_rtt_rx (call, rxrpc_rtt_rx_lost,9 ,0 , acked_serial,0 ,0 ); +trace_rxrpc_rtt_rx (call, rxrpc_rtt_rx_lost,9 ,0 , acked_serial,0 ,0 ,0 ); }/*
net/rxrpc/rtt.c +1 -1
@@ -175,7 +175,7 @@ void rxrpc_peer_add_rtt(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,spin_unlock (&peer->rtt_input_lock);trace_rxrpc_rtt_rx (call, why, rtt_slot, send_serial, resp_serial, - peer->srtt_us >>3 , peer->rto_us); + rtt_us, peer->srtt_us, peer->rto_us); }/*
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/5 rxrpc: Fix the calculation and use of RTO
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 5c0ceba23bb47085d6c9c53bff08a29634ee4e7e ]
Make the following changes to the calculation and use of RTO:
(1) Fix rxrpc_resend() to use the backed-off RTO value obtained by calling rxrpc_get_rto_backoff() rather than extracting the value itself. Without this, it may retransmit packets too early.
(2) The RTO value being similar to the RTT causes a lot of extraneous resends because the RTT doesn't end up taking account of clearing out of the receive queue on the server. Worse, responses to PING-ACKs are made as fast as possible and so are less than the DATA-requested-ACK RTT and so skew the RTT down.
Fix this by putting a lower bound on the RTO by adding 100ms to it and limiting the lower end to 200ms.
Stable-dep-of: e4d2878369d5 ("rxrpc: Fix irq-disabled in local_bh_enable()")
--- net/rxrpc/call_event.c | 3 ++- net/rxrpc/rtt.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
net/rxrpc/call_event.c +2 -1
@@ -71,7 +71,8 @@ void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb)struct rxrpc_skb_priv *sp;struct rxrpc_txbuf *txb;rxrpc_seq_t transmitted = call->tx_transmitted; -ktime_t next_resend =KTIME_MAX , rto =ns_to_ktime (call->peer->rto_us *NSEC_PER_USEC ); +ktime_t next_resend =KTIME_MAX ; +ktime_t rto =rxrpc_get_rto_backoff (call->peer, false);ktime_t resend_at =KTIME_MAX , now, delay;bool unacked = false, did_send = false;unsigned int i;
net/rxrpc/rtt.c +1 -1
@@ -27,7 +27,7 @@ static u32 __rxrpc_set_rto(const struct rxrpc_peer *peer)static u32 rxrpc_bound_rto (u32 rto) { -return min (rto,RXRPC_RTO_MAX ); +return clamp (200000 , rto +100000 ,RXRPC_RTO_MAX ); }/*
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/5 rxrpc: Manage RTT per-call rather than per-peer
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit b40ef2b85a7d117dd323b5910e504899e0a3e7dc ]
Manage the determination of RTT on a per-call (ie. per-RPC op) basis rather than on a per-peer basis, averaging across all calls going to that peer. The problem is that the RTT measurements from the initial packets on a call may be off because the server may do some setting up (such as getting a lock on a file) before accepting the rest of the data in the RPC and, further, the RTT may be affected by server-side file operations, for instance if a large amount of data is being written or read.
Note: When handling the FS.StoreData-type RPCs, for example, the server uses the userStatus field in the header of ACK packets as supplementary flow control to aid in managing this. AF_RXRPC does not yet support this, but it should be added.
Stable-dep-of: e4d2878369d5 ("rxrpc: Fix irq-disabled in local_bh_enable()")
--- include/trace/events/rxrpc.h | 2 +- net/rxrpc/ar-internal.h | 39 ++++++++------- net/rxrpc/call_event.c | 18 +++---- net/rxrpc/call_object.c | 2 + net/rxrpc/input.c | 8 ++-- net/rxrpc/output.c | 14 +++--- net/rxrpc/peer_object.c | 8 +--- net/rxrpc/proc.c | 6 +-- net/rxrpc/rtt.c | 93 ++++++++++++++++++------------------ net/rxrpc/sendmsg.c | 2 +- 10 files changed, 97 insertions(+), 95 deletions(-)
include/trace/events/rxrpc.h +1 -1
@@ -1333,7 +1333,7 @@ TRACE_EVENT(rxrpc_rtt_rx, __entry->rtt = rtt; __entry->srtt = srtt; __entry->rto = rto; - __entry->min_rtt =minmax_get (&call->peer->min_rtt) + __entry->min_rtt =minmax_get (&call->min_rtt) ), TP_printk("c=%08x [%d] %s sr=%08x rr=%08x rtt=%u srtt=%u rto=%u min=%u",
net/rxrpc/ar-internal.h +21 -18
@@ -344,20 +344,9 @@ struct rxrpc_peer {int debug_id;/* debug ID for printks */ struct sockaddr_rxrpc srx;/* remote address */ -/* calculated RTT cache */ -#define RXRPC_RTT_CACHE_SIZE 32 -spinlock_t rtt_input_lock;/* RTT lock for input routine */ -ktime_t rtt_last_req;/* Time of last RTT request */ -unsigned int rtt_count;/* Number of samples we've got */ -unsigned int rtt_taken;/* Number of samples taken (wrapping) */ -struct minmax min_rtt;/* Estimated minimum RTT */ - -u32 srtt_us;/* smoothed round trip time << 3 in usecs */ -u32 mdev_us;/* medium deviation */ -u32 mdev_max_us;/* maximal mdev for the last rtt period */ -u32 rttvar_us;/* smoothed mdev_max */ -u32 rto_us;/* Retransmission timeout in usec */ -u8 backoff;/* Backoff timeout (as shift) */ +/* Calculated RTT cache */ +unsigned int recent_srtt_us; +unsigned int recent_rto_us;u8 cong_ssthresh;/* Congestion slow-start threshold */ };
@@ -742,6 +731,18 @@ struct rxrpc_call {rxrpc_seq_t acks_hard_ack;/* Latest hard-ack point */ rxrpc_seq_t acks_lowest_nak;/* Lowest NACK in the buffer (or ==tx_hard_ack) */ rxrpc_serial_t acks_highest_serial;/* Highest serial number ACK'd */ + +/* Calculated RTT cache */ +ktime_t rtt_last_req;/* Time of last RTT request */ +unsigned int rtt_count;/* Number of samples we've got */ +unsigned int rtt_taken;/* Number of samples taken (wrapping) */ +struct minmax min_rtt;/* Estimated minimum RTT */ +u32 srtt_us;/* smoothed round trip time << 3 in usecs */ +u32 mdev_us;/* medium deviation */ +u32 mdev_max_us;/* maximal mdev for the last rtt period */ +u32 rttvar_us;/* smoothed mdev_max */ +u32 rto_us;/* Retransmission timeout in usec */ +u8 backoff;/* Backoff timeout (as shift) */ };/*
@@ -1222,10 +1223,12 @@ static inline int rxrpc_abort_eproto(struct rxrpc_call *call,/* * rtt.c */ -void rxrpc_peer_add_rtt (struct rxrpc_call *,enum rxrpc_rtt_rx_trace ,int , -rxrpc_serial_t ,rxrpc_serial_t ,ktime_t ,ktime_t ); -ktime_t rxrpc_get_rto_backoff (struct rxrpc_peer *peer,bool retrans); -void rxrpc_peer_init_rtt (struct rxrpc_peer *); +void rxrpc_call_add_rtt (struct rxrpc_call *call,enum rxrpc_rtt_rx_trace why, +int rtt_slot, +rxrpc_serial_t send_serial,rxrpc_serial_t resp_serial, +ktime_t send_time,ktime_t resp_time); +ktime_t rxrpc_get_rto_backoff (struct rxrpc_call *call,bool retrans); +void rxrpc_call_init_rtt (struct rxrpc_call *call);/* * rxkad.c
net/rxrpc/call_event.c +9 -9
@@ -44,8 +44,8 @@ void rxrpc_propose_delay_ACK(struct rxrpc_call *call, rxrpc_serial_t serial,trace_rxrpc_propose_ack (call, why,RXRPC_ACK_DELAY , serial); -if (call->peer->srtt_us) - delay = (call->peer->srtt_us >>3 ) *NSEC_PER_USEC ; +if (call->srtt_us) + delay = (call->srtt_us >>3 ) *NSEC_PER_USEC ;else delay =ms_to_ktime (READ_ONCE (rxrpc_soft_ack_delay));ktime_add_ms (delay, call->tx_backoff);
@@ -72,7 +72,7 @@ void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb)struct rxrpc_txbuf *txb;rxrpc_seq_t transmitted = call->tx_transmitted;ktime_t next_resend =KTIME_MAX ; -ktime_t rto =rxrpc_get_rto_backoff (call->peer, false); +ktime_t rto =rxrpc_get_rto_backoff (call, false);ktime_t resend_at =KTIME_MAX , now, delay;bool unacked = false, did_send = false;unsigned int i;
@@ -174,7 +174,7 @@ void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb) no_further_resend: no_resend:if (resend_at <KTIME_MAX ) { - delay =rxrpc_get_rto_backoff (call->peer, did_send); + delay =rxrpc_get_rto_backoff (call, did_send); resend_at =ktime_add (resend_at, delay);trace_rxrpc_timer_set (call, resend_at - now, rxrpc_timer_trace_resend_reset); }
@@ -189,7 +189,7 @@ void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb)*/ if (!did_send) {ktime_t next_ping =ktime_add_us (call->acks_latest_ts, - call->peer->srtt_us >>3 ); + call->srtt_us >>3 );if (ktime_sub (next_ping, now) <=0 ) rxrpc_send_ACK(call, RXRPC_ACK_PING, 0,
@@ -306,8 +306,8 @@ static void rxrpc_transmit_some_data(struct rxrpc_call *call)*/ static void rxrpc_send_initial_ping (struct rxrpc_call *call) { -if (call->peer->rtt_count <3 || -ktime_before (ktime_add_ms (call->peer->rtt_last_req,1000 ), +if (call->rtt_count <3 || +ktime_before (ktime_add_ms (call->rtt_last_req,1000 ),ktime_get_real ()))rxrpc_send_ACK (call,RXRPC_ACK_PING ,0 , rxrpc_propose_ack_ping_for_params);
@@ -438,10 +438,10 @@ bool rxrpc_input_call_event(struct rxrpc_call *call) rxrpc_propose_ack_rx_idle);if (call->ackr_nr_unacked >2 ) { -if (call->peer->rtt_count <3 ) +if (call->rtt_count <3 )rxrpc_send_ACK (call,RXRPC_ACK_PING ,0 , rxrpc_propose_ack_ping_for_rtt); -else if (ktime_before (ktime_add_ms (call->peer->rtt_last_req,1000 ), +else if (ktime_before (ktime_add_ms (call->rtt_last_req,1000 ),ktime_get_real ()))rxrpc_send_ACK (call,RXRPC_ACK_PING ,0 , rxrpc_propose_ack_ping_for_old_rtt);
net/rxrpc/call_object.c +2 -0
@@ -178,6 +178,8 @@ struct rxrpc_call *rxrpc_alloc_call(struct rxrpc_sock *rx, gfp_t gfp, call->cong_cwnd =RXRPC_MIN_CWND ; call->cong_ssthresh =RXRPC_TX_MAX_WINDOW ; +rxrpc_call_init_rtt (call); + call->rxnet = rxnet; call->rtt_avail =RXRPC_CALL_RTT_AVAIL_MASK ;atomic_inc (&rxnet->nr_calls);
net/rxrpc/input.c +4 -4
@@ -83,11 +83,11 @@ static void rxrpc_congestion_management(struct rxrpc_call *call,/* We analyse the number of packets that get ACK'd per RTT * period and increase the window if we managed to fill it. */ -if (call->peer->rtt_count ==0 ) +if (call->rtt_count ==0 ) goto out;if (ktime_before (skb->tstamp,ktime_add_us (call->cong_tstamp, - call->peer->srtt_us >>3 ))) + call->srtt_us >>3 ))) goto out_no_clear_ca; change = rxrpc_cong_rtt_window_end; call->cong_tstamp = skb->tstamp;
@@ -197,7 +197,7 @@ void rxrpc_congestion_degrade(struct rxrpc_call *call)if (__rxrpc_call_state (call) ==RXRPC_CALL_CLIENT_AWAIT_REPLY )return ; - rtt =ns_to_ktime (call->peer->srtt_us * (1000 /8 )); + rtt =ns_to_ktime (call->srtt_us * (NSEC_PER_USEC /8 )); now =ktime_get_real ();if (!ktime_before (ktime_add (call->tx_last_sent, rtt), now))return ;
@@ -664,7 +664,7 @@ static void rxrpc_complete_rtt_probe(struct rxrpc_call *call,clear_bit (i +RXRPC_CALL_RTT_PEND_SHIFT , &call->rtt_avail);smp_mb ();/* Read data before setting avail bit */ set_bit (i, &call->rtt_avail); -rxrpc_peer_add_rtt (call, type, i, acked_serial, ack_serial, +rxrpc_call_add_rtt (call, type, i, acked_serial, ack_serial, sent_at, resp_time); matched = true; }
net/rxrpc/output.c +7 -7
@@ -220,7 +220,7 @@ static void rxrpc_send_ack_packet(struct rxrpc_call *call, struct rxrpc_txbuf *tif (ack->reason ==RXRPC_ACK_PING )rxrpc_begin_rtt_probe (call, txb->serial, now, rxrpc_rtt_tx_ping);if (txb->flags &RXRPC_REQUEST_ACK ) - call->peer->rtt_last_req = now; + call->rtt_last_req = now;rxrpc_set_keepalive (call, now); }rxrpc_tx_backoff (call, ret);
@@ -358,9 +358,9 @@ static void rxrpc_prepare_data_subpacket(struct rxrpc_call *call, struct rxrpc_t why = rxrpc_reqack_slow_start; else if (call->tx_winsize <= 2) why = rxrpc_reqack_small_txwin; - else if (call->peer->rtt_count < 3 && txb->seq & 1) + else if (call->rtt_count < 3) why = rxrpc_reqack_more_rtt; - else if (ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), ktime_get_real())) + else if (ktime_before(ktime_add_ms(call->rtt_last_req, 1000), ktime_get_real())) why = rxrpc_reqack_old_rtt; else goto dont_set_request_ack;
@@ -407,9 +407,9 @@ static void rxrpc_tstamp_data_packets(struct rxrpc_call *call, struct rxrpc_txbuif (ack_requested) {rxrpc_begin_rtt_probe (call, txb->serial, now, rxrpc_rtt_tx_data); - call->peer->rtt_last_req = now; -if (call->peer->rtt_count >1 ) { -ktime_t delay =rxrpc_get_rto_backoff (call->peer, false); + call->rtt_last_req = now; +if (call->rtt_count >1 ) { +ktime_t delay =rxrpc_get_rto_backoff (call, false); call->ack_lost_at =ktime_add (now, delay);trace_rxrpc_timer_set (call, delay, rxrpc_timer_trace_lost_ack);
@@ -727,7 +727,7 @@ void rxrpc_transmit_one(struct rxrpc_call *call, struct rxrpc_txbuf *txb)rxrpc_instant_resend (call, txb); } }else { -ktime_t delay =ns_to_ktime (call->peer->rto_us *NSEC_PER_USEC ); +ktime_t delay =ns_to_ktime (call->rto_us *NSEC_PER_USEC ); call->resend_at =ktime_add (ktime_get_real (), delay);trace_rxrpc_timer_set (call, delay, rxrpc_timer_trace_resend_tx);
net/rxrpc/peer_object.c +2 -6
@@ -222,11 +222,8 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp, peer->service_conns =RB_ROOT ;seqlock_init (&peer->service_conn_lock);spin_lock_init (&peer->lock); -spin_lock_init (&peer->rtt_input_lock); peer->debug_id =atomic_inc_return (&rxrpc_debug_id); - -rxrpc_peer_init_rtt (peer); - + peer->recent_srtt_us =UINT_MAX ; peer->cong_ssthresh =RXRPC_TX_MAX_WINDOW ;trace_rxrpc_peer (peer->debug_id,1 , why); }
@@ -244,7 +241,6 @@ static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, peer->hash_key = hash_key;rxrpc_assess_MTU_size (local, peer); peer->mtu = peer->if_mtu; - peer->rtt_last_req =ktime_get_real ();switch (peer->srx.transport.family) {case AF_INET :
@@ -480,7 +476,7 @@ EXPORT_SYMBOL(rxrpc_kernel_get_call_peer);*/ unsigned int rxrpc_kernel_get_srtt (const struct rxrpc_peer *peer) { -return peer->rtt_count >0 ? peer->srtt_us >>3 :UINT_MAX ; +return READ_ONCE (peer->recent_srtt_us); }EXPORT_SYMBOL (rxrpc_kernel_get_srtt);
net/rxrpc/proc.c +3 -3
@@ -299,15 +299,15 @@ static int rxrpc_peer_seq_show(struct seq_file *seq, void *v) now =ktime_get_seconds ();seq_printf (seq,"UDP %-47.47s %-47.47s %3u" -" %3u %5u %6ds %8u %8u\n" , +" %3u %5u %6ds %8d %8d\n" , lbuff, rbuff,refcount_read (&peer->ref), peer->cong_ssthresh, peer->mtu, (s32 )now - (s32 )READ_ONCE (peer->last_tx_at), - peer->srtt_us >>3 , - peer->rto_us); +READ_ONCE (peer->recent_srtt_us), +READ_ONCE (peer->recent_rto_us));return 0 ; }
net/rxrpc/rtt.c +47 -46
202 lines not on this page · raw message
net/rxrpc/sendmsg.c +1 -1
@@ -133,7 +133,7 @@ static int rxrpc_wait_for_tx_window_waitall(struct rxrpc_sock *rx,rxrpc_seq_t tx_start, tx_win;signed long rtt, timeout; - rtt =READ_ONCE (call->peer->srtt_us) >>3 ; + rtt =READ_ONCE (call->srtt_us) >>3 ; rtt =usecs_to_jiffies (rtt) *2 ;if (rtt <2 ) rtt =2 ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 5/5 rxrpc: Fix irq-disabled in local_bh_enable()
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit e4d2878369d590bf8455e3678a644e503172eafa ]
The rxrpc_assess_MTU_size() function calls down into the IP layer to find out the MTU size for a route. When accepting an incoming call, this is called from rxrpc_new_incoming_call() which holds interrupts disabled across the code that calls down to it. Unfortunately, the IP layer uses local_bh_enable() which, config dependent, throws a warning if IRQs are enabled:
WARNING: CPU: 1 PID: 5544 at kernel/softirq.c:387 __local_bh_enable_ip+0x43/0xd0 ... RIP: 0010:__local_bh_enable_ip+0x43/0xd0 ... Call Trace: <TASK> rt_cache_route+0x7e/0xa0 rt_set_nexthop.isra.0+0x3b3/0x3f0 __mkroute_output+0x43a/0x460 ip_route_output_key_hash+0xf7/0x140 ip_route_output_flow+0x1b/0x90 rxrpc_assess_MTU_size.isra.0+0x2a0/0x590 rxrpc_new_incoming_peer+0x46/0x120 rxrpc_alloc_incoming_call+0x1b1/0x400 rxrpc_new_incoming_call+0x1da/0x5e0 rxrpc_input_packet+0x827/0x900 rxrpc_io_thread+0x403/0xb60 kthread+0x2f7/0x310 ret_from_fork+0x2a/0x230 ret_from_fork_asm+0x1a/0x30 ... hardirqs last enabled at (23): _raw_spin_unlock_irq+0x24/0x50 hardirqs last disabled at (24): _raw_read_lock_irq+0x17/0x70 softirqs last enabled at (0): copy_process+0xc61/0x2730 softirqs last disabled at (25): rt_add_uncached_list+0x3c/0x90
Fix this by moving the call to rxrpc_assess_MTU_size() out of rxrpc_init_peer() and further up the stack where it can be done without interrupts disabled.
It shouldn't be a problem for rxrpc_new_incoming_call() to do it after the locks are dropped as pmtud is going to be performed by the I/O thread - and we're in the I/O thread at this point.
--- net/rxrpc/ar-internal.h | 1 + net/rxrpc/call_accept.c | 1 + net/rxrpc/peer_object.c | 12 +++++++----- 3 files changed, 9 insertions(+), 5 deletions(-)
net/rxrpc/ar-internal.h +1 -0
@@ -1183,6 +1183,7 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *, const struct sockaddr_rxrpc *);struct rxrpc_peer *rxrpc_lookup_peer (struct rxrpc_local *local,struct sockaddr_rxrpc *srx,gfp_t gfp); +void rxrpc_assess_MTU_size (struct rxrpc_local *local,struct rxrpc_peer *peer);struct rxrpc_peer *rxrpc_alloc_peer (struct rxrpc_local *,gfp_t ,enum rxrpc_peer_trace );void rxrpc_new_incoming_peer (struct rxrpc_local *local,struct rxrpc_peer *peer);
net/rxrpc/call_accept.c +1 -0
@@ -407,6 +407,7 @@ bool rxrpc_new_incoming_call(struct rxrpc_local *local,spin_unlock (&rx->incoming_lock);read_unlock_irq (&local->services_lock); +rxrpc_assess_MTU_size (local, call->peer);if (hlist_unhashed (&call->error_link)) {spin_lock_irq (&call->peer->lock);
net/rxrpc/peer_object.c +7 -5
@@ -149,8 +149,7 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *local,* assess the MTU size for the network interface through which this peer is * reached */ -static void rxrpc_assess_MTU_size (struct rxrpc_local *local, -struct rxrpc_peer *peer) +void rxrpc_assess_MTU_size (struct rxrpc_local *local,struct rxrpc_peer *peer) {struct net *net = local->net;struct dst_entry *dst;
@@ -162,6 +161,8 @@ static void rxrpc_assess_MTU_size(struct rxrpc_local *local,#endif peer->if_mtu =1500 ; + peer->mtu = peer->if_mtu; + peer->maxdata = peer->mtu - peer->hdrsize;memset (&fl,0 ,sizeof (fl));switch (peer->srx.transport.family) {
@@ -201,6 +202,9 @@ static void rxrpc_assess_MTU_size(struct rxrpc_local *local, peer->if_mtu =dst_mtu (dst);dst_release (dst); + peer->mtu = peer->if_mtu; + peer->maxdata = peer->mtu - peer->hdrsize; +_leave (" [if_mtu %u]" , peer->if_mtu); }
@@ -239,8 +243,6 @@ static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, unsigned long hash_key) { peer->hash_key = hash_key; -rxrpc_assess_MTU_size (local, peer); - peer->mtu = peer->if_mtu;switch (peer->srx.transport.family) {case AF_INET :
@@ -264,7 +266,6 @@ static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, } peer->hdrsize +=sizeof (struct rxrpc_wire_header ); - peer->maxdata = peer->mtu - peer->hdrsize; }/*
@@ -283,6 +284,7 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local,if (peer) {memcpy (&peer->srx, srx,sizeof (*srx));rxrpc_init_peer (local, peer, hash_key); +rxrpc_assess_MTU_size (local, peer); }_leave (" = %p" , peer);
Signature · 1 line
2.53.0