From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 91D2F1B1C1 for ; Wed, 24 Jan 2018 16:41:45 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 48328226D3; Wed, 24 Jan 2018 10:41:45 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:41:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=H6xmnmw0tAFxYTCFZ +1RPZTeKeYWmBMoxUrCb3qt658=; b=atDvoAZrf9g0R/16FFKZXnA5DeFmK1iQZ LxlUHxzrxY9Ng5vD6kQD2qTzN215A4qoBPAm5O14XP9WTZTlLh9j42rt1lPJLB+5 pESdDhRDmEbqoOYFb05Lz3xuI67BoWnz2jGgX3jPM4xA7EvnnswSnZ+7h9Ejnv4k Fm65fF1lhdsnu0SQNVeO3+4a/QJRGEdkEhiKTX4rIDIjOtZS/bENhrhobcI3b4BV JgN26wA6CNkvBvNf/yuKZ5NjHHNMFQmhPqY8xNr8lRBZKB5Ckn/fNXvOOnYD3eJB 7PtzeACWY7dadW5ni29FaYd6fzvAhN+AcBY6/JaV/jWn7v1NjSKgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=H6xmnmw0tAFxYTCFZ+1RPZTeKeYWmBMoxUrCb3qt658=; b=F4XpMb6D +1YIyehAqtesbenreOSmJXLNwqmnQ5xi0C6+u7VPtsDgyBB9m3RRfGZ6BpDCBPqj r52iYaKMRyMcNipg3vMF8UelDRfU1ihOBZUEKWyFvTOFG8BS924k541o1xpPmehD LIn+0zIWTols33XrLCNVPFf0E6VJHsUfhjP3WQd0/v+BdEnEDMLv/BoQPy0UYnz4 jvEtV3pa0zUgrFDYsYLvY276XG1uOA/LeTFyFBwFVXiGOrsn67fbOl8Nl25mXWh5 ttkQzPiXizPK9lToIenzZG8U4NSXinM2vTfki6LogVxqH/NVNg05a3bUPc9ZYCBX +dBvRuk5/+FQ1g== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 2515C7E3D4; Wed, 24 Jan 2018 10:41:42 -0500 (EST) From: Yuanhan Liu To: Gage Eads Cc: Harry van Haaren , dpdk stable Date: Wed, 24 Jan 2018 23:33:19 +0800 Message-Id: <1516808026-25523-131-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'event/sw: fix queue memory leak and multi-link bug' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:41:45 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 0adf9b4ffe82278e379cb6306f962490a6b872ce Mon Sep 17 00:00:00 2001 From: Gage Eads Date: Wed, 29 Nov 2017 21:08:33 -0600 Subject: [PATCH] event/sw: fix queue memory leak and multi-link bug [ upstream commit e1f2dcdb8f5c01bb1296c5c6c03d39cdf368b91a ] This commit reinitializes a queue before it is reconfigured, such that reorder buffer memory is not leaked. This bug masked a few other problems, which this commit corrects as well: - sw_port_link() allowed a port to link to a queue twice, such that the port could then successfully unlink the queue twice. Now the link function checks whether a port is already linked to the queue, and if so returns success but doesn't assign the a port a second slot in the queue's cq map. - test_eventdev.c's test_eventdev_unlink() was unlinking a queue twice from the same port, and expecting the second unlink to succeed. Now the test unlinks, links, then unlinks again. - test_eventdev.c's test_eventdev_link_get() was linking a single queue but expecting the unlink function to return nb_queues (where nb_queues > 1). The test now checks for a return value of 1. Fixes: 5ffb2f142d95 ("event/sw: support event queues") Fixes: 371a688fc159 ("event/sw: support linking queues to ports") Fixes: f8f9d233ea0e ("test/eventdev: add unit tests") Signed-off-by: Gage Eads Acked-by: Harry van Haaren --- drivers/event/sw/sw_evdev.c | 46 +++++++++++++++++++++++++++++---------------- test/test/test_eventdev.c | 7 +++++-- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c index fd11079..d989346 100644 --- a/drivers/event/sw/sw_evdev.c +++ b/drivers/event/sw/sw_evdev.c @@ -62,6 +62,7 @@ sw_port_link(struct rte_eventdev *dev, void *port, const uint8_t queues[], RTE_SET_USED(priorities); for (i = 0; i < num; i++) { struct sw_qid *q = &sw->qids[queues[i]]; + unsigned int j; /* check for qid map overflow */ if (q->cq_num_mapped_cqs >= RTE_DIM(q->cq_map)) { @@ -74,6 +75,15 @@ sw_port_link(struct rte_eventdev *dev, void *port, const uint8_t queues[], break; } + for (j = 0; j < q->cq_num_mapped_cqs; j++) { + if (q->cq_map[j] == p->id) + break; + } + + /* check if port is already linked */ + if (j < q->cq_num_mapped_cqs) + continue; + if (q->type == SW_SCHED_TYPE_DIRECT) { /* check directed qids only map to one port */ if (p->num_qids_mapped > 0) { @@ -338,6 +348,23 @@ cleanup: return -EINVAL; } +static void +sw_queue_release(struct rte_eventdev *dev, uint8_t id) +{ + struct sw_evdev *sw = sw_pmd_priv(dev); + struct sw_qid *qid = &sw->qids[id]; + uint32_t i; + + for (i = 0; i < SW_IQS_MAX; i++) + iq_ring_destroy(qid->iq[i]); + + if (qid->type == RTE_SCHED_TYPE_ORDERED) { + rte_free(qid->reorder_buffer); + rte_ring_free(qid->reorder_buffer_freelist); + } + memset(qid, 0, sizeof(*qid)); +} + static int sw_queue_setup(struct rte_eventdev *dev, uint8_t queue_id, const struct rte_event_queue_conf *conf) @@ -355,24 +382,11 @@ sw_queue_setup(struct rte_eventdev *dev, uint8_t queue_id, } struct sw_evdev *sw = sw_pmd_priv(dev); - return qid_init(sw, queue_id, type, conf); -} - -static void -sw_queue_release(struct rte_eventdev *dev, uint8_t id) -{ - struct sw_evdev *sw = sw_pmd_priv(dev); - struct sw_qid *qid = &sw->qids[id]; - uint32_t i; - for (i = 0; i < SW_IQS_MAX; i++) - iq_ring_destroy(qid->iq[i]); + if (sw->qids[queue_id].initialized) + sw_queue_release(dev, queue_id); - if (qid->type == RTE_SCHED_TYPE_ORDERED) { - rte_free(qid->reorder_buffer); - rte_ring_free(qid->reorder_buffer_freelist); - } - memset(qid, 0, sizeof(*qid)); + return qid_init(sw, queue_id, type, conf); } static void diff --git a/test/test/test_eventdev.c b/test/test/test_eventdev.c index ba39cba..1ed2a1d 100644 --- a/test/test/test_eventdev.c +++ b/test/test/test_eventdev.c @@ -839,6 +839,9 @@ test_eventdev_unlink(void) for (i = 0; i < nb_queues; i++) queues[i] = i; + ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0); + TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d", + TEST_DEV_ID); ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, nb_queues); TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d", @@ -899,9 +902,9 @@ test_eventdev_link_get(void) ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities); TEST_ASSERT(ret == 1, "(%d)Wrong link get ret=%d expected=%d", TEST_DEV_ID, ret, 1); - /* unlink all*/ + /* unlink the queue */ ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0); - TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d", + TEST_ASSERT(ret == 1, "Failed to unlink(device%d) ret=%d", TEST_DEV_ID, ret); /* 4links and 2 unlinks */ -- 2.7.4