From patchwork Fri Mar 2 15:00:12 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: 130557 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1382423lja; Fri, 2 Mar 2018 07:14:40 -0800 (PST) X-Google-Smtp-Source: AG47ELt94cz4BmOP4f3H1xbKImLy3MyHg61WnZPvB9Xmlw6e9jlVwx1nAivZKGxBr2mqoRNDEGFs X-Received: by 10.200.6.74 with SMTP id e10mr8535930qth.166.1520003680265; Fri, 02 Mar 2018 07:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003680; cv=none; d=google.com; s=arc-20160816; b=QHNVjjSpHNQzSSVz47YEA16USfcYuyhZX/W9FLUcn5Bwr7b2JurMIGoK+15eL05rLe RABhmbc81azWJRRS+Wo5+RNnOG953Q6RnWiL6jixkOBd47NCM/+jrhzvm4TImaw1Mgse BOKShSEPKXZD00k/bttQAGDpKzszSoHpSlWRnXNYbkhE6HjZqDZ7AJb5a+3bCR56Tl42 mrqjirEAUZsqQsSmnPUGOLEP10xfaXoQj9p5BWsssXKyKgtzhhe5BtvT5VNhUc42xW9t gx04rxrSQVmQTCDithalqUF7QHmHDkZJbMLIH+3yAJAeJm80s18nNdInBucVvP9isb5i URMg== 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=w+byxeHrWBN2tRObBwevJXKH3SGVDvLbccNy68/kIOs=; b=PNN9lBEsubwubsRkLXJtRdGBpFkkqdQaf8N9INWyWVqQheiH71e6fD5vHJ2QHZ4F5M pqZa0DxkuZAATPsNhTO2vlw2pJceMZ6WlvMhYXaBkiXrpnFoKAaIjaV/8sP+KpdCIcpa +KsjvuFaYXGgEDgnaP//dj+Ly3Q4Ijo0qDEWye7VsNA0x5BVfYS5lgtLUxLmlnfV4RvV m1w5EkLQVTIuBdZz/3d0YTNQKSD50C8JZLoW1YDPS6yDT6lAF1utWm8x1MCqxvVcOveK lFX0+ia18EKEjRn31afOkOn/H+dt8IfFdRG8262cX0RD3az5IR8WeE7JqDJdk0LYLoQ4 UdnQ== 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 w193si6445493qka.157.2018.03.02.07.14.40; Fri, 02 Mar 2018 07:14:40 -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 EA0AC627AA; Fri, 2 Mar 2018 15:14:39 +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 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 EF56E617C9; Fri, 2 Mar 2018 15:01:40 +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 029C26077E; Fri, 2 Mar 2018 15:00:37 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 96B7561778 for ; Fri, 2 Mar 2018 15:00:21 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 9B4FB43014EE for ; Fri, 2 Mar 2018 18:00:19 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yqA50JH0Lq-0Jmmm9vj; Fri, 02 Mar 2018 18:00:19 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ChbgkO0UiZ-0I2GMw9V; Fri, 02 Mar 2018 18:00:18 +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: Fri, 2 Mar 2018 18:00:12 +0300 Message-Id: <1520002815-30682-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520002815-30682-1-git-send-email-odpbot@yandex.ru> References: <1520002815-30682-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 504 Subject: [lng-odp] [PATCH v2 3/6] linux-gen: queue: enqueue may fail 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 Drop events when queue enqueue fails. Enqueue failure is more likely now when queue has limited size. Signed-off-by: Petri Savolainen --- /** Email created from pull request 504 (psavol:master-sched-optim-2) ** https://github.com/Linaro/odp/pull/504 ** Patch: https://github.com/Linaro/odp/pull/504.patch ** Base sha: e1c0e4570a45d05dd9f2e8e052ce71164209d112 ** Merge commit sha: 964132736e0785222be184065d6ac73121cd46ac **/ platform/linux-generic/odp_packet_io.c | 47 +++++++++++++++++++++++++--- platform/linux-generic/odp_schedule_basic.c | 14 +++++++-- platform/linux-generic/odp_schedule_iquery.c | 13 ++++++-- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index e76ff8140..f67181576 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -638,8 +638,22 @@ static odp_buffer_hdr_t *pktin_dequeue(queue_t q_int) if (pkts <= 0) return NULL; - if (pkts > 1) - queue_fn->enq_multi(q_int, &hdr_tbl[1], pkts - 1); + if (pkts > 1) { + int num_enq; + int num = pkts - 1; + + num_enq = queue_fn->enq_multi(q_int, &hdr_tbl[1], num); + + if (odp_unlikely(num_enq < num)) { + if (odp_unlikely(num_enq < 0)) + num_enq = 0; + + ODP_DBG("Interface %s dropped %i packets\n", + entry->s.name, num - num_enq); + buffer_free_multi(&hdr_tbl[num_enq + 1], num - num_enq); + } + } + buf_hdr = hdr_tbl[0]; return buf_hdr; } @@ -676,8 +690,21 @@ static int pktin_deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[], int num) for (j = 0; i < pkts; i++, j++) hdr_tbl[j] = hdr_tbl[i]; - if (j) - queue_fn->enq_multi(q_int, hdr_tbl, j); + if (j) { + int num_enq; + + num_enq = queue_fn->enq_multi(q_int, hdr_tbl, j); + + if (odp_unlikely(num_enq < j)) { + if (odp_unlikely(num_enq < 0)) + num_enq = 0; + + ODP_DBG("Interface %s dropped %i packets\n", + entry->s.name, j - num_enq); + buffer_free_multi(&buf_hdr[num_enq], j - num_enq); + } + } + return nbr; } @@ -763,6 +790,7 @@ int sched_cb_pktin_poll_old(int pktio_index, int num_queue, int index[]) for (idx = 0; idx < num_queue; idx++) { queue_t q_int; + int num_enq; num = pktin_recv_buf(entry, index[idx], hdr_tbl, QUEUE_MULTI_MAX); @@ -776,7 +804,16 @@ int sched_cb_pktin_poll_old(int pktio_index, int num_queue, int index[]) } q_int = entry->s.in_queue[index[idx]].queue_int; - queue_fn->enq_multi(q_int, hdr_tbl, num); + num_enq = queue_fn->enq_multi(q_int, hdr_tbl, num); + + if (odp_unlikely(num_enq < num)) { + if (odp_unlikely(num_enq < 0)) + num_enq = 0; + + ODP_DBG("Interface %s dropped %i packets\n", + entry->s.name, num - num_enq); + buffer_free_multi(&hdr_tbl[num_enq], num - num_enq); + } } return 0; diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index b251bdeef..3ea261fae 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -581,13 +581,23 @@ static inline void ordered_stash_release(void) for (i = 0; i < sched_local.ordered.stash_num; i++) { queue_entry_t *queue_entry; odp_buffer_hdr_t **buf_hdr; - int num; + int num, num_enq; queue_entry = sched_local.ordered.stash[i].queue_entry; buf_hdr = sched_local.ordered.stash[i].buf_hdr; num = sched_local.ordered.stash[i].num; - queue_fn->enq_multi(qentry_to_int(queue_entry), buf_hdr, num); + num_enq = queue_fn->enq_multi(qentry_to_int(queue_entry), + buf_hdr, num); + + /* Drop packets that were not enqueued */ + if (odp_unlikely(num_enq < num)) { + if (odp_unlikely(num_enq < 0)) + num_enq = 0; + + ODP_DBG("Dropped %i packets\n", num - num_enq); + buffer_free_multi(&buf_hdr[num_enq], num - num_enq); + } } sched_local.ordered.stash_num = 0; } diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index ddd97bea7..40f2e9fca 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -1136,13 +1136,22 @@ static inline void ordered_stash_release(void) for (i = 0; i < thread_local.ordered.stash_num; i++) { queue_entry_t *queue_entry; odp_buffer_hdr_t **buf_hdr; - int num; + int num, num_enq; queue_entry = thread_local.ordered.stash[i].queue_entry; buf_hdr = thread_local.ordered.stash[i].buf_hdr; num = thread_local.ordered.stash[i].num; - queue_fn->enq_multi(qentry_to_int(queue_entry), buf_hdr, num); + num_enq = queue_fn->enq_multi(qentry_to_int(queue_entry), + buf_hdr, num); + + if (odp_unlikely(num_enq < num)) { + if (odp_unlikely(num_enq < 0)) + num_enq = 0; + + ODP_DBG("Dropped %i packets\n", num - num_enq); + buffer_free_multi(&buf_hdr[num_enq], num - num_enq); + } } thread_local.ordered.stash_num = 0; }