i40e: fix the issue of not freeing memzone
PATCH 1/1 i40e: fix the issue of not freeing memzone
This fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
--- doc/guides/rel_notes/release_2_2.rst | 5 +++++ drivers/net/i40e/base/i40e_osdep.h | 2 +- drivers/net/i40e/i40e_ethdev.c | 12 +++++++----- 3 files changed, 13 insertions(+), 6 deletions(-)
doc/guides/rel_notes/release_2_2.rst +5 -0
@@ -150,6 +150,11 @@ Drivers Added discarding packets on VSI to the stats and rectify the old statistics. +* **i40e: Fixed issue of not freeing memzone.** + + Fixed the issue of not freeing memzone in the call to free the memory for + adminq DMA. + * **vhost: Fixed Qemu shutdown.** Fixed issue with libvirt ``virsh destroy`` not killing the VM.
drivers/net/i40e/base/i40e_osdep.h +1 -1
@@ -146,7 +146,7 @@ struct i40e_dma_mem {void *va;u64 pa;u32 size; -u64 id; +const void *zone; } __attribute__((packed));#define i40e_allocate_dma_mem (h, m, unused, s, a) \
drivers/net/i40e/i40e_ethdev.c +7 -5
@@ -2910,15 +2910,13 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, u64 size, u32 alignment) { -static uint64_t id =0 ;const struct rte_memzone *mz =NULL ;char z_name[RTE_MEMZONE_NAMESIZE ];if (!mem)return I40E_ERR_PARAM ; - id++; -snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); +snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64,rte_rand ());#ifdef RTE_LIBRTE_XEN_DOM0 mz =rte_memzone_reserve_bounded (z_name, size,SOCKET_ID_ANY ,0 , alignment,RTE_PGSIZE_2M );
@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,if (!mz)return I40E_ERR_NO_MEMORY ; - mem->id = id; mem->size = size; mem->va = mz->addr;#ifdef RTE_LIBRTE_XEN_DOM0
@@ -2937,6 +2934,8 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,#else mem->pa = mz->phys_addr;#endif + mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone allocated: %p" , mem->zone);return I40E_SUCCESS ; }
@@ -2950,9 +2949,12 @@ enum i40e_status_code i40e_free_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, struct i40e_dma_mem *mem) { -if (!mem || !mem->va) +if (!mem)return I40E_ERR_PARAM ; +PMD_DRV_LOG (DEBUG ,"memzone to be freed: %p" , mem->zone); +rte_memzone_free ((const struct rte_memzone *)mem->zone); + mem->zone =NULL ; mem->va =NULL ; mem->pa = (u64 )0 ;
Signature · 1 line
1.9.3
drivers/net/i40e/i40e_ethdev.c i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, · line 2919
Quoted 10 lines
drivers/net/i40e/i40e_ethdev.c +1
-3-static uint64_t id =0 ;const struct rte_memzone *mz =NULL ;char z_name[RTE_MEMZONE_NAMESIZE ];if (!mem)return I40E_ERR_PARAM ; - id++; -snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); +snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64,rte_rand ());
Why change id++ to rte_rand() ?
Quoted 14 lines
#ifdef
RTE_LIBRTE_XEN_DOM0
mz = rte_memzone_reserve_bounded(z_name, size,SOCKET_ID_ANY, 0,drivers/net/i40e/i40e_ethdev.c +0
-1alignment, RTE_PGSIZE_2M);@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, if (!mz) return I40E_ERR_NO_MEMORY; - mem->id = id; mem->size = size; mem->va = mz->addr;#ifdef
RTE_LIBRTE_XEN_DOM0
drivers/net/i40e/i40e_ethdev.c i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, · line 2940
Quoted 7 lines
drivers/net/i40e/i40e_ethdev.c +2
-0@@ -2937,6 +2934,8 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, #else mem->pa = mz->phys_addr;#endif + mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone allocated: %p" , mem->zone);
Why not print the name of mem_zone instead of pointer?
Thanks
Jingjing
Quoted 12 lines
-----Original Message-----
From: Wu, Jingjing
Sent: Friday, November 6, 2015 1:40 PM
To: Zhang, Helin; [email protected]
Subject: RE: [PATCH] i40e: fix the issue of not freeing memzoneQuoted 4 lines
drivers/net/i40e/i40e_ethdev.c +0
-1-static uint64_t id =0 ;const struct rte_memzone *mz =NULL ;char z_name[RTE_MEMZONE_NAMESIZE ];
Quoted 8 lines
drivers/net/i40e/i40e_ethdev.c i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, · line 2919
Quoted 6 lines
drivers/net/i40e/i40e_ethdev.c +1
-2if (!mem)return I40E_ERR_PARAM ; - id++; -snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); +snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64,rte_rand ());Why change id++ to
rte_rand()?
Don't need to maintain the ID, which may have race condition issue.
Get a random data is good enough. Some other PMDs are using tsc count for the similar purpose.
Quoted 9 lines
Quoted 9 lines
#ifdef
RTE_LIBRTE_XEN_DOM0drivers/net/i40e/i40e_ethdev.c +0
-0mz =rte_memzone_reserve_bounded (z_name, size,SOCKET_ID_ANY ,0 , alignment,RTE_PGSIZE_2M );@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, if (!mz) return I40E_ERR_NO_MEMORY;
Quoted 13 lines
drivers/net/i40e/i40e_ethdev.c i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, · line 2940
Quoted 12 lines
drivers/net/i40e/i40e_ethdev.c +0
-1- mem->id = id; mem->size = size; mem->va = mz->addr;#ifdef
RTE_LIBRTE_XEN_DOM0drivers/net/i40e/i40e_ethdev.c +2
-0@@ -2937,6 +2934,8 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, #else mem->pa = mz->phys_addr;#endif + mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone allocated: %p" , mem->zone);Why not print the name of
mem_zoneinstead of pointer?
Good idea to print the name instead, and possible physical address, virtual address, etc.
Regards,
Helin
Quoted 4 lines
Thanks
Jingjing
PATCH v2 1/1 i40e: fix the issue of not freeing memzone
In reply to Helin ZhangThis fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
--- doc/guides/rel_notes/release_2_2.rst | 5 +++++ drivers/net/i40e/base/i40e_osdep.h | 2 +- drivers/net/i40e/i40e_ethdev.c | 14 +++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-)
v2 changes:
Reworked debug messages.
doc/guides/rel_notes/release_2_2.rst +5 -0
@@ -150,6 +150,11 @@ Drivers Added discarding packets on VSI to the stats and rectify the old statistics. +* **i40e: Fixed issue of not freeing memzone.** + + Fixed the issue of not freeing memzone in the call to free the memory for + adminq DMA. + * **vhost: Fixed Qemu shutdown.** Fixed issue with libvirt ``virsh destroy`` not killing the VM.
drivers/net/i40e/base/i40e_osdep.h +1 -1
@@ -146,7 +146,7 @@ struct i40e_dma_mem {void *va;u64 pa;u32 size; -u64 id; +const void *zone; } __attribute__((packed));#define i40e_allocate_dma_mem (h, m, unused, s, a) \
drivers/net/i40e/i40e_ethdev.c +9 -5
@@ -2910,15 +2910,13 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, u64 size, u32 alignment) { -static uint64_t id =0 ;const struct rte_memzone *mz =NULL ;char z_name[RTE_MEMZONE_NAMESIZE ];if (!mem)return I40E_ERR_PARAM ; - id++; -snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); +snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64,rte_rand ());#ifdef RTE_LIBRTE_XEN_DOM0 mz =rte_memzone_reserve_bounded (z_name, size,SOCKET_ID_ANY ,0 , alignment,RTE_PGSIZE_2M );
@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,if (!mz)return I40E_ERR_NO_MEMORY ; - mem->id = id; mem->size = size; mem->va = mz->addr;#ifdef RTE_LIBRTE_XEN_DOM0
@@ -2937,6 +2934,9 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,#else mem->pa = mz->phys_addr;#endif + mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone %s allocated with physical address: %p" , + mz->name, mem->pa);return I40E_SUCCESS ; }
@@ -2950,9 +2950,13 @@ enum i40e_status_code i40e_free_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, struct i40e_dma_mem *mem) { -if (!mem || !mem->va) +if (!mem)return I40E_ERR_PARAM ; +PMD_DRV_LOG (DEBUG ,"memzone %s to be freed with physical address: %p" , + ((const struct rte_memzone *)mem->zone)->name, mem->pa); +rte_memzone_free ((const struct rte_memzone *)mem->zone); + mem->zone =NULL ; mem->va =NULL ; mem->pa = (u64 )0 ;
Signature · 1 line
1.9.3
Quoted 9 lines
-----Original Message-----
From: Zhang, Helin
Sent: Friday, November 06, 2015 3:57 PM
To: [email protected]
Cc: Wu, Jingjing; Zhang, Helin
Subject: [PATCH v2] i40e: fix the issue of not freeing memzone
Quoted 4 lines
This fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
Signed-off-by Helin Zhang <[email protected]>
2015-11-06 15:57, Helin Zhang:
Quoted 4 lines
This fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
Signed-off-by Helin Zhang <[email protected]>
Please could you add a "Fixes:" line?
Thanks
Quoted 9 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, November 6, 2015 6:20 PM
To: Zhang, Helin
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] i40e: fix the issue of not freeing memzone
Quoted 8 lines
2015-11-06 15:57, Helin Zhang:
Quoted 4 lines
This fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
Signed-off-by Helin Zhang <[email protected]>Please could you add a "Fixes:" line?
Thanks
Sure, will send a new patch for that. Thanks!
Helin
PATCH v3 1/1 i40e: fix the issue of not freeing memzone
In reply to Helin ZhangThis fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
--- doc/guides/rel_notes/release_2_2.rst | 5 +++++ drivers/net/i40e/base/i40e_osdep.h | 2 +- drivers/net/i40e/i40e_ethdev.c | 14 +++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-)
doc/guides/rel_notes/release_2_2.rst +5 -0
@@ -150,6 +150,11 @@ Drivers Added discarding packets on VSI to the stats and rectify the old statistics. +* **i40e: Fixed issue of not freeing memzone.** + + Fixed the issue of not freeing memzone in the call to free the memory for + adminq DMA. + * **vhost: Fixed Qemu shutdown.** Fixed issue with libvirt ``virsh destroy`` not killing the VM.
drivers/net/i40e/base/i40e_osdep.h +1 -1
@@ -146,7 +146,7 @@ struct i40e_dma_mem {void *va;u64 pa;u32 size; -u64 id; +const void *zone; } __attribute__((packed));#define i40e_allocate_dma_mem (h, m, unused, s, a) \
drivers/net/i40e/i40e_ethdev.c +9 -5
@@ -2910,15 +2910,13 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, u64 size, u32 alignment) { -static uint64_t id =0 ;const struct rte_memzone *mz =NULL ;char z_name[RTE_MEMZONE_NAMESIZE ];if (!mem)return I40E_ERR_PARAM ; - id++; -snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); +snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64,rte_rand ());#ifdef RTE_LIBRTE_XEN_DOM0 mz =rte_memzone_reserve_bounded (z_name, size,SOCKET_ID_ANY ,0 , alignment,RTE_PGSIZE_2M );
@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,if (!mz)return I40E_ERR_NO_MEMORY ; - mem->id = id; mem->size = size; mem->va = mz->addr;#ifdef RTE_LIBRTE_XEN_DOM0
@@ -2937,6 +2934,9 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,#else mem->pa = mz->phys_addr;#endif + mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone %s allocated with physical address: %p" , + mz->name, mem->pa);return I40E_SUCCESS ; }
@@ -2950,9 +2950,13 @@ enum i40e_status_code i40e_free_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, struct i40e_dma_mem *mem) { -if (!mem || !mem->va) +if (!mem)return I40E_ERR_PARAM ; +PMD_DRV_LOG (DEBUG ,"memzone %s to be freed with physical address: %p" , + ((const struct rte_memzone *)mem->zone)->name, mem->pa); +rte_memzone_free ((const struct rte_memzone *)mem->zone); + mem->zone =NULL ; mem->va =NULL ; mem->pa = (u64 )0 ;
Signature · 1 line
1.9.3
Helin,
There is a compilation error.
2015-11-09 09:20, Helin Zhang:
drivers/net/i40e/i40e_ethdev.c i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, · line 2939
Quoted 3 lines
drivers/net/i40e/i40e_ethdev.c +3
-0+ mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone %s allocated with physical address: %p" , + mz->name, mem->pa);
error: format ‘%p’ expects argument of type ‘void *’, but argument 6 has type ‘u64 {aka long unsigned int}’
PATCH v4 1/1 i40e: fix the issue of not freeing memzone
In reply to Helin ZhangThis fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
--- doc/guides/rel_notes/release_2_2.rst | 5 +++++ drivers/net/i40e/base/i40e_osdep.h | 2 +- drivers/net/i40e/i40e_ethdev.c | 15 ++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-)
v2 changes:
Reworked the debug logs.
v3 changes:
Added more info into the commit logs.
v4 changes:
Fixed the compile issues in debug mode.
doc/guides/rel_notes/release_2_2.rst +5 -0
@@ -150,6 +150,11 @@ Drivers Added discarding packets on VSI to the stats and rectify the old statistics. +* **i40e: Fixed issue of not freeing memzone.** + + Fixed the issue of not freeing memzone in the call to free the memory for + adminq DMA. + * **vhost: Fixed Qemu shutdown.** Fixed issue with libvirt ``virsh destroy`` not killing the VM.
drivers/net/i40e/base/i40e_osdep.h +1 -1
@@ -146,7 +146,7 @@ struct i40e_dma_mem {void *va;u64 pa;u32 size; -u64 id; +const void *zone; } __attribute__((packed));#define i40e_allocate_dma_mem (h, m, unused, s, a) \
drivers/net/i40e/i40e_ethdev.c +10 -5
@@ -2910,15 +2910,13 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, u64 size, u32 alignment) { -static uint64_t id =0 ;const struct rte_memzone *mz =NULL ;char z_name[RTE_MEMZONE_NAMESIZE ];if (!mem)return I40E_ERR_PARAM ; - id++; -snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); +snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64,rte_rand ());#ifdef RTE_LIBRTE_XEN_DOM0 mz =rte_memzone_reserve_bounded (z_name, size,SOCKET_ID_ANY ,0 , alignment,RTE_PGSIZE_2M );
@@ -2929,7 +2927,6 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,if (!mz)return I40E_ERR_NO_MEMORY ; - mem->id = id; mem->size = size; mem->va = mz->addr;#ifdef RTE_LIBRTE_XEN_DOM0
@@ -2937,6 +2934,9 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,#else mem->pa = mz->phys_addr;#endif + mem->zone = (const void *)mz; +PMD_DRV_LOG (DEBUG ,"memzone %s allocated with physical address: " +"%" PRIu64, mz->name, mem->pa);return I40E_SUCCESS ; }
@@ -2950,9 +2950,14 @@ enum i40e_status_code i40e_free_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw, struct i40e_dma_mem *mem) { -if (!mem || !mem->va) +if (!mem)return I40E_ERR_PARAM ; +PMD_DRV_LOG (DEBUG ,"memzone %s to be freed with physical address: " +"%" PRIu64, ((const struct rte_memzone *)mem->zone)->name, + mem->pa); +rte_memzone_free ((const struct rte_memzone *)mem->zone); + mem->zone =NULL ; mem->va =NULL ; mem->pa = (u64 )0 ;
Signature · 1 line
1.9.3
Thomas Monjalon
Applied2015-11-11 13:28, Helin Zhang:
Quoted 6 lines
This fixes the issue of not freeing memzone in a call to free the memory for adminq DMA.
Fixes 4861cde46116 ("i40e: new poll mode driver")Signed-off-by Helin Zhang <[email protected]>
Applied, thanks