From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CC919A0032; Sat, 13 Nov 2021 01:28:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3ADF410FA; Sat, 13 Nov 2021 01:28:31 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id D2A1D4013F for ; Sat, 13 Nov 2021 01:28:29 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id gf14-20020a17090ac7ce00b001a7a2a0b5c3so8256049pjb.5 for ; Fri, 12 Nov 2021 16:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oiWywhA3WofE4yHKF3rzYgZO+5QXk1lx/khQFCnptBk=; b=TuCfAUG347T3nOqukAFIfGLqj3ptC75YSpMh3LVCtqhS/3LvFYOm/QCtdE8yEGSdRj hmn+C8KKDo5iB2lulihdcKSLfHqgE83PnzGbp/L6SqNa0mFG8oG7Usgj1OylIuykb24j uaSdE1r1A0SgNU1hp/LIIRLhS8XMkGLK4UgZgNVB0OCDK9LMjs+cKq2g7ABPLeQoO9dM iUA2ZWRS3RafLDSl+pztdJ5IA8T0vBTvifoxAV5T4pYrJj+iEboyYLsMyRP5RroH7iS2 2g3x5vGH2utBogvi/RRqc8M7uNR9u4NOfDy/g2r2eSRcGQ6Q5rDKY6YMOAsgyWTmjrvq 0v9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oiWywhA3WofE4yHKF3rzYgZO+5QXk1lx/khQFCnptBk=; b=F+YmUVLPHj5S2qdvO7nRE7B5iryKTpR6dAIJ++7m8VmemIpwoWRarLHwYXuPVIV267 2136BB5vPsiV2ZjLTD4sQt4hGiCKMTvO2mIvqvwUJdkxan72JK+Zf1PSDToQr6DVS0RM qaiVsZJN12bgMuFg/EyX51JYKuycFYAMBx/dO5umF3xWx51CxA1juKpqReIQJFwthG4w lsTNyDyfXw/MDAprPdjmfff46DN9JVjFNADNRkUWsPDyrIMDzcGyGuONytM7hgxFMQyf B7sfCPFpUryuK2KKe/+aoyZCbf4gbnPUug50ToQoDBM933mULSC335Uv23BL9I3pHFTX q9GQ== X-Gm-Message-State: AOAM53166zq5DlNyp8zy3GJ71VnbHtrdbNJxfp1m0ANfy3qs9Izq+iCf EBBt4uB8paftfxie4qs+WS6iW9g8+UH7fA== X-Google-Smtp-Source: ABdhPJyo8X2fdpjGAe2kw7XVn6iSRbY7FLQKaq3w3aJmlscbgtlo/tRr3zMf+Z86qGp3R0+GRF+7Ag== X-Received: by 2002:a17:90b:128d:: with SMTP id fw13mr22931079pjb.50.1636763308523; Fri, 12 Nov 2021 16:28:28 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id z10sm7687748pfh.106.2021.11.12.16.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 16:28:27 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v4 1/5] eal: close log in eal_cleanup Date: Fri, 12 Nov 2021 16:28:20 -0800 Message-Id: <20211113002824.338343-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113002824.338343-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113002824.338343-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When application calls rte_eal_cleanup on shutdown, the DPDK log should be closed and cleaned up. This helps reduce false reports from tools like ASAN and valgrind that track memory leaks. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 13 +++++++++++++ lib/eal/common/eal_private.h | 7 +++++++ lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_log.c | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 1be35f539727..cbd0b851f216 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -18,6 +18,7 @@ #include #include "eal_log.h" +#include "eal_private.h" struct rte_log_dynamic_type { const char *name; @@ -535,3 +536,15 @@ eal_log_set_default(FILE *default_log) "Debug dataplane logs available - lower performance\n"); #endif } + +/* + * Called by eal_cleanup + */ +void +rte_eal_log_cleanup(void) +{ + if (default_log_stream) { + fclose(default_log_stream); + default_log_stream = NULL; + } +} diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 36bcc0b5a492..2fbad534b938 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -152,6 +152,13 @@ int rte_eal_tailqs_init(void); */ int rte_eal_intr_init(void); +/** + * Close the default log stream + * + * This function is private to EAL. + */ +void rte_eal_log_cleanup(void); + /** * Init alarm mechanism. This is to allow a callback be called after * specific time. diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b49248388e..b67030b2792e 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1370,6 +1370,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(internal_conf); + rte_eal_log_cleanup(); return 0; } diff --git a/lib/eal/linux/eal_log.c b/lib/eal/linux/eal_log.c index c0aa1007c4df..5a795ac9ebe3 100644 --- a/lib/eal/linux/eal_log.c +++ b/lib/eal/linux/eal_log.c @@ -37,8 +37,16 @@ console_log_write(__rte_unused void *c, const char *buf, size_t size) return ret; } +static int +console_log_close(__rte_unused void *c) +{ + closelog(); + return 0; +} + static cookie_io_functions_t console_log_func = { .write = console_log_write, + .close = console_log_close, }; /* -- 2.30.2