From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
Sasha Levin <sashal@kernel.org>,
linux-afs@lists.infradead.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 12/32] rxrpc: Abstract out the calculation of whether there's Tx space
Date: Mon, 6 Apr 2020 20:01:30 -0400 [thread overview]
Message-ID: <20200407000151.16768-12-sashal@kernel.org> (raw)
In-Reply-To: <20200407000151.16768-1-sashal@kernel.org>
From: David Howells <dhowells@redhat.com>
[ Upstream commit 158fe6665389964a1de212818b4a5c52b7f7aff4 ]
Abstract out the calculation of there being sufficient Tx buffer space.
This is reproduced several times in the rxrpc sendmsg code.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/rxrpc/sendmsg.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index 813fd68881429..a13051d380973 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -17,6 +17,21 @@
#include <net/af_rxrpc.h>
#include "ar-internal.h"
+/*
+ * Return true if there's sufficient Tx queue space.
+ */
+static bool rxrpc_check_tx_space(struct rxrpc_call *call, rxrpc_seq_t *_tx_win)
+{
+ unsigned int win_size =
+ min_t(unsigned int, call->tx_winsize,
+ call->cong_cwnd + call->cong_extra);
+ rxrpc_seq_t tx_win = READ_ONCE(call->tx_hard_ack);
+
+ if (_tx_win)
+ *_tx_win = tx_win;
+ return call->tx_top - tx_win < win_size;
+}
+
/*
* Wait for space to appear in the Tx queue or a signal to occur.
*/
@@ -26,9 +41,7 @@ static int rxrpc_wait_for_tx_window_intr(struct rxrpc_sock *rx,
{
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
- if (call->tx_top - call->tx_hard_ack <
- min_t(unsigned int, call->tx_winsize,
- call->cong_cwnd + call->cong_extra))
+ if (rxrpc_check_tx_space(call, NULL))
return 0;
if (call->state >= RXRPC_CALL_COMPLETE)
@@ -68,9 +81,7 @@ static int rxrpc_wait_for_tx_window_nonintr(struct rxrpc_sock *rx,
set_current_state(TASK_UNINTERRUPTIBLE);
tx_win = READ_ONCE(call->tx_hard_ack);
- if (call->tx_top - tx_win <
- min_t(unsigned int, call->tx_winsize,
- call->cong_cwnd + call->cong_extra))
+ if (rxrpc_check_tx_space(call, &tx_win))
return 0;
if (call->state >= RXRPC_CALL_COMPLETE)
@@ -302,9 +313,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
_debug("alloc");
- if (call->tx_top - call->tx_hard_ack >=
- min_t(unsigned int, call->tx_winsize,
- call->cong_cwnd + call->cong_extra)) {
+ if (!rxrpc_check_tx_space(call, NULL)) {
ret = -EAGAIN;
if (msg->msg_flags & MSG_DONTWAIT)
goto maybe_error;
--
2.20.1
next prev parent reply other threads:[~2020-04-07 0:06 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 0:01 [PATCH AUTOSEL 5.4 01/32] ARM: dts: sun8i-a83t-tbs-a711: HM5065 doesn't like such a high voltage Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 02/32] bus: sunxi-rsb: Return correct data when mixing 16-bit and 8-bit reads Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 03/32] ARM: dts: Fix dm814x Ethernet by changing to use rgmii-id mode Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 04/32] bpf: Fix deadlock with rq_lock in bpf_send_signal() Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 05/32] net/mlx5e: kTLS, Fix wrong value in record tracker enum Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 06/32] iwlwifi: consider HE capability when setting LDPC Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 07/32] iwlwifi: yoyo: don't add TLV offset when reading FIFOs Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 08/32] iwlwifi: dbg: don't abort if sending DBGC_SUSPEND_RESUME fails Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 09/32] iwlwifi: mvm: Fix rate scale NSS configuration Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 10/32] Input: tm2-touchkey - add support for Coreriver TC360 variant Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 11/32] soc: fsl: dpio: register dpio irq handlers after dpio create Sasha Levin
2020-04-07 0:01 ` Sasha Levin [this message]
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 13/32] rxrpc: Fix call interruptibility handling Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 14/32] rxrpc: Fix sendmsg(MSG_WAITALL) handling Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 15/32] net: stmmac: platform: Fix misleading interrupt error msg Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 16/32] net: vxge: fix wrong __VA_ARGS__ usage Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 17/32] hinic: fix a bug of waitting for IO stopped Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 18/32] hinic: fix the bug of clearing event queue Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 19/32] hinic: fix out-of-order excution in arm cpu Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 20/32] hinic: fix wrong para of wait_for_completion_timeout Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 21/32] hinic: fix wrong value of MIN_SKB_LEN Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 22/32] selftests/net: add definition for SOL_DCCP to fix compilation errors for old libc Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 23/32] IB/hfi1: Ensure pq is not left on waitlist Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 24/32] netfilter: nf_tables: Allow set back-ends to report partial overlaps on insertion Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 25/32] netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start() Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 26/32] netfilter: nft_set_rbtree: Detect partial overlaps on insertion Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 27/32] cxgb4/ptp: pass the sign of offset delta in FW CMD Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 28/32] drm/scheduler: fix rare NULL ptr race Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 29/32] cfg80211: Do not warn on same channel at the end of CSA Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 30/32] qlcnic: Fix bad kzalloc null test Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 31/32] i2c: st: fix missing struct parameter description Sasha Levin
2020-04-07 0:01 ` [PATCH AUTOSEL 5.4 32/32] i2c: pca-platform: Use platform_irq_get_optional Sasha Levin
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=20200407000151.16768-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).