Skip to content

Commit

Permalink
mptcp: split mptcp_clean_una function
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Florian Westphal authored and Jakub Kicinski committed Nov 5, 2020
1 parent 5a369ca commit 95ed690
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,19 +853,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);
}
}

Expand Down Expand Up @@ -1769,7 +1775,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);
if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
Expand Down

0 comments on commit 95ed690

Please sign in to comment.