* [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes
@ 2017-07-04 13:51 Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 1/2] net/ena: fix cleanup of the Tx bufs Michal Krawczyk
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michal Krawczyk @ 2017-07-04 13:51 UTC (permalink / raw)
To: mw, gtzalik, matua, evgenys; +Cc: dev, Michal Krawczyk
Hi,
I am sending two patches fixing memory management issues.
One patch prevents from multiple release of one mbuf in some cases, and
the second one properly initializes allocated memory.
Alexander Matushevsky (1):
net/ena: initialize memory in the allocation macros
Michal Krawczyk (1):
net/ena: fix cleanup of the Tx bufs
drivers/net/ena/base/ena_plat_dpdk.h | 2 ++
drivers/net/ena/ena_ethdev.c | 8 ++++----
2 files changed, 6 insertions(+), 4 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH 1/2] net/ena: fix cleanup of the Tx bufs
2017-07-04 13:51 [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Michal Krawczyk
@ 2017-07-04 13:51 ` Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 2/2] net/ena: initialize memory in the allocation macros Michal Krawczyk
2017-07-05 10:28 ` [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Ferruh Yigit
2 siblings, 0 replies; 4+ messages in thread
From: Michal Krawczyk @ 2017-07-04 13:51 UTC (permalink / raw)
To: mw, gtzalik, matua, evgenys; +Cc: dev, Michal Krawczyk
After cleanup of the mbuf on Tx path, queue was still pointing to this
mbuf and upon cleanup of the Tx buffers, it was being freed second time.
Moreover, to make sure that upon interrupt all mbufs will be freed,
whole ring is being cleaned up instead of part of it - originally only
range between head and tail was being cleaned up.
Fixes: 1173fca25af9 ("ena: add polling-mode driver")
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
---
drivers/net/ena/ena_ethdev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 6c2ee9e..80ce1f3 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -689,11 +689,10 @@ static void ena_rx_queue_release_bufs(struct ena_ring *ring)
static void ena_tx_queue_release_bufs(struct ena_ring *ring)
{
- unsigned int ring_mask = ring->ring_size - 1;
+ unsigned int i;
- while (ring->next_to_clean != ring->next_to_use) {
- struct ena_tx_buffer *tx_buf =
- &ring->tx_buffer_info[ring->next_to_clean & ring_mask];
+ for (i = 0; i < ring->ring_size; ++i) {
+ struct ena_tx_buffer *tx_buf = &ring->tx_buffer_info[i];
if (tx_buf->mbuf)
rte_pktmbuf_free(tx_buf->mbuf);
@@ -1772,6 +1771,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
/* Free whole mbuf chain */
mbuf = tx_info->mbuf;
rte_pktmbuf_free(mbuf);
+ tx_info->mbuf = NULL;
/* Put back descriptor to the ring for reuse */
tx_ring->empty_tx_reqs[next_to_clean & ring_mask] = req_id;
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH 2/2] net/ena: initialize memory in the allocation macros
2017-07-04 13:51 [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 1/2] net/ena: fix cleanup of the Tx bufs Michal Krawczyk
@ 2017-07-04 13:51 ` Michal Krawczyk
2017-07-05 10:28 ` [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Ferruh Yigit
2 siblings, 0 replies; 4+ messages in thread
From: Michal Krawczyk @ 2017-07-04 13:51 UTC (permalink / raw)
To: mw, gtzalik, matua, evgenys; +Cc: dev, Michal Krawczyk
From: Alexander Matushevsky <matua@amazon.com>
Uninitialized memory could cause memory corruption, by indicating
completion of the invalid mbuf.
Fixes: 3d3edc265fc8 ("net/ena: make coherent memory allocation NUMA-aware")
Signed-off-by: Alexander Matushevsky <matua@amazon.com>
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
---
drivers/net/ena/base/ena_plat_dpdk.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 7eaebf4..71a8c1e 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -207,6 +207,7 @@ typedef uint64_t dma_addr_t;
snprintf(z_name, sizeof(z_name), \
"ena_alloc_%d", ena_alloc_cnt++); \
mz = rte_memzone_reserve(z_name, size, node, 0); \
+ memset(mz->addr, 0, size); \
virt = mz->addr; \
phys = mz->phys_addr; \
} while (0)
@@ -219,6 +220,7 @@ typedef uint64_t dma_addr_t;
snprintf(z_name, sizeof(z_name), \
"ena_alloc_%d", ena_alloc_cnt++); \
mz = rte_memzone_reserve(z_name, size, node, 0); \
+ memset(mz->addr, 0, size); \
virt = mz->addr; \
} while (0)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes
2017-07-04 13:51 [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 1/2] net/ena: fix cleanup of the Tx bufs Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 2/2] net/ena: initialize memory in the allocation macros Michal Krawczyk
@ 2017-07-05 10:28 ` Ferruh Yigit
2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2017-07-05 10:28 UTC (permalink / raw)
To: Michal Krawczyk, mw, gtzalik, matua, evgenys; +Cc: dev
On 7/4/2017 2:51 PM, Michal Krawczyk wrote:
> Hi,
>
> I am sending two patches fixing memory management issues.
> One patch prevents from multiple release of one mbuf in some cases, and
> the second one properly initializes allocated memory.
>
> Alexander Matushevsky (1):
> net/ena: initialize memory in the allocation macros
>
> Michal Krawczyk (1):
> net/ena: fix cleanup of the Tx bufs
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-05 10:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-04 13:51 [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 1/2] net/ena: fix cleanup of the Tx bufs Michal Krawczyk
2017-07-04 13:51 ` [dpdk-dev] [PATCH 2/2] net/ena: initialize memory in the allocation macros Michal Krawczyk
2017-07-05 10:28 ` [dpdk-dev] [PATCH 0/2] ENA PMD memory management fixes Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).