* [dpdk-stable] [PATCH] test/memzone: fixing memory leak in memzone autotest
@ 2017-11-08 12:33 Radoslaw Biernacki
2017-11-11 11:26 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Radoslaw Biernacki @ 2017-11-08 12:33 UTC (permalink / raw)
To: dev, sergio.gonzalez.monroy; +Cc: stable
This patch fixes the memory leaks in memzone_autotest. Those memory leaks
lead to failures in tests from the same testing group due to out of memory
problems. With introduction of rte_memzone_free() it is now possible to
free the memzone. Fix uses this API call to make a clean after each test
case.
Fixes: ff909fe21f0a ("mem: introduce memzone freeing")
Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
---
test/test/test_memzone.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 134 insertions(+), 1 deletion(-)
diff --git a/test/test/test_memzone.c b/test/test/test_memzone.c
index c9394c4..1cf235a 100644
--- a/test/test/test_memzone.c
+++ b/test/test/test_memzone.c
@@ -176,6 +176,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 2M\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
@@ -187,6 +191,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 2M\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
/* Check if 1GB huge pages are unavailable, that function fails unless
* HINT flag is indicated
@@ -202,6 +210,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 2M\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
RTE_MEMZONE_1GB);
@@ -224,6 +236,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 1G\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
@@ -235,6 +251,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 1G\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
/* Check if 1GB huge pages are unavailable, that function fails unless
* HINT flag is indicated
@@ -250,12 +270,20 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 1G\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
RTE_MEMZONE_2MB);
if (mz != NULL) {
printf("MEMZONE FLAG 2MB\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
}
if (hugepage_2MB_avail && hugepage_1GB_avail) {
@@ -285,6 +313,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 16M\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
SOCKET_ID_ANY, RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
@@ -296,6 +328,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 16M\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
/* Check if 1GB huge pages are unavailable, that function fails
* unless HINT flag is indicated
@@ -312,6 +348,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 16M\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_16G", size,
SOCKET_ID_ANY, RTE_MEMZONE_16GB);
@@ -333,6 +373,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 16G\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_16G_HINT", size,
SOCKET_ID_ANY, RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
@@ -344,6 +388,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 16G\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
/* Check if 1GB huge pages are unavailable, that function fails
* unless HINT flag is indicated
@@ -360,6 +408,10 @@ test_memzone_reserve_flags(void)
printf("hugepage_sz not equal 16G\n");
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
mz = rte_memzone_reserve("flag_zone_16M", size,
SOCKET_ID_ANY, RTE_MEMZONE_16MB);
if (mz != NULL) {
@@ -434,6 +486,12 @@ test_memzone_reserve_max(void)
rte_memzone_dump(stdout);
return -1;
}
+
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+
return 0;
}
@@ -473,6 +531,12 @@ test_memzone_reserve_max_aligned(void)
rte_memzone_dump(stdout);
return -1;
}
+
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+
return 0;
}
@@ -593,6 +657,28 @@ test_memzone_aligned(void)
if (is_memory_overlap(memzone_aligned_512->iova, memzone_aligned_512->len,
memzone_aligned_1024->iova, memzone_aligned_1024->len))
return -1;
+
+ /* free all used zones */
+ if (rte_memzone_free(memzone_aligned_32)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+ if (rte_memzone_free(memzone_aligned_128)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+ if (rte_memzone_free(memzone_aligned_256)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+ if (rte_memzone_free(memzone_aligned_512)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+ if (rte_memzone_free(memzone_aligned_1024)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
return 0;
}
@@ -638,6 +724,11 @@ check_memzone_bounded(const char *name, uint32_t len, uint32_t align,
return -1;
}
+ if (rte_memzone_free(mz)) {
+ printf("Fail memzone free\n");
+ return -1;
+ }
+
return 0;
}
@@ -758,7 +849,7 @@ test_memzone_free(void)
}
static int
-test_memzone(void)
+test_memzone_basic(void)
{
const struct rte_memzone *memzone1;
const struct rte_memzone *memzone2;
@@ -837,6 +928,40 @@ test_memzone(void)
if (mz != NULL)
return -1;
+ if (rte_memzone_free(memzone1)) {
+ printf("Fail memzone free - memzone1\n");
+ return -1;
+ }
+ if (rte_memzone_free(memzone2)) {
+ printf("Fail memzone free - memzone2\n");
+ return -1;
+ }
+ if (memzone3 && rte_memzone_free(memzone3)) {
+ printf("Fail memzone free - memzone3\n");
+ return -1;
+ }
+ if (rte_memzone_free(memzone4)) {
+ printf("Fail memzone free - memzone4\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int memzone_calk_called;
+static void memzone_walk_clb(const struct rte_memzone *mz __rte_unused,
+ void *arg __rte_unused)
+{
+ memzone_calk_called = 1;
+}
+
+static int
+test_memzone(void)
+{
+ printf("test basic memzone API\n");
+ if (test_memzone_basic() < 0)
+ return -1;
+
printf("test free memzone\n");
if (test_memzone_free() < 0)
return -1;
@@ -869,6 +994,14 @@ test_memzone(void)
if (test_memzone_reserve_max_aligned() < 0)
return -1;
+ printf("check memzone cleanup\n");
+ rte_memzone_walk(memzone_walk_clb, NULL);
+ if (memzone_calk_called) {
+ printf("there are some memzones left after test\n");
+ rte_memzone_dump(stdout);
+ return -1;
+ }
+
return 0;
}
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-stable] [PATCH] test/memzone: fixing memory leak in memzone autotest
2017-11-08 12:33 [dpdk-stable] [PATCH] test/memzone: fixing memory leak in memzone autotest Radoslaw Biernacki
@ 2017-11-11 11:26 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2017-11-11 11:26 UTC (permalink / raw)
To: Radoslaw Biernacki; +Cc: stable, dev, sergio.gonzalez.monroy
08/11/2017 13:33, Radoslaw Biernacki:
> This patch fixes the memory leaks in memzone_autotest. Those memory leaks
> lead to failures in tests from the same testing group due to out of memory
> problems. With introduction of rte_memzone_free() it is now possible to
> free the memzone. Fix uses this API call to make a clean after each test
> case.
>
> Fixes: ff909fe21f0a ("mem: introduce memzone freeing")
>
> Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-11 13:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 12:33 [dpdk-stable] [PATCH] test/memzone: fixing memory leak in memzone autotest Radoslaw Biernacki
2017-11-11 11:26 ` Thomas Monjalon
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).