From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 3584F1B343 for ; Wed, 8 Nov 2017 13:34:00 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id q66so2249988wrb.13 for ; Wed, 08 Nov 2017 04:34:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=EmxJ2ucc6ZqmO3fR4u37MvG0EnbvvYWFoTlMwOnl3C8=; b=Tt2M9kWD4KfQyhAr3MAyRxl2kbJOxs8AFfZWLdw6cqjPr6MRS/TteokMxOq6hfao0c BYLsWcHLUYTZ2eJUEEruHY0tDgu/LvA0dj3vjq9apB5yw7Gv8irorf4rrQHNvS5vwqRE IYF0x89vLseBvpQpnSQLblv/HvVr01Yg9qUa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EmxJ2ucc6ZqmO3fR4u37MvG0EnbvvYWFoTlMwOnl3C8=; b=uMuuzWy+4ZeOvzAhdovt9VYcDQ8DC9RVutVMGRDaGtn5MW8YgPLYOhNA7ISo9QzqBL kLP/aXiYfwPxWTTmudsBMf7ZlQzvWWm1p1y9c1svBJ9XGIhG/3n/HvAuEJPw+e10Vxmy vz35Ufawy1sbrXyIRe01m9vpVeAmz8xUk8Ag2MML0VHEm2WVQ6ghlsIhypLYDBne/IOX aQjNG+mpK6Uo6uRbJUPAmmmnY5TXVcmcJKvvvBMeADB89hhVifSSzUFb/7mAXNMRgS0S 1kCPxLoc/WawbDq5OzjNHfrgPvMJJifN3YJ82pPpfOcXEJOx242z3tK1YPiaR2wgtu11 2ceg== X-Gm-Message-State: AJaThX6Ewwp+n8AGq5s/t6JpQADtl/edTub3uWIDSLFTSghLZ5gkY7nP NMlQY0oUoD9t1tnmWsp5qF1NyQ== X-Google-Smtp-Source: ABhQp+QDhqhyrvcuHGw5WqMbNZPVbolES0OkBdhqz09Ld6GUgz9+379KGYpjhV+e2CypTMalxiQBXg== X-Received: by 10.223.164.154 with SMTP id g26mr360188wrb.137.1510144439798; Wed, 08 Nov 2017 04:33:59 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s18sm1362367wrg.87.2017.11.08.04.33.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 04:33:59 -0800 (PST) From: Radoslaw Biernacki To: dev@dpdk.org, sergio.gonzalez.monroy@intel.com Cc: stable@dpdk.org Date: Wed, 8 Nov 2017 13:33:14 +0100 Message-Id: <1510144394-31678-1-git-send-email-radoslaw.biernacki@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-stable] [PATCH] test/memzone: fixing memory leak in memzone autotest 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, 08 Nov 2017 12:34:00 -0000 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 --- 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