refactor push pending
Subsystems (2)
v4 cover refactor push pending
v4:
- update __mptcp_subflow_push_pending as Mat suggested.
- add more patches from "BPF redundant scheduler" series.
v3:
- add a cleanup patch.
- remove msk->last_snd in mptcp_subflow_get_send().
- add the loop that calls the scheduler again in __mptcp_push_pending().
v2:
- add snd_burst check in dfrags loop as Mat suggested.
Refactor __mptcp_push_pending() and __mptcp_subflow_push_pending() to remove duplicate code and support redundant scheduler more easily in __mptcp_subflow_push_pending().
Geliang Tang (11):
Squash to "mptcp: add get_subflow wrappers"
mptcp: add new argument ssk_first
mptcp: move burst check out of subflow_get_send
mptcp: refactor push_pending logic
mptcp: simplify push_pending
mptcp: multi subflows push_pending
mptcp: use msk instead of mptcp_sk
mptcp: refactor subflow_push_pending logic
mptcp: simplify subflow_push_pending
mptcp: multi subflows subflow_push_pending
mptcp: multi subflows retrans support
net/mptcp/protocol.c | 259 ++++++++++++++++++++++--------------------- net/mptcp/protocol.h | 4 +- net/mptcp/sched.c | 59 +++++----- 3 files changed, 164 insertions(+), 158 deletions(-)
Signature · 1 line
2.35.3
PATCH v4 1/11 Squash to "mptcp: add get_subflow wrappers"
Please update the commit log:
'''
This patch defines two new wrappers mptcp_sched_get_send() and mptcp_sched_get_retrans(), invoke get_subflow() of msk->sched in them.
Set the subflow pointers array in struct mptcp_sched_data before invoking get_subflow(), then it can be used in get_subflow() in the BPF contexts.
Check the subflow scheduled flags to test which subflow or subflows are picked by the scheduler.
Move sock_owned_by_me() and the fallback check code from mptcp_subflow_get_send/retrans() into the wrappers. '''
--- net/mptcp/protocol.c | 8 +++--- net/mptcp/protocol.h | 4 +-- net/mptcp/sched.c | 59 +++++++++++++++++++++----------------------- 3 files changed, 34 insertions(+), 37 deletions(-)
net/mptcp/protocol.c +4 -4
@@ -1547,7 +1547,7 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)int ret =0 ; prev_ssk = ssk; - ssk =mptcp_sched_get_send (msk); + ssk =mptcp_subflow_get_send (msk);/* First check. If the ssk has changed since * the last round, release prev_ssk
@@ -1616,7 +1616,7 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk)* check for a different subflow usage only after * spooling the first chunk of data */ - xmit_ssk = first ? ssk :mptcp_sched_get_send (mptcp_sk (sk)); + xmit_ssk = first ? ssk :mptcp_subflow_get_send (mptcp_sk (sk));if (!xmit_ssk) goto out;if (xmit_ssk != ssk) {
@@ -2478,7 +2478,7 @@ static void __mptcp_retrans(struct sock *sk)mptcp_clean_una_wakeup (sk);/* first check ssk: need to kick "stale" logic */ - ssk =mptcp_sched_get_retrans (msk); + ssk =mptcp_subflow_get_retrans (msk); dfrag =mptcp_rtx_head (sk);if (!dfrag) {if (mptcp_data_fin_enabled (msk)) {
@@ -3196,7 +3196,7 @@ void __mptcp_check_push(struct sock *sk, struct sock *ssk)return ;if (!sock_owned_by_user (sk)) { -struct sock *xmit_ssk =mptcp_sched_get_send (mptcp_sk (sk)); +struct sock *xmit_ssk =mptcp_subflow_get_send (mptcp_sk (sk));if (xmit_ssk == ssk)__mptcp_subflow_push_pending (sk, ssk);
net/mptcp/protocol.h +2 -2
@@ -640,8 +640,8 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow, bool scheduled);struct sock *mptcp_subflow_get_send (struct mptcp_sock *msk);struct sock *mptcp_subflow_get_retrans (struct mptcp_sock *msk); -struct sock *mptcp_sched_get_send (struct mptcp_sock *msk); -struct sock *mptcp_sched_get_retrans (struct mptcp_sock *msk); +int mptcp_sched_get_send (struct mptcp_sock *msk); +int mptcp_sched_get_retrans (struct mptcp_sock *msk);static inline bool __tcp_can_send (const struct sock *ssk) {
net/mptcp/sched.c +28 -31
95 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH v4 2/11 mptcp: add new argument ssk_first
In reply to Geliang TangThe function mptcp_subflow_process_delegated() uses the input ssk first, while __mptcp_check_push() invokes the packet scheduler first.
So this patch adds a new argument named ssk_first for the function __mptcp_subflow_push_pending() to deal with these two cases separately.
With this change, the code that invokes the packet scheduler in the fuction __mptcp_check_push() can be removed, and replaced by invoking __mptcp_subflow_push_pending() directly.
--- net/mptcp/protocol.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
net/mptcp/protocol.c +8 -14
@@ -1593,16 +1593,17 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)__mptcp_check_send_data_fin (sk); } -static void __mptcp_subflow_push_pending (struct sock *sk,struct sock *ssk) +static void __mptcp_subflow_push_pending (struct sock *sk,struct sock *ssk, +bool ssk_first) {struct mptcp_sock *msk =mptcp_sk (sk);struct mptcp_sendmsg_info info = { .data_lock_held = true, };struct mptcp_data_frag *dfrag; +bool first = ssk_first;struct sock *xmit_ssk;int len, copied =0 ; -bool first = true; info.flags =0 ;while ((dfrag =mptcp_send_head (sk))) {
@@ -1612,8 +1613,7 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk)while (len >0 ) {int ret =0 ; -/* the caller already invoked the packet scheduler, -* check for a different subflow usage only after +/* check for a different subflow usage only after * spooling the first chunk of data */ xmit_ssk = first ? ssk :mptcp_subflow_get_send (mptcp_sk (sk));
@@ -3195,16 +3195,10 @@ void __mptcp_check_push(struct sock *sk, struct sock *ssk)if (!mptcp_send_head (sk))return ; -if (!sock_owned_by_user (sk)) { -struct sock *xmit_ssk =mptcp_subflow_get_send (mptcp_sk (sk)); - -if (xmit_ssk == ssk) -__mptcp_subflow_push_pending (sk, ssk); -else if (xmit_ssk) -mptcp_subflow_delegate (mptcp_subflow_ctx (xmit_ssk),MPTCP_DELEGATE_SEND ); - }else { +if (!sock_owned_by_user (sk)) +__mptcp_subflow_push_pending (sk, ssk, false); +else __set_bit (MPTCP_PUSH_PENDING , &mptcp_sk (sk)->cb_flags); - } }#define MPTCP_FLAGS_PROCESS_CTX_NEED (BIT(MPTCP_PUSH_PENDING) | \
@@ -3295,7 +3289,7 @@ void mptcp_subflow_process_delegated(struct sock *ssk)if (test_bit (MPTCP_DELEGATE_SEND , &subflow->delegated_status)) {mptcp_data_lock (sk);if (!sock_owned_by_user (sk)) -__mptcp_subflow_push_pending (sk, ssk); +__mptcp_subflow_push_pending (sk, ssk, true);else __set_bit (MPTCP_PUSH_PENDING , &mptcp_sk (sk)->cb_flags);mptcp_data_unlock (sk);
Signature · 1 line
2.35.3
Re: [PATCH mptcp-next v4 02/11] mptcp: add new argument ssk_first
Quoted 23 lines · Geliang Tang
The function
mptcp_subflow_process_delegated()uses the input ssk first, while__mptcp_check_push()invokes the packet scheduler first.So this patch adds a new argument named
ssk_firstfor the function__mptcp_subflow_push_pending()to deal with these two cases separately.With this change, the code that invokes the packet scheduler in the fuction
__mptcp_check_push()can be removed, and replaced by invoking__mptcp_subflow_push_pending()directly.Signed-off-by Geliang Tang <[email protected]>---
net/mptcp/protocol.c| 22 ++++++++--------------1 file changed, 8 insertions(+), 14 deletions(-)net/mptcp/protocol.c +0
-0@@ -1593,16 +1593,17 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)__mptcp_check_send_data_fin (sk); }
net/mptcp/protocol.c void __mptcp_push_pending(struct sock *sk, unsigned int flags) · line 1604
Quoted 10 lines
net/mptcp/protocol.c +3
-1-static void __mptcp_subflow_push_pending (struct sock *sk,struct sock *ssk) +static void __mptcp_subflow_push_pending (struct sock *sk,struct sock *ssk, +bool ssk_first) {struct mptcp_sock *msk =mptcp_sk (sk);struct mptcp_sendmsg_info info = { .data_lock_held = true, };struct mptcp_data_frag *dfrag; +bool first = ssk_first;
Hi Geliang -
Thanks for the v4.
If you add 'first' as the new argument instead of ssk_first, then you can remove this line and use 'first' everywhere.
- Mat
Quoted 50 lines
net/mptcp/protocol.c +5
-13struct sock *xmit_ssk;int len, copied =0 ; -bool first = true; info.flags =0 ;while ((dfrag =mptcp_send_head (sk))) {@@ -1612,8 +1613,7 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk)while (len >0 ) {int ret =0 ; -/* the caller already invoked the packet scheduler, -* check for a different subflow usage only after +/* check for a different subflow usage only after * spooling the first chunk of data */ xmit_ssk = first ? ssk :mptcp_subflow_get_send (mptcp_sk (sk));@@ -3195,16 +3195,10 @@ void __mptcp_check_push(struct sock *sk, struct sock *ssk)if (!mptcp_send_head (sk))return ; -if (!sock_owned_by_user (sk)) { -struct sock *xmit_ssk =mptcp_subflow_get_send (mptcp_sk (sk)); - -if (xmit_ssk == ssk) -__mptcp_subflow_push_pending (sk, ssk); -else if (xmit_ssk) -mptcp_subflow_delegate (mptcp_subflow_ctx (xmit_ssk),MPTCP_DELEGATE_SEND ); - }else { +if (!sock_owned_by_user (sk)) +__mptcp_subflow_push_pending (sk, ssk, false); +else __set_bit (MPTCP_PUSH_PENDING , &mptcp_sk (sk)->cb_flags); - } }#define MPTCP_FLAGS_PROCESS_CTX_NEED (BIT(MPTCP_PUSH_PENDING) | \@@ -3295,7 +3289,7 @@ void mptcp_subflow_process_delegated(struct sock *ssk)if (test_bit (MPTCP_DELEGATE_SEND , &subflow->delegated_status)) {mptcp_data_lock (sk);if (!sock_owned_by_user (sk)) -__mptcp_subflow_push_pending (sk, ssk); +__mptcp_subflow_push_pending (sk, ssk, true);else __set_bit (MPTCP_PUSH_PENDING , &mptcp_sk (sk)->cb_flags);mptcp_data_unlock (sk);Signature · 1 line
2.35.3
--
Mat Martineau
Intel
PATCH v4 3/11 mptcp: move burst check out of subflow_get_send
In reply to Geliang TangThis patch moves the burst check conditions out of the function mptcp_subflow_get_send(), check them in __mptcp_push_pending() and __mptcp_subflow_push_pending() in the inner "for each pending dfrag" loop.
--- net/mptcp/protocol.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
net/mptcp/protocol.c +15 -12
@@ -1417,14 +1417,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)u64 linger_time;long tout =0 ; -/* re-use last subflow, if the burst allow that */ -if (msk->last_snd && msk->snd_burst >0 && -sk_stream_memory_free (msk->last_snd) && -mptcp_subflow_active (mptcp_subflow_ctx (msk->last_snd))) { -mptcp_set_timeout (sk); -return msk->last_snd; - } -/* pick the subflow with the lower wmem/wspace ratio */ for (i =0 ; i <SSK_MODE_MAX ; ++i) { send_info[i].ssk =NULL ;
@@ -1477,16 +1469,13 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) burst =min_t (int,MPTCP_SEND_BURST_SIZE ,mptcp_wnd_end (msk) - msk->snd_nxt); wmem =READ_ONCE (ssk->sk_wmem_queued); -if (!burst) { - msk->last_snd =NULL ; +if (!burst)return ssk; - } subflow =mptcp_subflow_ctx (ssk); subflow->avg_pacing_rate =div_u64 ((u64 )subflow->avg_pacing_rate * wmem +READ_ONCE (ssk->sk_pacing_rate) * burst, burst + wmem); - msk->last_snd = ssk; msk->snd_burst = burst;return ssk; }
@@ -1579,6 +1568,13 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)mptcp_update_post_push (msk, dfrag, ret); }WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); }/* at this point we held the socket lock for the last subflow we used */
@@ -1637,6 +1633,13 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,mptcp_update_post_push (msk, dfrag, ret); }WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); } out:
Signature · 1 line
2.35.3
Re: [PATCH mptcp-next v4 03/11] mptcp: move burst check out of subflow_get_send
Quoted 5 lines · Geliang Tang
This patch moves the burst check conditions out of the function
mptcp_subflow_get_send(), check them in__mptcp_push_pending()and__mptcp_subflow_push_pending()in the inner "for each pending dfrag" loop.Signed-off-by Geliang Tang <[email protected]>
This patch changes behavior in a way that would break MPTCP sends if someone was bisecting git commits. I recommend squashing this with the next patch and making sure the code tests ok.
Quoted 9 lines
---
net/mptcp/protocol.c| 27 +++++++++++++++------------1 file changed, 15 insertions(+), 12 deletions(-)net/mptcp/protocol.c +0
-0
net/mptcp/protocol.c struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) · line 1425
Quoted 9 lines
net/mptcp/protocol.c +0
-6@@ -1417,14 +1417,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)u64 linger_time;long tout =0 ; -/* re-use last subflow, if the burst allow that */ -if (msk->last_snd && msk->snd_burst >0 && -sk_stream_memory_free (msk->last_snd) && -mptcp_subflow_active (mptcp_subflow_ctx (msk->last_snd))) { -mptcp_set_timeout (sk); -return msk->last_snd;
Once msk->last_snd is removed here, that member of msk is no longer used and it can be removed from struct mptcp_sock. I think I mentioned this in a previous review - if I'm mistaken please correct me here. Otherwise I will keep making the same suggestion :)
- Mat
Quoted 50 lines
net/mptcp/protocol.c +15
-6- } -/* pick the subflow with the lower wmem/wspace ratio */ for (i =0 ; i <SSK_MODE_MAX ; ++i) { send_info[i].ssk =NULL ;@@ -1477,16 +1469,13 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) burst =min_t (int,MPTCP_SEND_BURST_SIZE ,mptcp_wnd_end (msk) - msk->snd_nxt); wmem =READ_ONCE (ssk->sk_wmem_queued); -if (!burst) { - msk->last_snd =NULL ; +if (!burst)return ssk; - } subflow =mptcp_subflow_ctx (ssk); subflow->avg_pacing_rate =div_u64 ((u64 )subflow->avg_pacing_rate * wmem +READ_ONCE (ssk->sk_pacing_rate) * burst, burst + wmem); - msk->last_snd = ssk; msk->snd_burst = burst;return ssk; }@@ -1579,6 +1568,13 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)mptcp_update_post_push (msk, dfrag, ret); }WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); }/* at this point we held the socket lock for the last subflow we used */ @@ -1637,6 +1633,13 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,mptcp_update_post_push (msk, dfrag, ret); }WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); }
Quoted 6 lines
out:
Signature · 1 line
2.35.3
--
Mat Martineau
Intel
Re: [PATCH mptcp-next v4 03/11] mptcp: move burst check out of subflow_get_send
Quoted 23 lines · Mat Martineau
Quoted 5 lines · Geliang Tang
This patch moves the burst check conditions out of the function
mptcp_subflow_get_send(), check them in__mptcp_push_pending()and__mptcp_subflow_push_pending()in the inner "for each pending dfrag" loop.Signed-off-by Geliang Tang <[email protected]>This patch changes behavior in a way that would break MPTCP sends if someone was bisecting git commits. I recommend squashing this with the next patch and making sure the code tests ok.
Quoted 13 lines
---
net/mptcp/protocol.c| 27 +++++++++++++++------------1 file changed, 15 insertions(+), 12 deletions(-)net/mptcp/protocol.c +0
-0@@ -1417,14 +1417,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) u64 linger_time;long tout =0 ;
Quoted 10 lines
net/mptcp/protocol.c struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) · line 1425
Quoted 6 lines
net/mptcp/protocol.c +0
-6-/* re-use last subflow, if the burst allow that */ -if (msk->last_snd && msk->snd_burst >0 && -sk_stream_memory_free (msk->last_snd) && -mptcp_subflow_active (mptcp_subflow_ctx (msk->last_snd))) { -mptcp_set_timeout (sk); -return msk->last_snd;Once
msk->last_sndis removed here, that member of msk is no longer used and it can be removed from structmptcp_sock. I think I mentioned this in a previous review - if I'm mistaken please correct me here. Otherwise I will keep making the same suggestion :)
Also, if msk->last_snd is removed, MPTCP_RESET_SCHEDULER can be removed too.
- Mat
Quoted 59 lines
Quoted 59 lines
net/mptcp/protocol.c +0
-2- } -/* pick the subflow with the lower wmem/wspace ratio */ for (i =0 ; i <SSK_MODE_MAX ; ++i) {send_info[i].ssk = NULL;net/mptcp/protocol.c +1
-3@@ -1477,16 +1469,13 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) burst =min_t (int,MPTCP_SEND_BURST_SIZE ,mptcp_wnd_end (msk) - msk->snd_nxt); wmem =READ_ONCE (ssk->sk_wmem_queued); -if (!burst) { - msk->last_snd =NULL ; +if (!burst)return ssk; - } subflow =mptcp_subflow_ctx (ssk); subflow->avg_pacing_rate = div_u64((u64)subflow->avg_pacing_rate *wmem +
READ_ONCE(ssk->sk_pacing_rate) * burst, burst + wmem);net/mptcp/protocol.c +0
-1- msk->last_snd = ssk;msk->snd_burst = burst; return ssk; }net/mptcp/protocol.c +7
-0@@ -1579,6 +1568,13 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags)mptcp_update_post_push (msk ,dfrag ,ret ); }WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); }/* at this point we held the socket lock for the last subflow we used*/
net/mptcp/protocol.c +7
-0@@ -1637,6 +1633,13 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,mptcp_update_post_push (msk, dfrag, ret); }WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); }
Quoted 12 lines
Quoted 6 lines
out:
Signature · 1 line
2.35.3--
Mat Martineau
Intel
--
Mat Martineau
Intel
PATCH v4 4/11 mptcp: refactor push_pending logic
In reply to Geliang TangTo support redundant package schedulers more easily, this patch refactors __mptcp_push_pending() logic from:
For each dfrag:
While sends succeed:
Call the scheduler (selects subflow and msk->snd_burst) Update subflow locks (push/release/acquire as needed) Send the dfrag data with mptcp_sendmsg_frag() Update already_sent, snd_nxt, snd_burst
Update msk->first_pending
Push/release on final subflow
to:
While the scheduler selects one subflow:
Lock the subflow
For each pending dfrag:
While sends succeed:
Send the dfrag data with mptcp_sendmsg_frag() Update already_sent, snd_nxt, snd_burst
Update msk->first_pending
Break if required by msk->snd_burst / etc
Push and release the subflow
--- net/mptcp/protocol.c | 76 +++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 46 deletions(-)
net/mptcp/protocol.c +30 -46
@@ -1519,67 +1519,51 @@ void mptcp_check_and_set_pending(struct sock *sk)void __mptcp_push_pending (struct sock *sk,unsigned int flags) { -struct sock *prev_ssk =NULL , *ssk =NULL ;struct mptcp_sock *msk =mptcp_sk (sk);struct mptcp_sendmsg_info info = { .flags = flags, };bool do_check_data_fin = false;struct mptcp_data_frag *dfrag; +struct sock *ssk;int len; -while ((dfrag =mptcp_send_head (sk))) { - info.sent = dfrag->already_sent; - info.limit = dfrag->data_len; - len = dfrag->data_len - dfrag->already_sent; -while (len >0 ) { -int ret =0 ; - - prev_ssk = ssk; - ssk =mptcp_subflow_get_send (msk); - -/* First check. If the ssk has changed since -* the last round, release prev_ssk -*/ -if (ssk != prev_ssk && prev_ssk) -mptcp_push_release (prev_ssk, &info); -if (!ssk) - goto out; +while (mptcp_send_head (sk) && (ssk =mptcp_subflow_get_send (msk))) { +lock_sock (ssk); -/* Need to lock the new subflow only if different -* from the previous one, otherwise we are still -* helding the relevant lock -*/ -if (ssk != prev_ssk) -lock_sock (ssk); +while ((dfrag =mptcp_send_head (sk))) { + info.sent = dfrag->already_sent; + info.limit = dfrag->data_len; + len = dfrag->data_len - dfrag->already_sent; +while (len >0 ) { +int ret =0 ; + + ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); +if (ret <=0 ) { +if (ret == -EAGAIN ) +continue ; +mptcp_push_release (ssk, &info); + goto out; + } + + do_check_data_fin = true; + info.sent += ret; + len -= ret; + +mptcp_update_post_push (msk, dfrag, ret); + } +WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); - ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) { -if (ret == -EAGAIN ) -continue ; -mptcp_push_release (ssk, &info); +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { goto out; } - - do_check_data_fin = true; - info.sent += ret; - len -= ret; - -mptcp_update_post_push (msk, dfrag, ret); - } -WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); - -if (msk->snd_burst <=0 || - !sk_stream_memory_free (ssk) || - !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { - goto out; +mptcp_set_timeout (sk); } -mptcp_set_timeout (sk); - } -/* at this point we held the socket lock for the last subflow we used */ -if (ssk)mptcp_push_release (ssk, &info); + } out:/* ensure the rtx timer is running */
Signature · 1 line
2.35.3
Re: [PATCH mptcp-next v4 04/11] mptcp: refactor push_pending logic
Quoted 95 lines · Geliang Tang
To support redundant package schedulers more easily, this patch refactors
__mptcp_push_pending()logic from:For each dfrag:
While sends succeed:
Call the scheduler (selects subflow andmsk->snd_burst) Update subflow locks (push/release/acquire as needed) Send the dfrag data withmptcp_sendmsg_frag()Updatealready_sent,snd_nxt,snd_burst
Updatemsk->first_pending
Push/release on final subflowto:
While the scheduler selects one subflow:
Lock the subflow
For each pending dfrag:
While sends succeed:
Send the dfrag data withmptcp_sendmsg_frag()Updatealready_sent,snd_nxt,snd_burst
Updatemsk->first_pending
Break if required bymsk->snd_burst/ etc
Push and release the subflowSigned-off-by Geliang Tang <[email protected]>---
net/mptcp/protocol.c| 76 +++++++++++++++++---------------------------1 file changed, 30 insertions(+), 46 deletions(-)net/mptcp/protocol.c +25
-24@@ -1519,67 +1519,51 @@ void mptcp_check_and_set_pending(struct sock *sk)void __mptcp_push_pending (struct sock *sk,unsigned int flags) { -struct sock *prev_ssk =NULL , *ssk =NULL ;struct mptcp_sock *msk =mptcp_sk (sk);struct mptcp_sendmsg_info info = { .flags = flags, };bool do_check_data_fin = false;struct mptcp_data_frag *dfrag; +struct sock *ssk;int len; -while ((dfrag =mptcp_send_head (sk))) { - info.sent = dfrag->already_sent; - info.limit = dfrag->data_len; - len = dfrag->data_len - dfrag->already_sent; -while (len >0 ) { -int ret =0 ; - - prev_ssk = ssk; - ssk =mptcp_subflow_get_send (msk); - -/* First check. If the ssk has changed since -* the last round, release prev_ssk -*/ -if (ssk != prev_ssk && prev_ssk) -mptcp_push_release (prev_ssk, &info); -if (!ssk) - goto out; +while (mptcp_send_head (sk) && (ssk =mptcp_subflow_get_send (msk))) { +lock_sock (ssk); -/* Need to lock the new subflow only if different -* from the previous one, otherwise we are still -* helding the relevant lock -*/ -if (ssk != prev_ssk) -lock_sock (ssk); +while ((dfrag =mptcp_send_head (sk))) { + info.sent = dfrag->already_sent; + info.limit = dfrag->data_len; + len = dfrag->data_len - dfrag->already_sent; +while (len >0 ) { +int ret =0 ; + + ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); +if (ret <=0 ) { +if (ret == -EAGAIN ) +continue ; +mptcp_push_release (ssk, &info); + goto out; + } + + do_check_data_fin = true; + info.sent += ret; + len -= ret; + +mptcp_update_post_push (msk, dfrag, ret); + } +WRITE_ONCE (msk->first_pending,mptcp_send_next (sk));
net/mptcp/protocol.c void mptcp_check_and_set_pending(struct sock *sk) · line 1560
Quoted 10 lines
net/mptcp/protocol.c +3
-5- ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) { -if (ret == -EAGAIN ) -continue ; -mptcp_push_release (ssk, &info); +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { goto out;
When a burst is over, the scheduler needs to be called again. So rather than jumping out of both loops, this should repeat the outer while loop.
It also looks like there are code paths where mptcp_push_release() is not called, so the ssk is never unlocked. That should be fixed so this patch does not break git bisection.
- Mat
Quoted 25 lines
net/mptcp/protocol.c +2
-17} - - do_check_data_fin = true; - info.sent += ret; - len -= ret; - -mptcp_update_post_push (msk, dfrag, ret); - } -WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); - -if (msk->snd_burst <=0 || - !sk_stream_memory_free (ssk) || - !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { - goto out; +mptcp_set_timeout (sk); } -mptcp_set_timeout (sk); - } -/* at this point we held the socket lock for the last subflow we used */ -if (ssk)mptcp_push_release (ssk, &info); + }out:
Quoted 6 lines
/* ensure the rtx timer is running */Signature · 1 line
2.35.3
--
Mat Martineau
Intel
PATCH v4 5/11 mptcp: simplify push_pending
In reply to Geliang TangThis patch moves the duplicate code from __mptcp_push_pending() and __mptcp_subflow_push_pending() into a new helper function, named __subflow_push_pending(). And simplify __mptcp_push_pending() by invoking this helper.
--- net/mptcp/protocol.c | 90 +++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 42 deletions(-)
net/mptcp/protocol.c +48 -42
@@ -1480,12 +1480,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)return ssk; } -static void mptcp_push_release (struct sock *ssk,struct mptcp_sendmsg_info *info) -{ -tcp_push (ssk,0 , info->mss_now,tcp_sk (ssk)->nonagle, info->size_goal); -release_sock (ssk); -} -static void mptcp_update_post_push (struct mptcp_sock *msk,struct mptcp_data_frag *dfrag,u32 sent)
@@ -1517,6 +1511,52 @@ void mptcp_check_and_set_pending(struct sock *sk)mptcp_sk (sk)->push_pending |=BIT (MPTCP_PUSH_PENDING ); } +static int __subflow_push_pending (struct sock *sk,struct sock *ssk, +struct mptcp_sendmsg_info *info) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_data_frag *dfrag; +int len, copied =0 ; + +while ((dfrag =mptcp_send_head (sk))) { + info->sent = dfrag->already_sent; + info->limit = dfrag->data_len; + len = dfrag->data_len - dfrag->already_sent; +while (len >0 ) { +int ret =0 ; + + ret =mptcp_sendmsg_frag (sk, ssk, dfrag, info); +if (ret <=0 ) { +if (ret == -EAGAIN ) +continue ; + goto out; + } + + info->sent += ret; + copied += ret; + len -= ret; + +mptcp_update_post_push (msk, dfrag, ret); + } +WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); + } + +out: +if (copied) { +tcp_push (ssk,0 , info->mss_now,tcp_sk (ssk)->nonagle, + info->size_goal); + } + +return copied; +} +void __mptcp_push_pending (struct sock *sk,unsigned int flags) {struct mptcp_sock *msk =mptcp_sk (sk);
@@ -1524,48 +1564,14 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags) .flags = flags, };bool do_check_data_fin = false; -struct mptcp_data_frag *dfrag;struct sock *ssk; -int len;while (mptcp_send_head (sk) && (ssk =mptcp_subflow_get_send (msk))) {lock_sock (ssk); - -while ((dfrag =mptcp_send_head (sk))) { - info.sent = dfrag->already_sent; - info.limit = dfrag->data_len; - len = dfrag->data_len - dfrag->already_sent; -while (len >0 ) { -int ret =0 ; - - ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) { -if (ret == -EAGAIN ) -continue ; -mptcp_push_release (ssk, &info); - goto out; - } - - do_check_data_fin = true; - info.sent += ret; - len -= ret; - -mptcp_update_post_push (msk, dfrag, ret); - } -WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); - -if (msk->snd_burst <=0 || - !sk_stream_memory_free (ssk) || - !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { - goto out; - } -mptcp_set_timeout (sk); - } - -mptcp_push_release (ssk, &info); + do_check_data_fin =__subflow_push_pending (sk, ssk, &info); +release_sock (ssk); } -out:/* ensure the rtx timer is running */ if (!mptcp_timer_pending (sk))mptcp_reset_timer (sk);
Signature · 1 line
2.35.3
Re: [PATCH mptcp-next v4 05/11] mptcp: simplify push_pending
Quoted 39 lines · Geliang Tang
This patch moves the duplicate code from
__mptcp_push_pending()and__mptcp_subflow_push_pending()into a new helper function, named__subflow_push_pending(). And simplify__mptcp_push_pending()by invoking this helper.Signed-off-by Geliang Tang <[email protected]>---
net/mptcp/protocol.c| 90 +++++++++++++++++++++++---------------------1 file changed, 48 insertions(+), 42 deletions(-)net/mptcp/protocol.c +8
-6@@ -1480,12 +1480,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)return ssk; } -static void mptcp_push_release (struct sock *ssk,struct mptcp_sendmsg_info *info) -{ -tcp_push (ssk,0 , info->mss_now,tcp_sk (ssk)->nonagle, info->size_goal); -release_sock (ssk); -} -static void mptcp_update_post_push (struct mptcp_sock *msk,struct mptcp_data_frag *dfrag,u32 sent)@@ -1517,6 +1511,52 @@ void mptcp_check_and_set_pending(struct sock *sk)mptcp_sk (sk)->push_pending |=BIT (MPTCP_PUSH_PENDING ); } +static int __subflow_push_pending (struct sock *sk,struct sock *ssk, +struct mptcp_sendmsg_info *info) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_data_frag *dfrag; +int len, copied =0 ; + +while ((dfrag =mptcp_send_head (sk))) {
net/mptcp/protocol.c void mptcp_check_and_set_pending(struct sock *sk) · line 1531
Quoted 10 lines
net/mptcp/protocol.c +10
-0+ info->sent = dfrag->already_sent; + info->limit = dfrag->data_len; + len = dfrag->data_len - dfrag->already_sent; +while (len >0 ) { +int ret =0 ; + + ret =mptcp_sendmsg_frag (sk, ssk, dfrag, info); +if (ret <=0 ) { +if (ret == -EAGAIN ) +continue ;
In the older code, the scheduler got called again in the -EAGAIN case. With this refactored code, this could get in a very tight loop if mptcp_sendmsg_frag() returns. I think it's necessary to cleanly finish this loop iteration and let the scheduler run again in this -EAGAIN case.
Quoted 65 lines
net/mptcp/protocol.c +28
-26+ goto out; + } + + info->sent += ret; + copied += ret; + len -= ret; + +mptcp_update_post_push (msk, dfrag, ret); + } +WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); + +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); + } + +out: +if (copied) { +tcp_push (ssk,0 , info->mss_now,tcp_sk (ssk)->nonagle, + info->size_goal); + } + +return copied; +} +void __mptcp_push_pending (struct sock *sk,unsigned int flags) {struct mptcp_sock *msk =mptcp_sk (sk);@@ -1524,48 +1564,14 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags) .flags = flags, };bool do_check_data_fin = false; -struct mptcp_data_frag *dfrag;struct sock *ssk; -int len;while (mptcp_send_head (sk) && (ssk =mptcp_subflow_get_send (msk))) {lock_sock (ssk); - -while ((dfrag =mptcp_send_head (sk))) { - info.sent = dfrag->already_sent; - info.limit = dfrag->data_len; - len = dfrag->data_len - dfrag->already_sent; -while (len >0 ) { -int ret =0 ; - - ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) { -if (ret == -EAGAIN ) -continue ; -mptcp_push_release (ssk, &info); - goto out; - } - - do_check_data_fin = true; - info.sent += ret; - len -= ret; - -mptcp_update_post_push (msk, dfrag, ret); - } -WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); -
net/mptcp/protocol.c void __mptcp_push_pending(struct sock *sk, unsigned int flags) · line 1571
Quoted 10 lines
net/mptcp/protocol.c +1
-9-if (msk->snd_burst <=0 || - !sk_stream_memory_free (ssk) || - !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { - goto out; - } -mptcp_set_timeout (sk); - } - -mptcp_push_release (ssk, &info); + do_check_data_fin =__subflow_push_pending (sk, ssk, &info);
do_check_data_fin is a bool, but __subflow_push_pending() returns an int (the number of bytes copied). Looking at the other patches, the int value is needed. I suggest assigning the int return value to an int variable:
copied = __subflow_push_pending(sk, ssk, &info);
and updating the 'if' statement below...
Quoted 9 lines
net/mptcp/protocol.c +1
-1+release_sock (ssk); } -out:/* ensure the rtx timer is running */ if (!mptcp_timer_pending (sk))mptcp_reset_timer (sk);if (do_check_data_fin) __mptcp_check_send_data_fin(sk);
...like this:
if (copied > 0)
__mptcp_check_send_data_fin(sk);
Thanks,
--
Mat Martineau
Intel
PATCH v4 6/11 mptcp: multi subflows push_pending
In reply to Geliang TangThis patch adds the multiple subflows support for __mptcp_push_pending(). Use mptcp_sched_get_send() wrapper instead of mptcp_subflow_get_send() in it.
Check the subflow scheduled flags to test which subflow or subflows are picked by the scheduler, use them to send data.
--- net/mptcp/protocol.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
net/mptcp/protocol.c +18 -8
@@ -1560,16 +1560,26 @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk,void __mptcp_push_pending (struct sock *sk,unsigned int flags) {struct mptcp_sock *msk =mptcp_sk (sk); -struct mptcp_sendmsg_info info = { - .flags = flags, - };bool do_check_data_fin = false; -struct sock *ssk; -while (mptcp_send_head (sk) && (ssk =mptcp_subflow_get_send (msk))) { -lock_sock (ssk); - do_check_data_fin =__subflow_push_pending (sk, ssk, &info); -release_sock (ssk); +while (mptcp_send_head (sk) && !mptcp_sched_get_send (msk)) { +struct mptcp_subflow_context *subflow; +struct mptcp_sendmsg_info info = { + .flags = flags, + }; + +mptcp_for_each_subflow (msk, subflow) { +if (READ_ONCE (subflow->scheduled)) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); + +lock_sock (ssk); + do_check_data_fin =__subflow_push_pending (sk, ssk, &info); +release_sock (ssk); + + msk->last_snd = ssk; +mptcp_subflow_set_scheduled (subflow, false); + } + } }/* ensure the rtx timer is running */
Signature · 1 line
2.35.3
PATCH v4 7/11 mptcp: use msk instead of mptcp_sk
In reply to Geliang TangUse msk instead of mptcp_sk(sk) in the functions where the variable "msk = mptcp_sk(sk)" has been defined.
--- net/mptcp/protocol.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/mptcp/protocol.c +5 -5
@@ -1612,7 +1612,7 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,/* check for a different subflow usage only after * spooling the first chunk of data */ - xmit_ssk = first ? ssk :mptcp_subflow_get_send (mptcp_sk (sk)); + xmit_ssk = first ? ssk :mptcp_subflow_get_send (msk);if (!xmit_ssk) goto out;if (xmit_ssk != ssk) {
@@ -2242,7 +2242,7 @@ bool __mptcp_retransmit_pending_data(struct sock *sk)struct mptcp_data_frag *cur, *rtx_head;struct mptcp_sock *msk =mptcp_sk (sk); -if (__mptcp_check_fallback (mptcp_sk (sk))) +if (__mptcp_check_fallback (msk))return false;if (tcp_rtx_and_write_queues_empty (sk))
@@ -2924,7 +2924,7 @@ bool __mptcp_close(struct sock *sk, long timeout)sock_hold (sk);pr_debug ("msk=%p state=%d" , sk, sk->sk_state); -if (mptcp_sk (sk)->token) +if (msk->token)mptcp_event (MPTCP_EVENT_CLOSED , msk,NULL ,GFP_KERNEL );if (sk->sk_state ==TCP_CLOSE ) {
@@ -2983,8 +2983,8 @@ static int mptcp_disconnect(struct sock *sk, int flags)mptcp_stop_timer (sk);sk_stop_timer (sk, &sk->sk_timer); -if (mptcp_sk (sk)->token) -mptcp_event (MPTCP_EVENT_CLOSED ,mptcp_sk (sk),NULL ,GFP_KERNEL ); +if (msk->token) +mptcp_event (MPTCP_EVENT_CLOSED , msk,NULL ,GFP_KERNEL );/* msk->subflow is still intact, the following will not free the first * subflow
Signature · 1 line
2.35.3
PATCH v4 8/11 mptcp: refactor subflow_push_pending logic
In reply to Geliang TangThis patch refactors __mptcp_subflow_push_pending logic from:
For each dfrag:
While sends succeed: Call the scheduler (selects subflow and msk->snd_burst) Send the dfrag data with mptcp_subflow_delegate(), break Send the dfrag data with mptcp_sendmsg_frag() Update dfrag->already_sent, msk->snd_nxt, msk->snd_burst Update msk->first_pending
to:
While first_pending isn't empty:
Call the scheduler (selects subflow and msk->snd_burst) Send the dfrag data with mptcp_subflow_delegate(), break Send the dfrag data with mptcp_sendmsg_frag()
For each pending dfrag:
While sends succeed:
Send the dfrag data with mptcp_sendmsg_frag() Update already_sent, snd_nxt, snd_burst
Update msk->first_pending
Break if required by msk->snd_burst / etc
--- net/mptcp/protocol.c | 66 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-)
net/mptcp/protocol.c +34 -32
@@ -1602,44 +1602,46 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,int len, copied =0 ; info.flags =0 ; -while ((dfrag =mptcp_send_head (sk))) { - info.sent = dfrag->already_sent; - info.limit = dfrag->data_len; - len = dfrag->data_len - dfrag->already_sent; -while (len >0 ) { -int ret =0 ; +while (mptcp_send_head (sk)) { +/* check for a different subflow usage only after +* spooling the first chunk of data +*/ + xmit_ssk = first ? ssk :mptcp_subflow_get_send (msk); +if (!xmit_ssk) + goto out; +if (xmit_ssk != ssk) { +mptcp_subflow_delegate (mptcp_subflow_ctx (xmit_ssk), +MPTCP_DELEGATE_SEND ); + goto out; + } -/* check for a different subflow usage only after -* spooling the first chunk of data -*/ - xmit_ssk = first ? ssk :mptcp_subflow_get_send (msk); -if (!xmit_ssk) - goto out; -if (xmit_ssk != ssk) { -mptcp_subflow_delegate (mptcp_subflow_ctx (xmit_ssk), -MPTCP_DELEGATE_SEND ); - goto out; - } +while ((dfrag =mptcp_send_head (sk))) { + info.sent = dfrag->already_sent; + info.limit = dfrag->data_len; + len = dfrag->data_len - dfrag->already_sent; +while (len >0 ) { +int ret =0 ; - ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) - goto out; + ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); +if (ret <=0 ) + goto out; - info.sent += ret; - copied += ret; - len -= ret; - first = false; + info.sent += ret; + copied += ret; + len -= ret; + first = false; -mptcp_update_post_push (msk, dfrag, ret); - } -WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); +mptcp_update_post_push (msk, dfrag, ret); + } +WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); -if (msk->snd_burst <=0 || - !sk_stream_memory_free (ssk) || - !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { - goto out; +if (msk->snd_burst <=0 || + !sk_stream_memory_free (ssk) || + !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { + goto out; + } +mptcp_set_timeout (sk); } -mptcp_set_timeout (sk); } out:
Signature · 1 line
2.35.3
PATCH v4 9/11 mptcp: simplify subflow_push_pending
In reply to Geliang TangThis patch simplifies __mptcp_subflow_push_pending() by invoking __subflow_push_pending() helper.
--- net/mptcp/protocol.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-)
net/mptcp/protocol.c +4 -31
@@ -1596,10 +1596,9 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,struct mptcp_sendmsg_info info = { .data_lock_held = true, }; -struct mptcp_data_frag *dfrag;bool first = ssk_first;struct sock *xmit_ssk; -int len, copied =0 ; +int copied =0 ; info.flags =0 ;while (mptcp_send_head (sk)) {
@@ -1615,33 +1614,9 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, goto out; } -while ((dfrag =mptcp_send_head (sk))) { - info.sent = dfrag->already_sent; - info.limit = dfrag->data_len; - len = dfrag->data_len - dfrag->already_sent; -while (len >0 ) { -int ret =0 ; - - ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) - goto out; - - info.sent += ret; - copied += ret; - len -= ret; - first = false; - -mptcp_update_post_push (msk, dfrag, ret); - } -WRITE_ONCE (msk->first_pending,mptcp_send_next (sk)); - -if (msk->snd_burst <=0 || - !sk_stream_memory_free (ssk) || - !mptcp_subflow_active (mptcp_subflow_ctx (ssk))) { - goto out; - } -mptcp_set_timeout (sk); - } + copied =__subflow_push_pending (sk, ssk, &info); +if (!copied) +break ; } out:
@@ -1649,8 +1624,6 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,* not going to flush it via release_sock() */ if (copied) { -tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, - info.size_goal);if (!mptcp_timer_pending (sk))mptcp_reset_timer (sk);
Signature · 1 line
2.35.3
PATCH v4 10/11 mptcp: multi subflows subflow_push_pending
In reply to Geliang TangThis patch adds the multiple subflows support for __mptcp_subflow_push_pending(). Use mptcp_sched_get_send() wrapper instead of mptcp_subflow_get_send() in it.
Check the subflow scheduled flags to test which subflow or subflows are picked by the scheduler, use them to send data.
--- net/mptcp/protocol.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-)
net/mptcp/protocol.c +32 -11
@@ -1593,11 +1593,11 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool ssk_first) {struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_subflow_context *subflow;struct mptcp_sendmsg_info info = { .data_lock_held = true, };bool first = ssk_first; -struct sock *xmit_ssk;int copied =0 ; info.flags =0 ;
@@ -1605,18 +1605,39 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk,/* check for a different subflow usage only after * spooling the first chunk of data */ - xmit_ssk = first ? ssk :mptcp_subflow_get_send (msk); -if (!xmit_ssk) - goto out; -if (xmit_ssk != ssk) { -mptcp_subflow_delegate (mptcp_subflow_ctx (xmit_ssk), -MPTCP_DELEGATE_SEND ); - goto out; +if (first) { + copied =__subflow_push_pending (sk, ssk, &info); +if (!copied) +break ; + first = false; + msk->last_snd = ssk; +continue ; } - copied =__subflow_push_pending (sk, ssk, &info); -if (!copied) -break ; +if (mptcp_sched_get_send (msk)) + goto out; + +mptcp_for_each_subflow (msk, subflow) { +if (READ_ONCE (subflow->scheduled)) { +struct sock *xmit_ssk =mptcp_subflow_tcp_sock (subflow); + +if (xmit_ssk != ssk) { +if (mptcp_subflow_has_delegated_action (subflow)) + goto out; +mptcp_subflow_delegate (mptcp_subflow_ctx (xmit_ssk), +MPTCP_DELEGATE_SEND ); + msk->last_snd = xmit_ssk; +mptcp_subflow_set_scheduled (subflow, false); +continue ; + } + + copied =__subflow_push_pending (sk, ssk, &info); +if (!copied) + goto out; + msk->last_snd = ssk; +mptcp_subflow_set_scheduled (subflow, false); + } + } } out:
Signature · 1 line
2.35.3
PATCH v4 11/11 mptcp: multi subflows retrans support
In reply to Geliang TangThis patch adds the multiple subflows support for __mptcp_retrans(). In it, use sched_get_retrans() wrapper instead of mptcp_subflow_get_retrans().
Iterate each subflow of msk, check the scheduled flag to test if it is picked by the scheduler. If so, use it to retrans data.
--- net/mptcp/protocol.c | 62 ++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 23 deletions(-)
net/mptcp/protocol.c +39 -23
@@ -2468,16 +2468,17 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)static void __mptcp_retrans (struct sock *sk) {struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_subflow_context *subflow;struct mptcp_sendmsg_info info = {};struct mptcp_data_frag *dfrag; -size_t copied =0 ;struct sock *ssk; -int ret; +int ret, err; +u16 len =0 ;mptcp_clean_una_wakeup (sk);/* first check ssk: need to kick "stale" logic */ - ssk =mptcp_subflow_get_retrans (msk); + err =mptcp_sched_get_retrans (msk); dfrag =mptcp_rtx_head (sk);if (!dfrag) {if (mptcp_data_fin_enabled (msk)) {
@@ -2496,31 +2497,46 @@ static void __mptcp_retrans(struct sock *sk) goto reset_timer; } -if (!ssk) +if (err) goto reset_timer; -lock_sock (ssk); +mptcp_for_each_subflow (msk, subflow) { +if (READ_ONCE (subflow->scheduled)) { +u16 copied =0 ; + + ssk =mptcp_subflow_tcp_sock (subflow); +if (!ssk) + goto reset_timer; + +lock_sock (ssk); + +/* limit retransmission to the bytes already sent on some subflows */ + info.sent =0 ; + info.limit =READ_ONCE (msk->csum_enabled) ? dfrag->data_len : + dfrag->already_sent; +while (info.sent < info.limit) { + ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); +if (ret <=0 ) +break ; + +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RETRANSSEGS ); + copied += ret; + info.sent += ret; + } +if (copied) { + len =max (copied, len); +tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, + info.size_goal); +WRITE_ONCE (msk->allow_infinite_fallback, false); + } -/* limit retransmission to the bytes already sent on some subflows */ - info.sent =0 ; - info.limit =READ_ONCE (msk->csum_enabled) ? dfrag->data_len : dfrag->already_sent; -while (info.sent < info.limit) { - ret =mptcp_sendmsg_frag (sk, ssk, dfrag, &info); -if (ret <=0 ) -break ; +release_sock (ssk); -MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RETRANSSEGS ); - copied += ret; - info.sent += ret; - } -if (copied) { - dfrag->already_sent =max (dfrag->already_sent, info.sent); -tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, - info.size_goal); -WRITE_ONCE (msk->allow_infinite_fallback, false); + msk->last_snd = ssk; +mptcp_subflow_set_scheduled (subflow, false); + } } - -release_sock (ssk); + dfrag->already_sent =max (dfrag->already_sent, len); reset_timer:mptcp_check_and_set_pending (sk);
Signature · 1 line
2.35.3
Re: mptcp: multi subflows retrans support: Tests Results
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal:
- Success! ✅:
- Task: https://cirrus-ci.com/task/6082444804751360
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6082444804751360/summary/summary.txt
- {"code":404,"message":
- "Can't find artifacts containing file conclusion.txt"}:
- Task: https://cirrus-ci.com/task/5519494851330048
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5519494851330048/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/bc515f11df5d
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)