[ovs-dev] 答复: [PATCH] Use batch process recv for tap and raw socket in netdev datapath

=?gb2312?B?WWkgWWFuZyAo0e6gRCkt1Ma3/s7xvK/NxQ==?= yangyi01 at inspur.com
Wed Dec 18 02:01:47 UTC 2019


Ben, thank for your review, for recvmmsg, we have to prepare some buffers
for it, but we have no way to know how many packets are there for socket, so
these mallocs are must-have overhead, maybe self-adaptive malloc mechanism
is better, for example, the first receive just mallocs 4 buffers, if it
receives 4 buffers successfully, we can increase it to 8, till it is up to
32, if it can't receive all the buffers, we can decrease it by one half, but
this will make code complicated a bit.

Your fix is right, I should be set to 0 when retval < 0, thank for your
review again, I'll update it with your fix patch and send another version.

-----ÓʼþÔ­¼þ-----
·¢¼þÈË: Ben Pfaff [mailto:blp at ovn.org] 
·¢ËÍʱ¼ä: 2019Äê12ÔÂ18ÈÕ 4:14
ÊÕ¼þÈË: yang_y_yi at 163.com
³­ËÍ: ovs-dev at openvswitch.org; ian.stokes at intel.com; Yi Yang (Ñî D)-ÔÆ·þÎñ¼¯
ÍÅ <yangyi01 at inspur.com>
Ö÷Ìâ: Re: [PATCH] Use batch process recv for tap and raw socket in netdev
datapath

On Fri, Dec 06, 2019 at 02:09:24AM -0500, yang_y_yi at 163.com wrote:
> From: Yi Yang <yangyi01 at inspur.com>
> 
> Current netdev_linux_rxq_recv_tap and netdev_linux_rxq_recv_sock just 
> receive single packet, that is very inefficient, per my test case 
> which adds two tap ports or veth ports into OVS bridge
> (datapath_type=netdev) and use iperf3 to do performance test between 
> two ports (they are set into different network name space).

Thanks for the patch!  This is an impressive performance improvement!

Each call to netdev_linux_batch_rxq_recv_sock() now calls malloc() 32 times.
This is expensive if only a few packets (or none) are received.
Maybe it doesn't matter, but I wonder whether it affects performance.

I think that no packets are freed on error.  Fix:

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index
9cb45d5c7d29..3414a6495ced 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1198,6 +1198,7 @@ netdev_linux_batch_rxq_recv_sock(int fd, int mtu,
     if (retval < 0) {
         /* Save -errno to retval temporarily */
         retval = -errno;
+        i = 0;
         goto free_buffers;
     }
 

To get sparse to work, one must fold in the following:

diff --git a/include/sparse/sys/socket.h b/include/sparse/sys/socket.h index
4178f57e2bda..e954ade714b5 100644
--- a/include/sparse/sys/socket.h
+++ b/include/sparse/sys/socket.h
@@ -27,6 +27,7 @@
 
 typedef unsigned short int sa_family_t;  typedef __socklen_t socklen_t;
+struct timespec;
 
 struct sockaddr {
     sa_family_t sa_family;
@@ -171,4 +172,7 @@ int sockatmark(int);  int socket(int, int, int);  int
socketpair(int, int, int, int[2]);
 
+int sendmmsg(int, struct mmsghdr *, unsigned int, int); int 
+recvmmsg(int, struct mmsghdr *, unsigned int, int, struct timespec *);
+
 #endif /* <sys/socket.h> for sparse */


More information about the dev mailing list