Skip to content

Commit

Permalink
Revert "debug fix"
Browse files Browse the repository at this point in the history
This reverts commit 08160fd.
  • Loading branch information
Geliang Tang committed Apr 25, 2024
1 parent 164e512 commit c070279
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 88 deletions.
28 changes: 7 additions & 21 deletions net/core/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,34 +117,25 @@ EXPORT_SYMBOL(sk_stream_wait_close);
*/
int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
{
int ret, err = 0, i = 0;
int ret, err = 0;
long vm_wait = 0;
long current_timeo = *timeo_p;
DEFINE_WAIT_FUNC(wait, woken_wake_function);

if (sk_stream_memory_free(sk)) {
if (sk_stream_memory_free(sk))
current_timeo = vm_wait = get_random_u32_below(HZ / 5) + 2;
} else
pr_info("%s\n", __func__);

add_wait_queue(sk_sleep(sk), &wait);

while (1) {
pr_info("%s i=%d timeo_p=%ld current_timeo=%ld vm_wait=%ld \n", __func__, i++, *timeo_p, current_timeo, vm_wait);
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);

if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) {
pr_info("%s goto do_error 1\n", __func__);
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
goto do_error;
}
if (!*timeo_p) {
pr_info("%s goto do_eagain 1 current_timeo=%ld\n", __func__, current_timeo);
if (!*timeo_p)
goto do_eagain;
}
if (signal_pending(current)) {
pr_info("%s goto do_interrupted 1\n", __func__);
if (signal_pending(current))
goto do_interrupted;
}
sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
if (sk_stream_memory_free(sk) && !vm_wait)
break;
Expand All @@ -156,20 +147,15 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
(sk_stream_memory_free(sk) && !vm_wait),
&wait);
sk->sk_write_pending--;
if (ret < 0) {
pr_info("%s goto do_error 2\n", __func__);
if (ret < 0)
goto do_error;
}

if (vm_wait) {
vm_wait -= current_timeo;
current_timeo = *timeo_p;
if (current_timeo != MAX_SCHEDULE_TIMEOUT &&
(current_timeo -= vm_wait) < 0) {
pr_info("%s set current_timeo = 0\n", __func__);
(current_timeo -= vm_wait) < 0)
current_timeo = 0;
}
pr_info("%s set vm_wait = 0\n", __func__);
vm_wait = 0;
}
*timeo_p = current_timeo;
Expand Down
77 changes: 10 additions & 67 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,9 +1420,6 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
if (!mptcp_subflow_active(subflow))
continue;

//if (tcp_rtx_and_write_queues_empty(ssk))
// continue;

tout = max(tout, mptcp_timeout_from_subflow(subflow));
nr_active += !subflow->backup;
pace = subflow->avg_pacing_rate;
Expand Down Expand Up @@ -1458,10 +1455,8 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
* to check that subflow has a non empty cwin.
*/
ssk = send_info[SSK_MODE_ACTIVE].ssk;
if (!ssk || !sk_stream_memory_free(ssk)) {
pr_info("%s return NULL", __func__);
if (!ssk || !sk_stream_memory_free(ssk))
return NULL;
}

burst = min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt);
wmem = READ_ONCE(ssk->sk_wmem_queued);
Expand Down Expand Up @@ -1550,7 +1545,6 @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk,
!sk_stream_memory_free(ssk) ||
!mptcp_subflow_active(mptcp_subflow_ctx(ssk))) {
err = copied;
//pr_info("%s goto out", __func__);
goto out;
}
mptcp_set_timeout(sk);
Expand Down Expand Up @@ -1662,10 +1656,8 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk, bool
if (READ_ONCE(subflow->scheduled)) {
mptcp_subflow_set_scheduled(subflow, false);
ret = __subflow_push_pending(sk, ssk, &info);
if (ret <= 0) {
pr_info("%s not keep_pushing ret=%d", __func__, ret);
if (ret <= 0)
keep_pushing = false;
}
copied += ret;
}

Expand Down Expand Up @@ -1791,8 +1783,6 @@ static u32 mptcp_send_limit(const struct sock *sk)
return limit - not_sent;
}

static void __mptcp_retrans(struct sock *sk);

static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
{
struct mptcp_sock *msk = mptcp_sk(sk);
Expand All @@ -1814,28 +1804,21 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
copied += copied_syn;
if (ret == -EINPROGRESS && copied_syn > 0)
goto out;
else if (ret) {
pr_info("%s goto do_error 1\n", __func__);
else if (ret)
goto do_error;
}
}

