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 F4145A0562; Sun, 29 Mar 2020 16:49:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 853A81C0AA; Sun, 29 Mar 2020 16:45:09 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 1DF791C1B2 for ; Sun, 29 Mar 2020 16:45:08 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02TEeRWu013022; Sun, 29 Mar 2020 07:45:07 -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=BbWqYe9J6ZpYRkCae49pVVHO9GKhu1//Vayz7nylwF4=; b=HWafPkiS+xLDqUckG8hn8ljl1cufiyaHdefuTAhBE/GzqOHm9EyUkjL50c8RPQooSlwU A1OgvZbOOGBEzWpZArLFHBUWTDE7hH9svbCC7rIV7XNUE2gLLaOqErEMMYiaG8/bW/63 lpKrDGGLB86cQuDpOo9ckK+nD3FcAW4TNHDaTx96Zh2hjIklxZcBl2djQof7HS0crcMm Ce+NrdqKSfB8VCFxk65TGT//aJb1LSXEhEqsXH7y3/xt0HjbuQMQk2/C6s3qK6MWTDRC AR0UfPuqCIU/KnkmNPGk5UPwTHiWZ6KRMIYiFMODvgdSBRK/dA9LW76Mpc+K1EPqbr85 cQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 30263kb5kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 29 Mar 2020 07:45:07 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 29 Mar 2020 07:45:04 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 29 Mar 2020 07:45:04 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sun, 29 Mar 2020 07:45:03 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 78DCB3F704A; Sun, 29 Mar 2020 07:45:01 -0700 (PDT) From: To: John McNamara , Marko Kovacevic , Jerin Jacob , "Sunil Kumar Kori" CC: , , , , Date: Sun, 29 Mar 2020 20:13:33 +0530 Message-ID: <20200329144342.1543749-25-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200329144342.1543749-1-jerinj@marvell.com> References: <20200325211603.240288-1-jerinj@marvell.com> <20200329144342.1543749-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.645 definitions=2020-03-29_05:2020-03-27, 2020-03-29 signatures=0 Subject: [dpdk-dev] [PATCH v3 24/33] eal/trace: add trace dir 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-dir EAL parameter to configure directory where traces will be generated. Signed-off-by: Sunil Kumar Kori --- doc/guides/linux_gsg/eal_args.include.rst | 11 ++++ lib/librte_eal/common/eal_common_options.c | 15 ++++++ .../common/eal_common_trace_utils.c | 54 +++++++++++++++++++ lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_trace.h | 1 + 5 files changed, 83 insertions(+) diff --git a/doc/guides/linux_gsg/eal_args.include.rst b/doc/guides/linux_gsg/eal_args.include.rst index 94289d1e2..8c72363b4 100644 --- a/doc/guides/linux_gsg/eal_args.include.rst +++ b/doc/guides/linux_gsg/eal_args.include.rst @@ -155,6 +155,17 @@ Debugging options Can be specified multiple times up to 32 times. +* ``--trace-dir=`` + + Specify trace directory for trace output. For example: + + Configuring ``/tmp/`` as a trace output directory:: + + --trace-dir=/tmp + + By default, trace output will created at ``home`` directory and parameter + must be specified once only. + Other options ~~~~~~~~~~~~~ diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 0d6576a12..d71f89be2 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -69,6 +69,7 @@ eal_long_options[] = { {OPT_LCORES, 1, NULL, OPT_LCORES_NUM }, {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM }, {OPT_TRACE_LEVEL, 1, NULL, OPT_TRACE_LEVEL_NUM }, + {OPT_TRACE_DIR, 1, NULL, OPT_TRACE_DIR_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 }, @@ -1430,6 +1431,15 @@ eal_parse_common_option(int opt, const char *optarg, break; } + case OPT_TRACE_DIR_NUM: { + if (eal_trace_dir_args_save(optarg) < 0) { + RTE_LOG(ERR, EAL, "invalid parameters for --" + OPT_TRACE_DIR "\n"); + return -1; + } + break; + } + case OPT_LCORES_NUM: if (eal_parse_lcores(optarg) < 0) { RTE_LOG(ERR, EAL, "invalid parameter for --" @@ -1710,6 +1720,11 @@ eal_common_usage(void) " Set trace level specific to component\n" " Default, there is no trace level enabled\n" " User must specify this option if required\n" + " --"OPT_TRACE_DIR"=\n" + " Specify trace directory for trace output.\n" + " By default, trace output will created at\n" + " HOME directory and parameter must be\n" + " specified once only\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_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c index 1f47faed4..3c85152c7 100644 --- a/lib/librte_eal/common/eal_common_trace_utils.c +++ b/lib/librte_eal/common/eal_common_trace_utils.c @@ -118,6 +118,22 @@ trace_session_name_generate(char *trace_dir) return -rte_errno; } +static int +trace_dir_update(const char *str) +{ + struct trace *trace = trace_obj_get(); + int rc, remaining; + + remaining = sizeof(trace->dir) - trace->dir_offset; + rc = rte_strscpy(&trace->dir[0] + trace->dir_offset, str, remaining); + if (rc < 0) + goto fail; + + trace->dir_offset += rc; +fail: + return rc; +} + int eal_trace_level_args_save(const char *optarg) { @@ -222,6 +238,37 @@ trace_level_args_apply(const char *arg) return -1; } +int +eal_trace_dir_args_save(char const *optarg) +{ + struct trace *trace = trace_obj_get(); + uint32_t size = sizeof(trace->dir); + char *dir_path = NULL; + int rc; + + if (optarg == NULL) { + trace_err("no optarg is passed\n"); + return -EINVAL; + } + + if (strlen(optarg) >= size) { + trace_err("input string is too big\n"); + return -ENAMETOOLONG; + } + + dir_path = (char *)calloc(1, size); + if (dir_path == NULL) { + trace_err("fail to allocate memory\n"); + return -ENOMEM; + } + + sprintf(dir_path, "%s/", optarg); + rc = trace_dir_update(dir_path); + + free(dir_path); + return rc; +} + int trace_epoch_time_save(void) { @@ -292,6 +339,10 @@ trace_mkdir(void) return rc; } + rc = trace_dir_update(dir_path); + free(dir_path); + if (rc < 0) + return rc; } /* Create the path if it t exist, no "mkdir -p" available here */ @@ -303,6 +354,9 @@ trace_mkdir(void) } rc = trace_session_name_generate(session); + if (rc < 0) + return rc; + rc = trace_dir_update(session); if (rc < 0) return rc; diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index c274a30cc..8c8283165 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -35,6 +35,8 @@ enum { OPT_LOG_LEVEL_NUM, #define OPT_TRACE_LEVEL "trace-level" OPT_TRACE_LEVEL_NUM, +#define OPT_TRACE_DIR "trace-dir" + OPT_TRACE_DIR_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 acdc8ecab..9ff172cc0 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -114,5 +114,6 @@ int eal_trace_init(void); void eal_trace_fini(void); int eal_trace_level_args_save(const char *optarg); void eal_trace_level_args_free(void); +int eal_trace_dir_args_save(const char *optarg); #endif /* __EAL_TRACE_H */ -- 2.25.1