diff mbox series

[mptcp-next] mptcp: split mptcp_clean_una function

Message ID 20200910163630.8137-1-fw@strlen.de
State Accepted, archived
Commit bef7797391292b1210d0ecd4b4a90483e5747e05
Delegated to: Matthieu Baerts
Headers show
Series [mptcp-next] mptcp: split mptcp_clean_una function | expand

Commit Message

Florian Westphal Sept. 10, 2020, 4:36 p.m. UTC
mptcp_clean_una() will wake writers in case memory could be reclaimed.
When called from mptcp_sendmsg the wakeup code isn't needed.

Move the wakeup to a new helper and then use that from the mptcp worker.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/mptcp/protocol.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

 Sending this ahead of the rebase on top of paolos patchset,
 I think this can be integrated stand-alone as it has no dependency
 on sendmsg refactor or poll rework.

Comments

Mat Martineau Sept. 17, 2020, 10:53 p.m. UTC | #1
On Thu, 10 Sep 2020, Florian Westphal wrote:

> mptcp_clean_una() will wake writers in case memory could be reclaimed.
> When called from mptcp_sendmsg the wakeup code isn't needed.
>
> Move the wakeup to a new helper and then use that from the mptcp worker.
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> net/mptcp/protocol.c | 28 +++++++++++++++++-----------
> 1 file changed, 17 insertions(+), 11 deletions(-)
>
> Sending this ahead of the rebase on top of paolos patchset,
> I think this can be integrated stand-alone as it has no dependency
> on sendmsg refactor or poll rework.
>

Looks good to me, thanks Florian. It still applies cleanly to the export 
branch too.

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

--
Mat Martineau
Intel
Matthieu Baerts Sept. 18, 2020, 3:37 p.m. UTC | #2
Hi Florian, Mat,

On 18/09/2020 00:53, Mat Martineau wrote:
> 
> On Thu, 10 Sep 2020, Florian Westphal wrote:
> 
>> mptcp_clean_una() will wake writers in case memory could be reclaimed.
>> When called from mptcp_sendmsg the wakeup code isn't needed.
>>
>> Move the wakeup to a new helper and then use that from the mptcp worker.
>>
>> Signed-off-by: Florian Westphal <fw@strlen.de>
>> ---
>> net/mptcp/protocol.c | 28 +++++++++++++++++-----------
>> 1 file changed, 17 insertions(+), 11 deletions(-)
>>
>> Sending this ahead of the rebase on top of paolos patchset,
>> I think this can be integrated stand-alone as it has no dependency
>> on sendmsg refactor or poll rework.
>>
> 
> Looks good to me, thanks Florian. It still applies cleanly to the export 
> branch too.
> 
> Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Thank you for the patch and the review!

- 0032722d977f: mptcp: split mptcp_clean_una function
- a0e1e786f7d2..dcdf6c22dc6f: result

Tests + export are in progress!

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7469e89b3d7a..3c2476baae2d 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -831,19 +831,25 @@  static void mptcp_clean_una(struct sock *sk)
 	}
 
 out:
-	if (cleaned) {
+	if (cleaned)
 		sk_mem_reclaim_partial(sk);
+}
 
-		/* Only wake up writers if a subflow is ready */
-		if (mptcp_is_writeable(msk)) {
-			set_bit(MPTCP_SEND_SPACE, &mptcp_sk(sk)->flags);
-			smp_mb__after_atomic();
+static void mptcp_clean_una_wakeup(struct sock *sk)
+{
+	struct mptcp_sock *msk = mptcp_sk(sk);
 
-			/* set SEND_SPACE before sk_stream_write_space clears
-			 * NOSPACE
-			 */
-			sk_stream_write_space(sk);
-		}
+	mptcp_clean_una(sk);
+
+	/* Only wake up writers if a subflow is ready */
+	if (mptcp_is_writeable(msk)) {
+		set_bit(MPTCP_SEND_SPACE, &msk->flags);
+		smp_mb__after_atomic();
+
+		/* set SEND_SPACE before sk_stream_write_space clears
+		 * NOSPACE
+		 */
+		sk_stream_write_space(sk);
 	}
 }
 
@@ -1724,7 +1730,7 @@  static void mptcp_worker(struct work_struct *work)
 	long timeo = 0;
 
 	lock_sock(sk);
-	mptcp_clean_una(sk);
+	mptcp_clean_una_wakeup(sk);
 	mptcp_check_data_fin_ack(sk);
 	__mptcp_flush_join_list(msk);
 	__mptcp_move_skbs(msk);