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,