From patchwork Fri Feb 24 06:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 61137 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp740839wrd; Thu, 23 Feb 2023 22:45:01 -0800 (PST) X-Google-Smtp-Source: AK7set+2ysGitshvk0KXD/VC7pMo4yRNIzpMIeRLytrBoK3UCHEgGNVVtj2Nx3h826TjvkIsJpZT X-Received: by 2002:a05:6a21:7889:b0:cc:5f27:d003 with SMTP id bf9-20020a056a21788900b000cc5f27d003mr2699206pzc.56.1677221100847; Thu, 23 Feb 2023 22:45:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677221100; cv=none; d=google.com; s=arc-20160816; b=EL3xgSkj5vcZ1n4c9aaqBiZ146nisywt1WW0Sg5t0JFBpwbVrlxfWrOEHYQbGZSI+Z wPvW428K9XL/zjTFPsZj8FHR5Og9cnEXVETP7XGychVAdNWN35ganJKXA0zsZxk98t8r 8VHshrriG8bZWZXizKAjIQmA2OsuryPi+wIuKLPHRed/hxBYcXqL9bExHmtURAbFk9ef qJb9HpE3DRrmP+1vJOfKAuHjQyk7Gk3qhe9cIIEYcz0fn6F3g9WSyo84iXyGT2BHlUWb 5eDtH97c2gaBXQQJwKJuQlBijJ5fFqrjk+qS+BKEDJnVT4CUgiAs+7nwuDfCbCS8ReWn zKKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=xk88ESEofXIk5vFzr/ZmmLF921PM85krFQ14woMgXv8=; b=ayt10MSGu7D+HBhAeeCKoAKzAZx/wblDc1H9b4Yx2kveUl5FrXIKskjGuRgaoQ9uw6 FQP/jnC8KwI+hcezmsy2Z7ZlDGrUUUAse4Tsd3DJtlFTN98mDhkgHi1rI4l8DY24mRjd j00MPQ5LGb6uvWeJdspTFsQBGQk9GZl8nvQPMlgEQFQWmxEktb3U01U1xaToeUdqowgM F8Lm4cUPV3+WTCmAfEeoIugOZSh/fq8YyiXw2flcbdXl9yc9IBJxrCkShCjMd+5QyjPd v0bK2ZhWyYPnXkhgB3a+OOoNwhIInoIcgKYLmOTOpHVEcWgsySNh80n/XfAOBnN/L1be lhcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a655184000000b004fbcde9147dsi7704456pgq.375.2023.02.23.22.44.47; Thu, 23 Feb 2023 22:45:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbjBXGjJ (ORCPT + 99 others); Fri, 24 Feb 2023 01:39:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjBXGjH (ORCPT ); Fri, 24 Feb 2023 01:39:07 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C50A60D78; Thu, 23 Feb 2023 22:39:05 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4PNKx26CWfz501RX; Fri, 24 Feb 2023 14:39:02 +0800 (CST) Received: from szxlzmapp03.zte.com.cn ([10.5.231.207]) by mse-fl1.zte.com.cn with SMTP id 31O6cpsx044681; Fri, 24 Feb 2023 14:38:51 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Fri, 24 Feb 2023 14:38:53 +0800 (CST) Date: Fri, 24 Feb 2023 14:38:53 +0800 (CST) X-Zmail-TransId: 2b0363f85b7d4e2e0d35 X-Mailer: Zmail v1.0 Message-ID: <202302241438536013777@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_selftests=3A_net=3A_udpgso=5Fbench?= =?utf-8?q?=5Ftx=3A_Add_test_for_IP_fragmentation_of_UDP_packets?= X-MAIL: mse-fl1.zte.com.cn 31O6cpsx044681 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63F85B86.002/4PNKx26CWfz501RX X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758693793170540887?= X-GMAIL-MSGID: =?utf-8?q?1758693793170540887?= From: zhang yunkai (CGEL ZTE) The UDP GSO bench only tests the performance of userspace payload splitting and UDP GSO. But we are also concerned about the performance comparing with IP fragmentation and UDP GSO. In other words comparing IP fragmentation and segmentation. So we add testcase of IP fragmentation of UDP packets, then user would easy to get to know the performance promotion of UDP GSO compared with IP fragmentation. We add a new option "-f", which is to send big data using IP fragmentation instead of using UDP GSO or userspace payload splitting. In the QEMU environment we could see obvious promotion of UDP GSO. The first test is to get the performance of userspace payload splitting. bash# udpgso_bench_tx -l 4 -4 -D "$DST" udp tx: 10 MB/s 7812 calls/s 186 msg/s udp tx: 10 MB/s 7392 calls/s 176 msg/s udp tx: 11 MB/s 7938 calls/s 189 msg/s udp tx: 11 MB/s 7854 calls/s 187 msg/s The second test is to get the performance of IP fragmentation. bash# udpgso_bench_tx -l 4 -4 -D "$DST" -f udp tx: 33 MB/s 572 calls/s 572 msg/s udp tx: 33 MB/s 563 calls/s 563 msg/s udp tx: 31 MB/s 540 calls/s 540 msg/s udp tx: 33 MB/s 571 calls/s 571 msg/s The third test is to get the performance of UDP GSO. bash# udpgso_bench_tx -l 4 -4 -D "$DST" -S 0 udp tx: 46 MB/s 795 calls/s 795 msg/s udp tx: 49 MB/s 845 calls/s 845 msg/s udp tx: 49 MB/s 847 calls/s 847 msg/s udp tx: 45 MB/s 774 calls/s 774 msg/s Signed-off-by: zhang yunkai (CGEL ZTE) Reviewed-by: xu xin (CGEL ZTE) Reviewed-by: Yang Yang (CGEL ZTE) Cc: Xuexin Jiang (CGEL ZTE) --- tools/testing/selftests/net/udpgso_bench_tx.c | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c index 477392715a9a..025e706b594b 100644 --- a/tools/testing/selftests/net/udpgso_bench_tx.c +++ b/tools/testing/selftests/net/udpgso_bench_tx.c @@ -64,6 +64,7 @@ static int cfg_runtime_ms = -1; static bool cfg_poll; static int cfg_poll_loop_timeout_ms = 2000; static bool cfg_segment; +static bool cfg_fragment; static bool cfg_sendmmsg; static bool cfg_tcp; static uint32_t cfg_tx_ts = SOF_TIMESTAMPING_TX_SOFTWARE; @@ -375,6 +376,21 @@ static int send_udp_sendmmsg(int fd, char *data) return ret; } +static int send_udp_fragment(int fd, char *data) +{ + int ret; + + ret = sendto(fd, data, cfg_payload_len, cfg_zerocopy ? MSG_ZEROCOPY : 0, + cfg_connected ? NULL : (void *)&cfg_dst_addr, + cfg_connected ? 0 : cfg_alen); + if (ret == -1) + error(1, errno, "write"); + if (ret != cfg_payload_len) + error(1, errno, "write: %uB != %uB\n", ret, cfg_payload_len); + + return 1; +} + static void send_udp_segment_cmsg(struct cmsghdr *cm) { uint16_t *valp; @@ -429,7 +445,7 @@ static int send_udp_segment(int fd, char *data) static void usage(const char *filepath) { - error(1, 0, "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] " + error(1, 0, "Usage: %s [-46acfmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] " "[-L secs] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]", filepath); } @@ -440,7 +456,7 @@ static void parse_opts(int argc, char **argv) int max_len, hdrlen; int c; - while ((c = getopt(argc, argv, "46acC:D:Hl:L:mM:p:s:PS:tTuvz")) != -1) { + while ((c = getopt(argc, argv, "46acC:D:fHl:L:mM:p:s:PS:tTuvz")) != -1) { switch (c) { case '4': if (cfg_family != PF_UNSPEC) @@ -469,6 +485,9 @@ static void parse_opts(int argc, char **argv) case 'l': cfg_runtime_ms = strtoul(optarg, NULL, 10) * 1000; break; + case 'f': + cfg_fragment = true; + break; case 'L': cfg_poll_loop_timeout_ms = strtoul(optarg, NULL, 10) * 1000; break; @@ -527,10 +546,10 @@ static void parse_opts(int argc, char **argv) error(1, 0, "must pass one of -4 or -6"); if (cfg_tcp && !cfg_connected) error(1, 0, "connectionless tcp makes no sense"); - if (cfg_segment && cfg_sendmmsg) - error(1, 0, "cannot combine segment offload and sendmmsg"); - if (cfg_tx_tstamp && !(cfg_segment || cfg_sendmmsg)) - error(1, 0, "Options -T and -H require either -S or -m option"); + if ((cfg_segment + cfg_sendmmsg + cfg_fragment) > 1) + error(1, 0, "cannot combine segment offload , fragment and sendmmsg"); + if (cfg_tx_tstamp && !(cfg_segment || cfg_sendmmsg || cfg_fragment)) + error(1, 0, "Options -T and -H require either -S or -m or -f option"); if (cfg_family == PF_INET) hdrlen = sizeof(struct iphdr) + sizeof(struct udphdr); @@ -695,6 +714,8 @@ int main(int argc, char **argv) num_sends += send_udp_segment(fd, buf[i]); else if (cfg_sendmmsg) num_sends += send_udp_sendmmsg(fd, buf[i]); + else if (cfg_fragment) + num_sends += send_udp_fragment(fd, buf[i]); else num_sends += send_udp(fd, buf[i]); num_msgs++;