From patchwork Mon Jul 6 17:11:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 50770 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 820F422A0A for ; Mon, 6 Jul 2015 17:12:24 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf52056220wgj.3 for ; Mon, 06 Jul 2015 10:12:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=a8RlIvZK4/+qmDHdl6XKi2sn8eUFdVuXxAsJHEDhrj8=; b=K5/AUYJ054W6g3UdQanIMhT/Zi4BZ3D68kR+5ab/VecOb36QbAi92RWagfY4ZJnYzW /Qb2U/siIH6LE2JunUN6hA+1zk/jL5AAFtBj2EJL4wrta1ecb+EfxMgnikka6l+SixEv MrUZICEAXsI/v2tZOb2ivVkofMHl8jqxNeuehVKAf1W/4NW5+ID3LXJVkR+urvMDzDKa dGCUOiPCoAcoJJrEz8csRfrTxEmEtOXP3BUVrEAbeIP5YUR+907U/eCwydgd5PWFxhNr yCDbHLoIsUC+u/cY1tRruRX5ZzHY2HvrtMlvUqIe7bpH2ZM5K/QP7RXCknke5iWQKAG1 eSXw== X-Gm-Message-State: ALoCoQndkwM8W1ly9UmoJMvNObpCXE2D+3nfPJrA8QIeez28Z/k+gM/0OEc6XWXAtFi2FETA59AR X-Received: by 10.112.171.41 with SMTP id ar9mr30751772lbc.24.1436202743814; Mon, 06 Jul 2015 10:12:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.7 with SMTP id f7ls656032lah.48.gmail; Mon, 06 Jul 2015 10:12:23 -0700 (PDT) X-Received: by 10.152.37.67 with SMTP id w3mr50072067laj.123.1436202743534; Mon, 06 Jul 2015 10:12:23 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id mi10si2551299lbb.154.2015.07.06.10.12.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 10:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labgy5 with SMTP id gy5so11179438lab.2 for ; Mon, 06 Jul 2015 10:12:23 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr50887134lbb.35.1436202743418; Mon, 06 Jul 2015 10:12:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1853757lbb; Mon, 6 Jul 2015 10:12:22 -0700 (PDT) X-Received: by 10.141.23.136 with SMTP id z130mr65405483qhd.36.1436202741951; Mon, 06 Jul 2015 10:12:21 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j201si21449099qhc.130.2015.07.06.10.12.18; Mon, 06 Jul 2015 10:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id BEF5561E11; Mon, 6 Jul 2015 17:12:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0B6BD61CB0; Mon, 6 Jul 2015 17:12:15 +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 483BB61D52; Mon, 6 Jul 2015 17:12:12 +0000 (UTC) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by lists.linaro.org (Postfix) with ESMTPS id 1E80261C65 for ; Mon, 6 Jul 2015 17:12:07 +0000 (UTC) Received: by wiga1 with SMTP id a1so234792914wig.0 for ; Mon, 06 Jul 2015 10:12:06 -0700 (PDT) X-Received: by 10.195.11.202 with SMTP id ek10mr99295691wjd.12.1436202726024; Mon, 06 Jul 2015 10:12:06 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id ma15sm48288708wic.20.2015.07.06.10.12.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jul 2015 10:12:05 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Mon, 6 Jul 2015 18:11:57 +0100 Message-Id: <1436202717-13883-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435770379-30000-10-git-send-email-zoltan.kiss@linaro.org> References: <1435770379-30000-10-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v5] queue: handle return value of odp_queue_enq_multi() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Unsent packet has to be released. If the event type is obvious from the context, use directly the relevant release functions, otherwise odp_event(free). Wider error handling is attempted, but this patch can't fix all the flaws in the many calling functions of odp_queue_enq() --- v5: fix array use in last hunk test/performance/odp_pktio_perf.c | 15 ++++++++++++++- test/performance/odp_scheduling.c | 10 ++++++++-- test/validation/pktio/pktio.c | 5 +++++ test/validation/queue/queue.c | 3 +++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 52bddc4..6e07c9f 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -270,6 +270,9 @@ static int alloc_packets(odp_event_t *event_tbl, int num_pkts) static int send_packets(odp_queue_t outq, odp_event_t *event_tbl, unsigned num_pkts) { + int ret; + unsigned cnt; + if (num_pkts == 0) return 0; else if (num_pkts == 1) { @@ -281,7 +284,17 @@ static int send_packets(odp_queue_t outq, } } - return odp_queue_enq_multi(outq, event_tbl, num_pkts); + ret = odp_queue_enq_multi(outq, event_tbl, num_pkts); + if (ret == (signed)num_pkts) + return ret; + + if (ret < 0) + ret = 0; + cnt = ret; + do + odp_event_free(event_tbl[cnt]); + while (++cnt < num_pkts); + return ret; } /* diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 1283986..8b46eb2 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -535,9 +535,15 @@ static int test_schedule_multi(const char *str, int thr, } /* Assume we can enqueue all events */ - if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX) != - MULTI_BUFS_MAX) { + j = odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX); + if (j != MULTI_BUFS_MAX) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); + if (j < 0) + j = 0; + do + odp_event_free(ev[j]); + while (++j < MULTI_BUFS_MAX); + return -1; } } diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 9d5af22..ac12759 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -389,6 +389,11 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts); if (ret != num_pkts) { CU_FAIL("failed to enqueue test packets"); + if (ret < 0) + ret = 0; + do + odp_packet_free(tx_pkt[ret]); + while (++ret < num_pkts); return; } } diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c index 5f05e49..217c75e 100644 --- a/test/validation/queue/queue.c +++ b/test/validation/queue/queue.c @@ -91,6 +91,9 @@ static void queue_test_sunnydays(void) */ ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE); CU_ASSERT(MAX_BUFFER_QUEUE == ret); + for (i = ret; i < MAX_BUFFER_QUEUE; i++) + odp_event_free(enev[i]); + pev_tmp = deev; do { deq_ret = odp_queue_deq_multi(queue_id, pev_tmp,