public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>,
	netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	passt-dev@passt.top, sbrivio@redhat.com, lvivier@redhat.com,
	dgibson@redhat.com, eric.dumazet@gmail.com,
	Menglong Dong <menglong8.dong@gmail.com>
Subject: Re: [net,v2] tcp: correct handling of extreme memory squeeze
Date: Fri, 24 Jan 2025 12:40:16 -0500	[thread overview]
Message-ID: <e15ff7f6-00b7-4071-866a-666a296d0b15@redhat.com> (raw)
In-Reply-To: <CANn89i+RRxyROe3wx6f4y1nk92Y-0eaahjh-OGb326d8NZnK9A@mail.gmail.com>



On 2025-01-20 11:22, Eric Dumazet wrote:
> On Mon, Jan 20, 2025 at 5:10 PM Jon Maloy <jmaloy@redhat.com> wrote:
>>
>>
>>
>> On 2025-01-20 00:03, Jon Maloy wrote:
>>>
>>>

[...]

>>>> I agree with Eric that probably tp->pred_flags should be cleared, and
>>>> a packetdrill test for this would be super-helpful.
>>>
>>> I must admit I have never used packetdrill, but I can make an effort.
>>
>> I hear from other sources that you cannot force a memory exhaustion with
>> packetdrill anyway, so this sounds like a pointless exercise.
> 
> We certainly can and should add a feature like that to packetdrill.
> 
> Documentation/fault-injection/ has some relevant information.
> 
> Even without this, tcp_try_rmem_schedule() is reading sk->sk_rcvbuf
> that could be lowered by a packetdrill script I think.
> 
Neal, Eric,
How do you suggest we proceed with this?
I downloaded packetdrill and tried it a bit, but to understand it well 
enough to introduce a new feature would require more time than I am
able to spend on this. Maybe Neal, who I see is one of the contributors 
to packetdrill could help out?

I can certainly clear tp->pred_flags and post it again, maybe with
an improved and shortened log. Would that be acceptable?

I also made a run where I looked into why __tcp_select_window()
ignores all the space that has been freed up:


  tcp_recvmsg_locked(->)
    __tcp_cleanup_rbuf(->) (copied 131072)
      tp->rcv_wup: 1788299855, tp->rcv_wnd: 5812224,
      tp->rcv_nxt 1793800175
      __tcp_select_window(->)
        tcp_space(->)
        tcp_space(<-) returning 458163
        free_space = round_down(458163, 1 << 4096) = 454656
        (free_space > tp->rcv_ssthresh) -->
          free_space = tp->rcv_ssthresh = 261920
        window = ALIGN(261920, 4096) = 26144
      __tcp_select_window(<-) returning 262144
      [rcv_win_now 311904, 2 * rcv_win_now 623808, new_window 262144]
      (new_window >= (2 * rcv_win_now)) ? --> time_to_ack 0
      NOT calling tcp_send_ack()
    __tcp_cleanup_rbuf(<-)
    [tp->rcv_wup 1788299855, tp->rcv_wnd 5812224,
     tp->rcv_nxt 1793800175]
  tcp_recvmsg_locked(<-) returning 131072 bytes.
  [tp->rcv_nxt 1793800175, tp->rcv_wnd 5812224,
   tp->rcv_wup 1788299855, sk->last_ack 0, tcp_receive_win() 311904,
   copied_seq 1788299855->1788395953 (96098), unread 5404222,
   sk_rcv_qlen 83, ofo_qlen 0]


As we see tp->rcv_ssthresh is the limiting factor, causing
a consistent situation where (new_window < (rcv_win_now * 2)),
and even (new_window < rcv_win_now).

To me, it looks like tp->ssthresh should have a higher value
in this situation, or maybe we should alter this test.

The combination of these two issues, -not updating tp->wnd and
_tcp_select_window() returning a wrong value, is what is causing
this whole problem.

///jon






  reply	other threads:[~2025-01-24 17:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-17 21:40 [net,v2] tcp: correct handling of extreme memory squeeze jmaloy
2025-01-17 22:09 ` Eric Dumazet
2025-01-17 22:27   ` Stefano Brivio
2025-01-18 17:01 ` Jason Xing
2025-01-18 20:04 ` Neal Cardwell
2025-01-20  5:03   ` Jon Maloy
2025-01-20 16:10     ` Jon Maloy
2025-01-20 16:22       ` Eric Dumazet
2025-01-24 17:40         ` Jon Maloy [this message]
2025-01-27  9:53           ` Eric Dumazet
2025-01-27 10:01           ` Stefano Brivio
2025-01-27 10:06             ` Eric Dumazet
2025-01-27 10:27               ` Stefano Brivio
2025-01-27 10:17             ` Jason Xing
2025-01-27 10:32               ` Stefano Brivio
2025-01-27 13:37                 ` Menglong Dong
2025-01-27 14:03                   ` Stefano Brivio
2025-01-27 16:37           ` Eric Dumazet
  -- strict thread matches above, loose matches on Subject: below --
2025-01-16  2:29 [net, v2] " Jon Maloy
2025-01-16 21:14 ` Stefano Brivio

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=e15ff7f6-00b7-4071-866a-666a296d0b15@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dgibson@redhat.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lvivier@redhat.com \
    --cc=menglong8.dong@gmail.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).