//again:
timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);

if ((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) {
ret = sk_stream_wait_connect(sk, &timeo);
if (ret) {
pr_info("%s goto do_error 2\n", __func__);
if (ret)
goto do_error;
}
}

ret = -EPIPE;
if (unlikely(sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))) {
pr_info("%s goto do_error 3\n", __func__);
if (unlikely(sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)))
goto do_error;
}

pfrag = sk_page_frag(sk);

Expand All @@ -1848,21 +1831,17 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)

/* ensure fitting the notsent_lowat() constraint */
copy_limit = mptcp_send_limit(sk);
if (!copy_limit) {
//pr_info("%s goto wait_for_memory 1\n", __func__);
if (!copy_limit)
goto wait_for_memory;
}

/* reuse tail pfrag, if possible, or carve a new one from the
* page allocator
*/
dfrag = mptcp_pending_tail(sk);
dfrag_collapsed = mptcp_frag_can_collapse_to(msk, pfrag, dfrag);
if (!dfrag_collapsed) {
if (!mptcp_page_frag_refill(sk, pfrag)) {
pr_info("%s goto wait_for_memory 2\n", __func__);
if (!mptcp_page_frag_refill(sk, pfrag))
goto wait_for_memory;
}

dfrag = mptcp_carve_data_frag(msk, pfrag, pfrag->offset);
frag_truesize = dfrag->overhead;
Expand All @@ -1878,17 +1857,13 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
psize = min_t(size_t, psize, copy_limit);
total_ts = psize + frag_truesize;

if (!sk_wmem_schedule(sk, total_ts)) {
pr_info("%s goto wait_for_memory 3\n", __func__);
if (!sk_wmem_schedule(sk, total_ts))
goto wait_for_memory;
}

ret = do_copy_data_nocache(sk, psize, &msg->msg_iter,
page_address(dfrag->page) + offset);
if (ret) {
pr_info("%s goto do_error 4\n", __func__);
if (ret)
goto do_error;
}

/* data successfully copied into the write queue */
sk_forward_alloc_add(sk, -total_ts);
Expand Down Expand Up @@ -1917,50 +1892,23 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
wait_for_memory:
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
__mptcp_push_pending(sk, msg->msg_flags);
//again:
pr_info("%s in wait_for_memory timeo=%ld\n", __func__, timeo);
ret = sk_stream_wait_memory(sk, &timeo);
if (ret) {
pr_info("%s goto do_error 5 err=%d timeo=%ld tcp_rtx_and_write_queues_empty=%d\n", __func__, ret, timeo, tcp_rtx_and_write_queues_empty(sk));
/* make sure we wake any epoll edge trigger waiter */
if (unlikely(tcp_rtx_and_write_queues_empty(sk) && ret == -EAGAIN)) {
//sk->sk_write_space(sk);
//tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);
//continue;
//goto again;
//goto wait_for_memory;
//__mptcp_retrans(sk);
//__mptcp_retransmit_pending_data(sk);
//sk_stream_memory_free(sk);
//clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
//timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
//return 0;
;
}
if (ret)
goto do_error;
}
}

if (copied)
__mptcp_push_pending(sk, msg->msg_flags);

out:
release_sock(sk);
if (copied == -EAGAIN)
pr_info("%s EAGAIN\n", __func__);
return copied;

do_error:
pr_info("%s do_error copied=%ld\n", __func__, copied);
if (copied)
goto out;

copied = sk_stream_error(sk, msg->msg_flags, ret);
/* make sure we wake any epoll edge trigger waiter */
//if (unlikely(tcp_rtx_and_write_queues_empty(sk) && copied == -EAGAIN)) {
// sk->sk_write_space(sk);
// tcp_chrono_stop(sk, TCP_CHRONO_SNDBUF_LIMITED);
//}
goto out;
}

Expand Down Expand Up @@ -2223,8 +2171,6 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
}

timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
//if (!timeo)
// pr_info("%s timeo=0\n", __func__);

len = min_t(size_t, len, INT_MAX);
target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
Expand Down Expand Up @@ -2284,7 +2230,6 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
}

if (!timeo) {
pr_info("%s EAGAIN\n", __func__);
copied = -EAGAIN;
break;
}
Expand Down Expand Up @@ -2318,8 +2263,6 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
mptcp_rcv_space_adjust(msk, copied);

release_sock(sk);
if (copied == -EAGAIN)
pr_info("%s EAGAIN\n", __func__);
return copied;
}

Expand Down

0 comments on commit c070279

Please sign in to comment.