From patchwork Thu Mar 1 16:00:09 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: 130319 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2985102edc; Thu, 1 Mar 2018 08:07:32 -0800 (PST) X-Google-Smtp-Source: AG47ELu7jgC2SK/rP+pyBZwdJFMsvSlm/0+KR8yJuwcnduqlJNmsODMoaDHq/dJRGNzh0X/S7A3M X-Received: by 10.55.2.140 with SMTP id v12mr3385620qkg.251.1519920452258; Thu, 01 Mar 2018 08:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519920452; cv=none; d=google.com; s=arc-20160816; b=e5axPA1lh3yOXTcxeRuAfB5H+4+YkrSCX2n4E6zkYuUDextvKM/jxMOq6BpwuCHt7S 7XHziIB7bovilniNoH5G6oXttWaVKH1QzVSaDjLfrEqCIROF5IWDSHz+GKkgQ2ZfWvsi xSYp4gQIHDPPN45KJQm6tmUqLcSXaqPijU6ZD+tV4nFTXSt306f7BfyfRjZ9cscphLP2 Iq1Yn3VF2sXnsgSuLnyDiezEV7AJ4A9hXJ6ptN4MuTyYeA7Fyi821JmrREIN6wMuKQib kLBgkz6AXlWwUOzcjsxZ8aF/D+vLDpYUsJIV6ZjeN5no32pZbRaHRj4vIiN+e/D3SZrN eykg== 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=Ctx9BFv7msQyKIyyHNiQl7oUrMsaZoF4XLYJGKwbDqU=; b=Ut6iwTgo7YF4ZJmT2g5i8s2psVdKYjdbKSedjYekqrwGpz0pwQpOQhSJVR46DwTYIg NxQ33Gr4CfRqNBRx0Qea1KIqexAL2X8wK4of+wnG2RCSURsUxgBxSGV29tBBQ9pskj92 kSJL5YTnvrmAtKU9RQFX/+7qZ4Ji6V/0fw7U5sAwcDq7K5ACdVRXYU9k8c0xqMF/i8df i7wgeR+jbKr8cU0uc7uVBkrRp58bD/IwoykeSRsVTGT3MptTbmDk9rKSuwyMu3ueIEKw OylEhKLKsZRTXFfdbBO3jxTFBPAggTSoatdsRu8BWHF5UfPl9Sa1vYnKFFsM3ZUNhO7t siMA== 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 u17si1129284qka.428.2018.03.01.08.07.32; Thu, 01 Mar 2018 08:07:32 -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 E907D6095E; Thu, 1 Mar 2018 16:07: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 A4B23616FC; Thu, 1 Mar 2018 16:05:03 +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 94577608F6; Thu, 1 Mar 2018 16:00:24 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id C6B7460915 for ; Thu, 1 Mar 2018 16:00:15 +0000 (UTC) Received: from mxback1o.mail.yandex.net (mxback1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1b]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 533D74083838 for ; Thu, 1 Mar 2018 19:00:14 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0fuX11PTCj-0EMuOBlX; Thu, 01 Mar 2018 19:00:14 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id co35rdYWSN-0D2KthBj; Thu, 01 Mar 2018 19:00:13 +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: Thu, 1 Mar 2018 19:00:09 +0300 Message-Id: <1519920009-23406-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519920009-23406-1-git-send-email-odpbot@yandex.ru> References: <1519920009-23406-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 504 Subject: [lng-odp] [PATCH v1 3/3] 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: 284f52d72ec19df3774c7409780f1f9eea33b8e6 ** Merge commit sha: 081cdd2f01d5a4e5b5b4d254f689e55d60a489cd **/ platform/linux-generic/odp_packet_io.c | 41 ++++++++++++++++++++++++---- platform/linux-generic/odp_schedule_basic.c | 13 +++++++-- platform/linux-generic/odp_schedule_iquery.c | 12 ++++++-- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 73d43b009..17d48bfdb 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -638,8 +638,20 @@ 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; + + buffer_free_multi(&hdr_tbl[num_enq + 1], num - num_enq); + } + } + buf_hdr = hdr_tbl[0]; return buf_hdr; } @@ -676,8 +688,19 @@ 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; + + buffer_free_multi(&buf_hdr[num_enq], j - num_enq); + } + } + return nbr; } @@ -763,6 +786,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 +800,14 @@ 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; + + 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 1975e3a4b..dc964f387 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -581,13 +581,22 @@ 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; + + 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..ab99ce789 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -1136,13 +1136,21 @@ 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; + + buffer_free_multi(&buf_hdr[num_enq], num - num_enq); + } } thread_local.ordered.stash_num = 0; }