net: limit TCP and UDP send/recv buffer usage with throttled IOB#18011
Conversation
The main content of this submission is to limit both the TX/RX buffers of TCP/UDP to throttled IOBs, avoiding impacts on the sending and receiving of control-type messages. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
|
@zhhyu7 I just tried this commit and the one before but compared to NuttX 12.12 the network regressed competely where it's not working anymore on the NXP i.MXRT. |
|
Well in this case it is better to revert and investigate further. I can assist with more tests using IPERF over Wi-Fi. |
eth0 Link encap:Ethernet HWaddr 0a:0e:82:92:b3:7f at UP mtu 1504 @PetervdPerk-NXP It seems to be related to the network card not entering the RUNNING state, the protocol stack will check the RUNNING flag when selecting the sending network card. |
@fdcavalcanti Thanks, If the test reveals that the robustness of the network protocol stack is worse than before this PR was merged, we can first revert this commit, and I will also conduct more detailed analysis and testing. |
|
Yes it seems we have issues (tested on esp32c3-devkit:wifi). Ping is fine but IPERF speed drops and stays there. |
This for pointing this out indeed it's that RUNNING flag doesn't get active to make ethernet work. Adding However, with this PR my network is even locking up faster and ifconfig locks up as well. Unfortunely I can't debug this anymore because of the regresssion defined in #18109 |
@fdcavalcanti May I ask which network card driver is used, arch/risc-v/src/esp32c3-legacy/esp32c3_wlan.c? |
|
@zhhyu7 The wireless interfacing is done on
|
@fdcavalcanti If netdev_upperhalf is used, it should be fine. Can we see what the backtrace of each thread are when it gets stuck? |
|
@zhhyu7 I tried on the
Seems they crash at the same place. |
|
Here's the backtrace for C6: |
@fdcavalcanti Get, Will iperf return to normal if this patch is reverted? Then I'll revert this patch first, and after optimizing the implementation, I'll find several more devices locally for detailed verification before proceeding further. Thanks a lot. |
|
Yes, if I revert the commit IPERF is able to complete. |
#18113 this is the revert PR. I will subsequently conduct verification based on the above devices first. |
@fdcavalcanti The total amount of IOB configured for the board is too small. When iperf writes 16k of data at once, if the write queue only uses unthrottled IOBs, there is a relatively high probability that the data in the write queue will exhaust the unthrottled IOBs but still be requesting a write buffer. At this point, the thread will block here, unable to trigger the subsequent tcp_send_txnotify, causing the data not to be sent out, and thus unable to receive an ack to release these IOBs, so it will never recover. You can try configuring CONFIG_NET_SEND_BUFSIZE=12000 (CONFIG_IOB_BUFSIZE * (CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE) - 4k), it should no longer get stuck. Please help to include this patch and the configuration of CONFIG_NET_SEND_BUFSIZE for verification when you have time. Thank you very much. I am synchronously optimizing the scenario where the TCP buffer writes too much data in a single operation (exceeding the total number of valid IOBs). |
|
Hi @zhhyu7 this is excellent input, thanks! I tried Here's my base IOB config:
I then rebooted the board and tried again. It had the same results regarding throughput but did not lose any IOB. Here's the log of the first run: After this, I kept it running for 5 minutes and it had very stable throughput (better then we ever had). Seems we are very near closure here. |
|
@fdcavalcanti which branch you're testing, unfortunately I'm facing other regressions on NuttX main that completely makes enet unusable for me. |
All right, thanks. I'm testing this branch (rebased) with the latest comments from @zhhyu7. |
Summary
The main content of this submission is to limit both the TX/RX buffers of TCP/UDP to throttled IOBs, avoiding impacts on the sending and receiving of control-type messages.
Impact
tcp_recvwindow.c,tcp_send_buffered.cudp_wrbuffer.c,tcp_callback.c,udp_send_buffered.cicmp_input.c,icmpv6_input.cpkt_netpool.c,pkt_sendmsg_buffered.cTesting
sim:matter with very small amount of IOB configuration
NuttX test log: