You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/01/05 14:25:26 UTC

[nuttx] branch master updated: net: downgrade iob priority of input/udp/icmp to avoid blocking devif

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new d87620abc9 net: downgrade iob priority of input/udp/icmp to avoid blocking devif
d87620abc9 is described below

commit d87620abc9db2a57d9bd8bf0477a32e3c380d141
Author: Zhe Weng <we...@xiaomi.com>
AuthorDate: Wed Dec 28 15:06:48 2022 +0800

    net: downgrade iob priority of input/udp/icmp to avoid blocking devif
    
    When trying to use iperf2, we found it comsumes all the IOB when sending UDP packets, then devif_poll has no IOB to send the packet out, so speed drops to 0 and never recovers.
    
    Signed-off-by: Zhe Weng <we...@xiaomi.com>
---
 net/icmp/icmp_reply.c         | 4 ++--
 net/icmp/icmp_sendmsg.c       | 2 +-
 net/icmpv6/icmpv6_reply.c     | 4 ++--
 net/icmpv6/icmpv6_sendmsg.c   | 2 +-
 net/netdev/netdev_input.c     | 2 +-
 net/netdev/netdev_iob.c       | 6 +++---
 net/udp/udp_sendto_buffered.c | 6 +++---
 net/udp/udp_wrbuffer.c        | 2 +-
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/icmp/icmp_reply.c b/net/icmp/icmp_reply.c
index ad9aed2963..1974e72dd5 100644
--- a/net/icmp/icmp_reply.c
+++ b/net/icmp/icmp_reply.c
@@ -146,7 +146,7 @@ void icmp_reply(FAR struct net_driver_s *dev, int type, int code)
 
       /* Re-prepare device buffer */
 
-      if (netdev_iob_prepare(dev, false, 0) != OK)
+      if (netdev_iob_prepare(dev, true, 0) != OK)
         {
           dev->d_len = 0;
           dev->d_iob = iob;
@@ -157,7 +157,7 @@ void icmp_reply(FAR struct net_driver_s *dev, int type, int code)
       /* Copy ipv4 header to device buffer */
 
       if (iob_trycopyin(dev->d_iob, (FAR void *)ipv4,
-                        IPv4_HDRLEN, 0, false) != IPv4_HDRLEN)
+                        IPv4_HDRLEN, 0, true) != IPv4_HDRLEN)
         {
           dev->d_len = 0;
           netdev_iob_release(dev);
diff --git a/net/icmp/icmp_sendmsg.c b/net/icmp/icmp_sendmsg.c
index 7e50f92774..da1666afd0 100644
--- a/net/icmp/icmp_sendmsg.c
+++ b/net/icmp/icmp_sendmsg.c
@@ -118,7 +118,7 @@ static void sendto_request(FAR struct net_driver_s *dev,
   iob_update_pktlen(dev->d_iob, IPv4_HDRLEN);
 
   iob_copyin(dev->d_iob, pstate->snd_buf,
-             pstate->snd_buflen, IPv4_HDRLEN, false);
+             pstate->snd_buflen, IPv4_HDRLEN, true);
 
   /* Initialize the IP header. */
 
diff --git a/net/icmpv6/icmpv6_reply.c b/net/icmpv6/icmpv6_reply.c
index e67f303c72..d368680613 100644
--- a/net/icmpv6/icmpv6_reply.c
+++ b/net/icmpv6/icmpv6_reply.c
@@ -135,7 +135,7 @@ void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data)
 
       /* Re-prepare device buffer */
 
