From patchwork Tue Feb 6 13:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 127004 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2896068ljc; Tue, 6 Feb 2018 05:01:33 -0800 (PST) X-Google-Smtp-Source: AH8x226u/4U8AM4d4FCFtU6F7rq2llsn39/YpeRP8g5KJ3NuyVmderwq5Brncd6OcqoSM751Jm0P X-Received: by 10.55.163.77 with SMTP id m74mr3245229qke.256.1517922093783; Tue, 06 Feb 2018 05:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517922093; cv=none; d=google.com; s=arc-20160816; b=TA6wv9ZSBcUoGf0mBft9lyvrYRsth2cGs4FHaKMB71Z1nxORa68UHpCG9+gbiBLuHI 6zEey6mTS8fVkoe3rWuj1ZV+f8pCVuFojvcW5LE/4jEQM5NYfHAnGBc092eSEEOiRay3 EDvyUNIVtXLtNSaTJ62GcYbzbIVJAkMT1MSbT/oA/UwQtCGowdcbQyepM16Q/YqvZSBR NvoTh97cqCHHMI6rCeb/fdOKWT77SVF3iPqsCZ2drNCtXmqWOMrBkE6ZvVzqp+G4ffYx D+vTjlzgpn0iGlbf3g7gAtlgj/vDdTSdVrsHxqOftW21ShS8sErIgJcP9cP3hT9bwYq0 WNlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=fPRbZ/OBab9bYdm7/AK0uaWpYZFb4ly4QCMHQmSCA8I=; b=hm+BshmZtZ7bX2WK/8pBt0DY6zVKdwAPTk1hwo03rmsAfanfYSDgZ8hXo/li+uoF2J 4iOKZWpa6F4ScPLewxeGevK3gQlkq0TYtuvLe5l9DxqbuDeHey9qKgAXp8HW/8klnKdg v81xLSD+O7//LwxS2njv0xq9oPSBCygMwhZT3t+mUvkJ3d/an5G8MLlwyKD4elMAbkC+ yp+xoalZVUXmbCLF8TyYijrTS/L/2wK12txSyC4i58B6XZjkEbOOXzb+NS2EV1XcfXKr tuJ3lZiBihNsWHxoT7LJ4nb3TVjSJAkGKwbwP+uNi+Qd8ywBXIVo1ECvP5qMcA/R/exM L2gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id e58si1734819qtc.114.2018.02.06.05.01.33; Tue, 06 Feb 2018 05:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 6A36A608AA; Tue, 6 Feb 2018 13:01:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 5BC44608E8; Tue, 6 Feb 2018 13:00:35 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 247E5607B4; Tue, 6 Feb 2018 13:00:18 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id C2FB56181C for ; Tue, 6 Feb 2018 13:00:10 +0000 (UTC) Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 40F9D1802330 for ; Tue, 6 Feb 2018 16:00:09 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id QohUhLNA7e-09Ze4rSc; Tue, 06 Feb 2018 16:00:09 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id aFSEfmaddw-083eIX8Z; Tue, 06 Feb 2018 16:00:08 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 6 Feb 2018 16:00:06 +0300 Message-Id: <1517922007-6874-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517922007-6874-1-git-send-email-odpbot@yandex.ru> References: <1517922007-6874-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 455 Subject: [lng-odp] [PATCH API-NEXT v1 1/2] validation: pktio: recv tmo test improvements X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Add checks and improve test output when recv tmo function fails to timeout correctly. Signed-off-by: Petri Savolainen --- /** Email created from pull request 455 (psavol:next-fix-recv-tmo) ** https://github.com/Linaro/odp/pull/455 ** Patch: https://github.com/Linaro/odp/pull/455.patch ** Base sha: 1836820278b57de6144c75872e148976d49d28a2 ** Merge commit sha: 7aa3734cf260df25134c8b302983d3a79cf7c47c **/ test/validation/api/pktio/pktio.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 6592b2600..53a36145b 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -511,7 +511,7 @@ static int wait_for_packets(pktio_info_t *pktio_rx, odp_packet_t pkt_tbl[], static int recv_packets_tmo(odp_pktio_t pktio, odp_packet_t pkt_tbl[], uint32_t seq_tbl[], int num, recv_tmo_mode_e mode, - uint64_t tmo, uint64_t ns) + uint64_t tmo, uint64_t ns, int no_pkt) { odp_packet_t pkt_tmp[num]; odp_pktin_queue_t pktin[MAX_QUEUES]; @@ -542,8 +542,19 @@ static int recv_packets_tmo(odp_pktio_t pktio, odp_packet_t pkt_tbl[], num - num_rx, tmo); ts2 = odp_time_global(); + CU_ASSERT(n >= 0); + if (n <= 0) break; + + /* When we don't expect any packets, drop all packets and + * retry timeout test. */ + if (no_pkt) { + printf(" drop %i dummy packets\n", n); + odp_packet_free_multi(pkt_tmp, n); + continue; + } + for (i = 0; i < n; i++) { if (pktio_pkt_seq(pkt_tmp[i]) == seq_tbl[num_rx]) pkt_tbl[num_rx++] = pkt_tmp[i]; @@ -554,8 +565,15 @@ static int recv_packets_tmo(odp_pktio_t pktio, odp_packet_t pkt_tbl[], CU_ASSERT(from_val < (unsigned)num_q); } while (num_rx < num); - if (num_rx < num) - CU_ASSERT(odp_time_diff_ns(ts2, ts1) >= ns); + if (num_rx < num) { + uint64_t diff = odp_time_diff_ns(ts2, ts1); + + if (diff < ns) + printf(" diff %" PRIu64 ", ns %" PRIu64 "\n", + diff, ns); + + CU_ASSERT(diff >= ns); + } return num_rx; } @@ -967,8 +985,9 @@ static void test_recv_tmo(recv_tmo_mode_e mode) /* No packets sent yet, so should wait */ ns = 100 * ODP_TIME_MSEC_IN_NS; + ret = recv_packets_tmo(pktio_rx, &pkt_tbl[0], &pkt_seq[0], 1, mode, - odp_pktin_wait_time(ns), ns); + odp_pktin_wait_time(ns), ns, 1); CU_ASSERT(ret == 0); ret = create_packets(pkt_tbl, pkt_seq, test_pkt_count, pktio_tx, @@ -979,19 +998,19 @@ static void test_recv_tmo(recv_tmo_mode_e mode) CU_ASSERT_FATAL(ret == test_pkt_count); ret = recv_packets_tmo(pktio_rx, &pkt_tbl[0], &pkt_seq[0], 1, mode, - odp_pktin_wait_time(UINT64_MAX), 0); + odp_pktin_wait_time(UINT64_MAX), 0, 0); CU_ASSERT_FATAL(ret == 1); ret = recv_packets_tmo(pktio_rx, &pkt_tbl[1], &pkt_seq[1], 1, mode, - ODP_PKTIN_NO_WAIT, 0); + ODP_PKTIN_NO_WAIT, 0, 0); CU_ASSERT_FATAL(ret == 1); ret = recv_packets_tmo(pktio_rx, &pkt_tbl[2], &pkt_seq[2], 1, mode, - odp_pktin_wait_time(0), 0); + odp_pktin_wait_time(0), 0, 0); CU_ASSERT_FATAL(ret == 1); ret = recv_packets_tmo(pktio_rx, &pkt_tbl[3], &pkt_seq[3], 3, mode, - odp_pktin_wait_time(ns), ns); + odp_pktin_wait_time(ns), ns, 0); CU_ASSERT_FATAL(ret == 3); for (i = 0; i < test_pkt_count; i++) From patchwork Tue Feb 6 13:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 127007 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2897393ljc; Tue, 6 Feb 2018 05:02:32 -0800 (PST) X-Google-Smtp-Source: AH8x226jWmVW1XS+8FYF/w1pPcs0DF/DKp1VIZfk2z9x4HlqWZ9PG84uJXkUU/B+6c3c2ZuSAM7v X-Received: by 10.55.79.83 with SMTP id d80mr471164qkb.339.1517922152008; Tue, 06 Feb 2018 05:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517922152; cv=none; d=google.com; s=arc-20160816; b=QA6i0zuVEzdzp/fhobIAErwwhc2ZLCO8hyrFpCHUyDg9tzbXJZgBOHYYD6yCVLGVeu XWAZ6L3miVVcwB6oHJEqDTeVGx/2RrVUlTg00Y6TqQoCY8miUWLK4fOwSlRf72z7FYqj vLsr1sBfnBKK9qThLmXdEJIvw9QlZxbjp9c0oAPpoTCcGdl6Llmauzhc3uJ4eGG2aYo9 zCqzg4QMpc4ZY1V4wUBLcFPT+h6M6mR1M/ZtCfgfBxZV3+siNd4qQPG3UKlUCgcbjzUK Xa4jWoA2ttBz/wM0LHUi8F+T369NzjR1x7+ymhSwzDlEuCylPHcLWe9eq9fDKCn/vmBu 3BJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=CJg+apSndySbSl2H8DkXXd/1MZAyn1Y11JGuYIJXlEw=; b=TYPNU3nH7PL+D3/TZuUT04sS55ASAsKh5wWqBgWBqeiIpH4jL7e/XKZBKGxtWH6rG4 VhkWqSDtqzemEaeo1BwIoEsJOPjcJwt4xGbGnb/eJvpiZcnT4J2TDRJ/80gHIOHwA9v4 QltyYEyqSN6vi0YBcVmxyM8Y6owZBB1KmAwMUp19zpOQ/iyeOaDR7GRBuE8JwM/U68qk XOndz+FsH8k5MGEAPYPx00nktePiprF7/ZXocxmVgGq3eMEBFXV9cTQ6+esyiArw15AT OC09QLG9iH9Ukbg2KSqYvgitShM+Lqm4c1IXOAJt6eCY4D4LTolY/84O2bAuk3yLYHqR wGWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id p126si3486780qke.471.2018.02.06.05.02.31; Tue, 06 Feb 2018 05:02:31 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9332E617E8; Tue, 6 Feb 2018 13:02:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id C134460B5F; Tue, 6 Feb 2018 13:00:37 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BCF01608E8; Tue, 6 Feb 2018 13:00:28 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id 7530C608BD for ; Tue, 6 Feb 2018 13:00:15 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward105j.mail.yandex.net (Yandex) with ESMTP id E7601180F8A for ; Tue, 6 Feb 2018 16:00:09 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 6Tp2fcboma-092C9pNo; Tue, 06 Feb 2018 16:00:09 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id aFSEfmaddw-093SOKcm; Tue, 06 Feb 2018 16:00:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 6 Feb 2018 16:00:07 +0300 Message-Id: <1517922007-6874-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517922007-6874-1-git-send-email-odpbot@yandex.ru> References: <1517922007-6874-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 455 Subject: [lng-odp] [PATCH API-NEXT v1 2/2] linux-gen: pktio: fix recv timeout issue with socket mmap X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Validation test failed sometimes when select returned that there are packets but sock_mmap_recv did find those (or it dropped those). Continue timeout wait with select if sock_mmap_recv didn't find any packets. Select updates timeout value automatically to reflect the amount of time not slept. Fixes https://bugs.linaro.org/show_bug.cgi?id=3615 Signed-off-by: Petri Savolainen --- /** Email created from pull request 455 (psavol:next-fix-recv-tmo) ** https://github.com/Linaro/odp/pull/455 ** Patch: https://github.com/Linaro/odp/pull/455.patch ** Base sha: 1836820278b57de6144c75872e148976d49d28a2 ** Merge commit sha: 7aa3734cf260df25134c8b302983d3a79cf7c47c **/ platform/linux-generic/pktio/socket_mmap.c | 40 ++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 04c44bc85..924d8e279 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -692,10 +692,19 @@ static int sock_mmap_recv_tmo(pktio_entry_t *pktio_entry, int index, FD_ZERO(&readfds); maxfd = sock_mmap_fd_set(pktio_entry, index, &readfds); - if (select(maxfd + 1, &readfds, NULL, NULL, &timeout) == 0) - return 0; + while (1) { + ret = select(maxfd + 1, &readfds, NULL, NULL, &timeout); + + if (ret <= 0) + return ret; + + ret = sock_mmap_recv(pktio_entry, index, pkt_table, num); + + if (ret) + return ret; - return sock_mmap_recv(pktio_entry, index, pkt_table, num); + /* If no packets, continue wait until timeout expires */ + } } static int sock_mmap_recv_mq_tmo(pktio_entry_t *pktio_entry[], int index[], @@ -729,20 +738,25 @@ static int sock_mmap_recv_mq_tmo(pktio_entry_t *pktio_entry[], int index[], timeout.tv_sec = usecs / (1000 * 1000); timeout.tv_usec = usecs - timeout.tv_sec * (1000ULL * 1000ULL); - if (select(maxfd + 1, &readfds, NULL, NULL, &timeout) == 0) - return 0; + while (1) { + ret = select(maxfd + 1, &readfds, NULL, NULL, &timeout); - for (i = 0; i < num_q; i++) { - ret = sock_mmap_recv(pktio_entry[i], index[i], pkt_table, num); + if (ret <= 0) + return ret; - if (ret > 0 && from) - *from = i; + for (i = 0; i < num_q; i++) { + ret = sock_mmap_recv(pktio_entry[i], index[i], + pkt_table, num); - if (ret != 0) - return ret; - } + if (ret > 0 && from) + *from = i; - return 0; + if (ret) + return ret; + } + + /* If no packets, continue wait until timeout expires */ + } } static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,