From patchwork Wed Nov 8 12:33:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radoslaw Biernacki X-Patchwork-Id: 118248 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5229226qgn; Wed, 8 Nov 2017 04:34:02 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q2yPi2JUkb6NcQ9l89iu+DPuWdYom1Q9/vwsavrYRagpR47Xp0++JkXnM4W8u8ZHUBGMvP X-Received: by 10.28.19.130 with SMTP id 124mr309722wmt.108.1510144442244; Wed, 08 Nov 2017 04:34:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510144442; cv=none; d=google.com; s=arc-20160816; b=eT3vGV37ke3bBA/5Q4h9gOpV1mLA2NtWl27p0x2xTfneVzJ7p5rmoCjQBVs7+X7HPF LElNkxQ3mVkxuTljkmgOAfHO7oDcmW58Oqh05QU35WTbKvoecXFN7smeZ5aitE+XCZiY U+AHhJircYKmMsDu+XQToXd97J2IdfLw8LqiH8rye1PG4gjcGM5glRuP6wxkyKvhMmpD mX3SMEfOls/DSkuzE6kgFGTc0axgOKl+F24aEbrQ+nYzknla6uTP3T4M7rQtYpfMWIWY ivZcPdA+tqqV7VxuT20hf5Vncng0iaUjLG+jZvlgFkQwD/rQzL+5NBcVKpY+EzbQDFKt 2EYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:cc:to :from:dkim-signature:arc-authentication-results; bh=EmxJ2ucc6ZqmO3fR4u37MvG0EnbvvYWFoTlMwOnl3C8=; b=lReMhNxunDIiTAB5EnEgAcOYeNWQdXOJHouzgHfJCi03nxNQ0F5vBKYOd5aZlj4q8a 6pXdb7wbgfZytNMMradrVsuSVyGopBEbgHNZ3iFHk3I/X0D2ByQuhWDDBhAmemEwcx3R TLft+P79rZ7uI0vveB8dfMuXox7YFsnFk74lA24ubxoEJBUQ7w10TCZKJbb75dpV7rzQ R3mPvhOWg1hJG4zhABVFBObqdrgQkHJ+CLa4JqabrbKOthygb4Riut6dMhUooReT4XKu GcfJc+1KCm0FbKQbvS+EaVrJUM7Ws19+J5IuGVQe2PQM98ZouFEVuyw3yhNhZYoBIl8+ QYsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Tt2M9kWD; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id h67si3414174wmg.63.2017.11.08.04.34.02; Wed, 08 Nov 2017 04:34:02 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Tt2M9kWD; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4FA6B1B3AA; Wed, 8 Nov 2017 13:34:01 +0100 (CET) Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 4C0821B347 for ; Wed, 8 Nov 2017 13:34:00 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id l22so2258279wrc.11 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=OzfAvRaUHMQ0BC2SFbbjaPK9bhU8lIuD13IEHRPYDrrUEXH+QWlEEQHRFrBKi1pVLf 31svg47oj9cmAxp3DMWY4at0gBbz2KmAndcSAUTZYvHjDeLFNU2VokYLqPnNUXtI2K3c zlbo/I6oU1o3O5aVMe9E+bwIfnqzALEc6lO9M0XOjWXzaiGE3lEDpvhXCXxPVH28T8Hx l355BQBc9bwXsIuxwGPY1wbpIeqqXB1rYzSFnNw+7Z5FKYdozXkgM3iTzkSWGPYGBMIK PEu1zGTnIRUjzyNlszZQCsgP2S6aWQd8jHPr5KfjPZNKKTHUTKgOJi7TauQWJiQQfoF6 +/AQ== X-Gm-Message-State: AJaThX6/kTobiinSX1ZiKQBWTjSN7sTFjtYVFQ4MwOkyZUNrWaFsTpzL c3MoW6no2cNuhsXk2WEl8HLfo36FHqQ= 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-dev] [PATCH] test/memzone: fixing memory leak in memzone autotest X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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(-) -- 2.7.4 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; }