-      if (netdev_iob_prepare(dev, false, 0) != OK)
+      if (netdev_iob_prepare(dev, true, 0) != OK)
         {
           dev->d_len = 0;
           dev->d_iob = iob;
@@ -146,7 +146,7 @@ void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data)
       /* Copy ipv4 header to device buffer */
 
       if (iob_trycopyin(dev->d_iob, (FAR void *)ipv6,
-                        IPv6_HDRLEN, 0, false) != IPv6_HDRLEN)
+                        IPv6_HDRLEN, 0, true) != IPv6_HDRLEN)
         {
           dev->d_len = 0;
           netdev_iob_release(dev);
diff --git a/net/icmpv6/icmpv6_sendmsg.c b/net/icmpv6/icmpv6_sendmsg.c
index 70bd8eefa1..379cd9ffba 100644
--- a/net/icmpv6/icmpv6_sendmsg.c
+++ b/net/icmpv6/icmpv6_sendmsg.c
@@ -120,7 +120,7 @@ static void sendto_request(FAR struct net_driver_s *dev,
   iob_update_pktlen(dev->d_iob, IPv6_HDRLEN);
 
   iob_copyin(dev->d_iob, pstate->snd_buf,
-             pstate->snd_buflen, IPv6_HDRLEN, false);
+             pstate->snd_buflen, IPv6_HDRLEN, true);
 
   /* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
 
diff --git a/net/netdev/netdev_input.c b/net/netdev/netdev_input.c
index a2669a4c98..ae03dce737 100644
--- a/net/netdev/netdev_input.c
+++ b/net/netdev/netdev_input.c
@@ -74,7 +74,7 @@ int netdev_input(FAR struct net_driver_s *dev,
 
   /* Prepare iob buffer */
 
-  ret = netdev_iob_prepare(dev, false, 0);
+  ret = netdev_iob_prepare(dev, true, 0);
   if (ret != OK)
     {
       return ret;
diff --git a/net/netdev/netdev_iob.c b/net/netdev/netdev_iob.c
index c13482cda3..15b466d8d8 100644
--- a/net/netdev/netdev_iob.c
+++ b/net/netdev/netdev_iob.c
@@ -60,10 +60,10 @@ int netdev_iob_prepare(FAR struct net_driver_s *dev, bool throttled,
 
   if (dev->d_iob == NULL)
     {
-      dev->d_iob = net_iobtimedalloc(false, timeout);
-      if (dev->d_iob == NULL && throttled)
+      dev->d_iob = net_iobtimedalloc(true, timeout);
+      if (dev->d_iob == NULL && throttled == false)
         {
-          dev->d_iob = net_iobtimedalloc(true, timeout);
+          dev->d_iob = net_iobtimedalloc(false, timeout);
         }
     }
 
diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c
index e5c36898fc..42b01a9ebe 100644
--- a/net/udp/udp_sendto_buffered.c
+++ b/net/udp/udp_sendto_buffered.c
@@ -795,7 +795,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
       if (nonblock)
         {
           ret = iob_trycopyin(wrb->wb_iob, (FAR uint8_t *)buf,
-                              len, udpiplen, false);
+                              len, udpiplen, true);
         }
       else
         {
@@ -809,7 +809,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
 
           blresult = net_breaklock(&count);
           ret = iob_copyin(wrb->wb_iob, (FAR uint8_t *)buf,
-                           len, udpiplen, false);
+                           len, udpiplen, true);
           if (blresult >= 0)
             {
               net_restorelock(count);
@@ -916,7 +916,7 @@ int psock_udp_cansend(FAR struct udp_conn_s *conn)
    * many more.
    */
 
-  if (udp_wrbuffer_test() < 0 || iob_navail(false) <= 0)
+  if (udp_wrbuffer_test() < 0 || iob_navail(true) <= 0)
     {
       return -EWOULDBLOCK;
     }
diff --git a/net/udp/udp_wrbuffer.c b/net/udp/udp_wrbuffer.c
index b4b14899a7..dacc65fa8a 100644
--- a/net/udp/udp_wrbuffer.c
+++ b/net/udp/udp_wrbuffer.c
@@ -263,7 +263,7 @@ FAR struct udp_wrbuffer_s *udp_wrbuffer_tryalloc(void)
 
   /* Now get the first I/O buffer for the write buffer structure */
 
-  wrb->wb_iob = iob_tryalloc(false);
+  wrb->wb_iob = iob_tryalloc(true);
   if (!wrb->wb_iob)
     {
       nerr("ERROR: Failed to allocate I/O buffer\n");