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:[email protected]] 发送时间: 2019年12月18日 4:14 收件人: [email protected] 抄送: [email protected]; [email protected]; Yi Yang (杨�D)-云服务集 团 <[email protected]> 主题: Re: [PATCH] Use batch process recv for tap and raw socket in netdev datapath On Fri, Dec 06, 2019 at 02:09:24AM -0500, [email protected] wrote: > From: Yi Yang <[email protected]> > > 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 */
_______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
