From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <harry.van.haaren@intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 6979F2C72
 for <dev@dpdk.org>; Tue, 18 Apr 2017 11:58:43 +0200 (CEST)
Received: from fmsmga004.fm.intel.com ([10.253.24.48])
 by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 18 Apr 2017 02:58:42 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.37,218,1488873600"; d="scan'208";a="250438221"
Received: from silpixa00398672.ir.intel.com ([10.237.223.128])
 by fmsmga004.fm.intel.com with ESMTP; 18 Apr 2017 02:58:41 -0700
From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: Harry van Haaren <harry.van.haaren@intel.com>
Date: Tue, 18 Apr 2017 10:58:40 +0100
Message-Id: <1492509520-31943-1-git-send-email-harry.van.haaren@intel.com>
X-Mailer: git-send-email 2.7.4
Subject: [dpdk-dev] [PATCH] event/sw: fix credit return on invalid queue id
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 18 Apr 2017 09:58:44 -0000

This patch returns a credit when an rte_event is
enqueued with an invalid queue_id. Previously a
credit was leaked from the system.

Note that the eventdev instance does not attempt
to free any resources that the rte_event owns. As
a result, resources owned by the rte_event are leaked.
Eg. if the rte_event represents an rte_mbuf, the mbuf
will not be freed, and causes a leak from the mempool.

Fixes: 656af9180014 ("event/sw: add worker core functions")

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 drivers/event/sw/sw_evdev_worker.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/event/sw/sw_evdev_worker.c b/drivers/event/sw/sw_evdev_worker.c
index b9b6f8d..9cb6bef 100644
--- a/drivers/event/sw/sw_evdev_worker.c
+++ b/drivers/event/sw/sw_evdev_worker.c
@@ -105,9 +105,12 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num)
 		 */
 		if ((new_ops[i] & QE_FLAG_COMPLETE) && outstanding)
 			p->outstanding_releases--;
-		/* Branch to avoid touching p->stats except error case */
-		if (unlikely(invalid_qid))
+
+		/* error case: branch to avoid touching p->stats */
+		if (unlikely(invalid_qid)) {
 			p->stats.rx_dropped++;
+			p->inflight_credits++;
+		}
 	}
 
 	/* returns number of events actually enqueued */
-- 
2.7.4