From patchwork Sat Nov 13 17:22:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 104280 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 50889A0032; Sat, 13 Nov 2021 18:23:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DEDC410FA; Sat, 13 Nov 2021 18:23:03 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 09CD34013F for ; Sat, 13 Nov 2021 18:23:02 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id n26so6587241pff.3 for ; Sat, 13 Nov 2021 09:23:01 -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=Ob+Y965IrfCVmT59+AWP48d7+i7jy+ZMpybYol04JJfYj01s761P0vhU5Ajohn3cDn oFwIaY+bYCJD+vOXxw56yiaLE6OZgOFwaTo73EIADOYPLsKRqdLaEPX7h+E8eT60L/aa Gh9+EYdopfXRD4yBCPCJT8DQqDpPoHtzNCQ/5GD854dIiP3YseYuoP8hmOZco3fxdvxZ VOAByPzqRLpoJ+uEzHiEEO2/hFc2vrajNscD0SXji0OQMsrOQQVIsVAFeNSr4c1ThE+e Sqo1Stn6A7+RIbcvOYenk9l45aQEjSaJnM8delTTBwH9D4P8eMNcGKZiuwNblaY0SJVt amRg== 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=KRbfxY56cl6jL9oHpzRr97TKAwSxSd5LNPmWXHb+RjuUtnu+LCmZHBiJvG+vmtzbyX cq6LSKBsITI2D9XOduQ2xRNsCsd2r5MFY4faMNLgKS6+THVa4X9lZppYJXipBh1+P+NI 6BH7rABW7as6qGvfbiTiCtFKfOGkhHSuJrtWjHzevrLxtUIn2W7TqJ/zgDOHLPc8FSZ4 j2YusNIXyq9kvKtkNc+jZ/df6ZPo93DBBQ47riA/aJOMUMBAh9lUAzPLKkB+2FZI0QCI tpLtcWTnv1U340fUBEPY5H9kGK+jDR2JhJc84FuO+vb97uuH+ISgYfsEVpoDQk4xZgsj zDkA== X-Gm-Message-State: AOAM530lzY/qn/o+O2dA0vpF1NoN827CYPylDRQgUrIB+ie1P5/V2geT J4Pky5HyclDXr+InviITTYUmPN7eQx73gw== X-Google-Smtp-Source: ABdhPJwZD/PFMWGHB6QhizEHCX8xTymCwOKStM+TvbLPLK/7/I9wzcogU+pK8florSTYgHk7vLxhCg== X-Received: by 2002:a63:e214:: with SMTP id q20mr15693118pgh.431.1636824180778; Sat, 13 Nov 2021 09:23:00 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id u19sm9658370pfl.185.2021.11.13.09.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 09:23:00 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 1/5] eal: close log in eal_cleanup Date: Sat, 13 Nov 2021 09:22:53 -0800 Message-Id: <20211113172257.6543-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113172257.6543-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113172257.6543-1-stephen@networkplumber.org> MIME-Version: 1.0 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, }; /*