From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 031111B414 for ; Tue, 30 Jan 2018 19:26:20 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2018 10:26:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,435,1511856000"; d="scan'208";a="27519412" Received: from silpixa00398672.ir.intel.com ([10.237.223.111]) by orsmga001.jf.intel.com with ESMTP; 30 Jan 2018 10:26:17 -0800 From: Harry van Haaren To: dev@dpdk.org Cc: pbhagavatula@caviumnetworks.com, Harry van Haaren , thomas@monjalon.net Date: Tue, 30 Jan 2018 18:26:09 +0000 Message-Id: <1517336769-18052-1-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517336497-17943-1-git-send-email-harry.van.haaren@intel.com> References: <1517336497-17943-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2] test: fix debug autotest with eal cleanup addition 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: , X-List-Received-Date: Tue, 30 Jan 2018 18:26:21 -0000 Before this patch, the debug_autotest would call fork(), call rte_panic() or rte_exit() in the child process, and examine the return code to verify that rte_panic() and rte_exit() were correctly reporting failures. With the inclusion of the rte_eal_cleanup() patch, rte_exit() was modified to cleanly tear-down EAL allocations. Currently only one library (service cores) is allocated by EAL at startup and should be cleaned up. This library has a check on a normal (non-hugepage) variable to protect against double cleanup. The service cores finalize() function itself frees back hugepage mem. Given the fork() approach from the unit test, and the fact that the double-free check is on an ordinary variable, causes multiple child processed (fork()-ed from the unit-test runner) to attempt to free the huge-page memory multiple times. The variable to protect against double-cleanup was not effective, as the fork() would restore it to show initialized in the next child. The solution is to call rte_service_finalize() *before* calling fork(), which results in the service cores double-cleanup variable to be zero before the fork(), and hence the child processes never free the hugepage service-cores memory (correct behavior, as the unit-test suite is still running, and owns the hugepages). Fixes: aec9c13c5257 ("eal: add function to release internal resources") Reported-by: Pavan Nikhilesh Signed-off-by: Harry van Haaren --- v2: - Fix 2 typo/spello mistakes in commit message Cc: thomas@monjalon.net Please consider for including in RC2 as this fixes the currently failing debug_autotest. --- test/test/test_debug.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test/test_debug.c b/test/test/test_debug.c index dd0de44..faf2cf5 100644 --- a/test/test/test_debug.c +++ b/test/test/test_debug.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "test.h" @@ -50,6 +51,11 @@ test_exit_val(int exit_val) int pid; int status; + /* manually cleanup EAL memory, as the fork() below would otherwise + * cause the same hugepages to be free()-ed multiple times. + */ + rte_service_finalize(); + pid = fork(); if (pid == 0) -- 2.7.4