From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BEF00A0577; Mon, 13 Apr 2020 17:08:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6171F1C0B8; Mon, 13 Apr 2020 17:03:11 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id C0B6B1C0CD for ; Mon, 13 Apr 2020 17:03:09 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03DExsM0014653; Mon, 13 Apr 2020 08:03:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=guqRDPggQhZNAgoZho8EC5HNMvABOY+mDnj3HjoEi2w=; b=uR0bBA8wHE+L25kDbTuZsuV0V5U1Rq7FyFh2UPxhBXTXG3kZ8l+DDLDJASpXunnC+kr1 sAZb/xthdGJjSaednHrXq4LnpxTvkDA86gEXRfwlxHW1Zf1lWbZ+YdCng5m7RLaS8Bsr OjD4tCY+bsFubLWKDu6j9Jx7oeb5nLYjQpKBYRzDEAIITc/2UYsSN4t22VQLfVyYdA9h JpMbJ8d+lY/EZyXzj2UEhTuB/Yw5UuWsaVbiBKllHhDui4QTkm11h7MqNb+bSkT7B1yK WbotyXMttJygz4QGKOCjTRTuszLkYV+5GuCRglE9HGvOi6qVrL0X6goW/s7EpuNAo/CD Mw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 30bb8qey1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 13 Apr 2020 08:03:08 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 13 Apr 2020 08:03:07 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 13 Apr 2020 08:03:06 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 13 Apr 2020 08:03:06 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id A4CE73F704B; Mon, 13 Apr 2020 08:03:02 -0700 (PDT) From: To: John McNamara , Marko Kovacevic , Jerin Jacob , "Sunil Kumar Kori" CC: , , , , Date: Mon, 13 Apr 2020 20:31:06 +0530 Message-ID: <20200413150116.734047-24-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413150116.734047-1-jerinj@marvell.com> References: <20200403153709.3703448-1-jerinj@marvell.com> <20200413150116.734047-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-13_07:2020-04-13, 2020-04-13 signatures=0 Subject: [dpdk-dev] [PATCH v5 23/33] eal/trace: add trace configuration parameter 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" From: Sunil Kumar Kori Trace library exposes --trace EAL parameter to enable trace points. Signed-off-by: Sunil Kumar Kori --- doc/guides/linux_gsg/eal_args.include.rst | 16 +++++ lib/librte_eal/common/eal_common_options.c | 16 +++++ lib/librte_eal/common/eal_common_trace.c | 10 ++++ .../common/eal_common_trace_utils.c | 59 +++++++++++++++++++ lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_trace.h | 11 +++- 6 files changed, 113 insertions(+), 1 deletion(-) diff --git a/doc/guides/linux_gsg/eal_args.include.rst b/doc/guides/linux_gsg/eal_args.include.rst index ed8b0e35b..d9e6a1d95 100644 --- a/doc/guides/linux_gsg/eal_args.include.rst +++ b/doc/guides/linux_gsg/eal_args.include.rst @@ -136,6 +136,22 @@ Debugging options Can be specified multiple times. +* ``--trace=`` + + Enable trace based on regular expression trace name. By default, the trace is + disabled. User must specify this option to enable trace. + For example: + + Global trace configuration for EAL only:: + + --trace=eal + + Global trace configuration for ALL the components:: + + --trace=.* + + Can be specified multiple times up to 32 times. + Other options ~~~~~~~~~~~~~ diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 525e51e7d..b2b2624e6 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -34,6 +34,7 @@ #include "eal_options.h" #include "eal_filesystem.h" #include "eal_private.h" +#include "eal_trace.h" #define BITS_PER_HEX 4 #define LCORE_OPT_LST 1 @@ -67,6 +68,7 @@ eal_long_options[] = { {OPT_IOVA_MODE, 1, NULL, OPT_IOVA_MODE_NUM }, {OPT_LCORES, 1, NULL, OPT_LCORES_NUM }, {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM }, + {OPT_TRACE, 1, NULL, OPT_TRACE_NUM }, {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM }, {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM}, {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM }, @@ -1418,6 +1420,16 @@ eal_parse_common_option(int opt, const char *optarg, } break; } + + case OPT_TRACE_NUM: { + if (eal_trace_args_save(optarg) < 0) { + RTE_LOG(ERR, EAL, "invalid parameters for --" + OPT_TRACE "\n"); + return -1; + } + break; + } + case OPT_LCORES_NUM: if (eal_parse_lcores(optarg) < 0) { RTE_LOG(ERR, EAL, "invalid parameter for --" @@ -1693,6 +1705,10 @@ eal_common_usage(void) " --"OPT_LOG_LEVEL"= Set global log level\n" " --"OPT_LOG_LEVEL"=:\n" " Set specific log level\n" + " --"OPT_TRACE"=\n" + " Enable trace based on regular expression trace name.\n" + " By default, the trace is disabled.\n" + " User must specify this option to enable trace.\n" " -v Display version information on startup\n" " -h, --help This help\n" " --"OPT_IN_MEMORY" Operate entirely in memory. This will\n" diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index 903a62a98..dd8086b88 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -38,6 +38,8 @@ trace_list_head_get(void) int eal_trace_init(void) { + uint8_t i; + /* Trace memory should start with 8B aligned for natural alignment */ RTE_BUILD_BUG_ON((offsetof(struct __rte_trace_header, mem) % 8) != 0); @@ -47,6 +49,9 @@ eal_trace_init(void) goto fail; } + if (trace.args.nb_args) + trace.global_status = true; + if (rte_trace_global_is_disabled()) return 0; @@ -71,6 +76,10 @@ eal_trace_init(void) if (trace_epoch_time_save() < 0) goto fail; + /* Apply global configurations */ + for (i = 0; i < trace.args.nb_args; i++) + trace_args_apply(trace.args.args[i]); + rte_trace_mode_set(trace.mode); return 0; @@ -89,6 +98,7 @@ eal_trace_fini(void) return; trace_mem_per_thread_free(); trace_metadata_destroy(); + eal_trace_args_free(); } bool diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c index bbe099473..7f4726d62 100644 --- a/lib/librte_eal/common/eal_common_trace_utils.c +++ b/lib/librte_eal/common/eal_common_trace_utils.c @@ -118,6 +118,65 @@ trace_session_name_generate(char *trace_dir) return -rte_errno; } +int +eal_trace_args_save(const char *optarg) +{ + struct trace *trace = trace_obj_get(); + char *trace_args; + uint8_t nb_args; + + nb_args = trace->args.nb_args; + + if (nb_args >= TRACE_MAX_ARGS) { + trace_err("ignoring trace %s as limit exceeds", optarg); + return 0; + } + + trace_args = calloc(1, (strlen(optarg) + 1)); + if (trace_args == NULL) { + trace_err("fail to allocate memory for %s", optarg); + return -ENOMEM; + } + + memcpy(trace_args, optarg, strlen(optarg)); + trace->args.args[nb_args++] = trace_args; + trace->args.nb_args = nb_args; + return 0; +} + +void +eal_trace_args_free(void) +{ + struct trace *trace = trace_obj_get(); + int i; + + for (i = 0; i < trace->args.nb_args; i++) { + if (trace->args.args[i]) { + free((void *)trace->args.args[i]); + trace->args.args[i] = NULL; + } + } +} + +int +trace_args_apply(const char *arg) +{ + char *str; + + str = strdup(arg); + if (str == NULL) + return -1; + + if (rte_trace_regexp(str, true) < 0) { + trace_err("cannot enable trace for %s", str); + free(str); + return -1; + } + + free(str); + return 0; +} + int trace_epoch_time_save(void) { diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index 9855429e5..4700410fd 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -33,6 +33,8 @@ enum { OPT_LCORES_NUM, #define OPT_LOG_LEVEL "log-level" OPT_LOG_LEVEL_NUM, +#define OPT_TRACE "trace" + OPT_TRACE_NUM, #define OPT_MASTER_LCORE "master-lcore" OPT_MASTER_LCORE_NUM, #define OPT_MBUF_POOL_OPS_NAME "mbuf-pool-ops-name" diff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_trace.h index c284a2e0b..95ab3614a 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -28,7 +28,7 @@ #define TRACE_CTF_FIELD_SIZE 384 #define TRACE_POINT_NAME_SIZE 64 #define TRACE_CTF_MAGIC 0xC1FC1FC1 - +#define TRACE_MAX_ARGS 32 struct trace_point { STAILQ_ENTRY(trace_point) next; @@ -47,6 +47,11 @@ struct thread_mem_meta { enum trace_area_e area; }; +struct trace_args { + uint8_t nb_args; + char *args[TRACE_MAX_ARGS]; +}; + struct trace { char dir[PATH_MAX]; int dir_offset; @@ -55,6 +60,7 @@ struct trace { enum rte_trace_mode mode; rte_uuid_t uuid; uint32_t buff_len; + struct trace_args args; uint32_t nb_trace_points; uint32_t nb_trace_mem_list; struct thread_mem_meta *lcore_meta; @@ -93,6 +99,7 @@ struct trace_point_head *trace_list_head_get(void); /* Util functions */ const char *trace_mode_to_string(enum rte_trace_mode mode); const char *trace_area_to_string(enum trace_area_e area); +int trace_args_apply(const char *arg); bool trace_has_duplicate_entry(void); void trace_uuid_generate(void); int trace_metadata_create(void); @@ -104,5 +111,7 @@ void trace_mem_per_thread_free(void); /* EAL interface */ int eal_trace_init(void); void eal_trace_fini(void); +int eal_trace_args_save(const char *optarg); +void eal_trace_args_free(void); #endif /* __EAL_TRACE_H */ -- 2.25.1