From patchwork Wed Mar 18 19:02:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerin Jacob Kollanukkaran X-Patchwork-Id: 66856 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 12F80A0579; Wed, 18 Mar 2020 20:03:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 229081C0AB; Wed, 18 Mar 2020 20:02:32 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 53C4F1C0AB for ; Wed, 18 Mar 2020 20:02:31 +0100 (CET) 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 02IJ1Qh5019385; Wed, 18 Mar 2020 12:02:30 -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=iIEqszmX2G6pDbZ9qLMSNgSQ77sh1gfn1j7sQvsI8dk=; b=FvJpOBV5F/DSvqefJ2hNGJICqIYnfpe1qMpM0fx7nKmZuxOmveq5abnZqrJ2mfsORwnb kBfYH+fLd1nRHlU2TbMLsaD+/zJT7KrsIGKD3LQElJsj1ojAjY7fNaCDD10237aPZj9E KR04aaOjetAEj3C1x6wYcPf5DRD3oKTeluEyUyGoBM8JaY8Zz6IvrUgBPHGhc7JiapL+ YEs7jVZ2nd6hQGdfMujWVNqmkBLNLhNVX4fnrdV9C5Dq8cJOZkKU1mGipxF33I53Ql/5 5Qt2BMgxAP7djy5vThVhH0SNWBmV/+tFesrtzUGueivYv3Gjo4M2a9EKjtCm/CnCJa3+ Pg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2yu9rpbrnq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 12:02:30 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 12:02:29 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 12:02:28 -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; Wed, 18 Mar 2020 12:02:28 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 9E4CD3F703F; Wed, 18 Mar 2020 12:02:26 -0700 (PDT) From: To: Jerin Jacob , Sunil Kumar Kori CC: , , , , Date: Thu, 19 Mar 2020 00:32:15 +0530 Message-ID: <20200318190241.3150971-7-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318190241.3150971-1-jerinj@marvell.com> References: <20200318190241.3150971-1-jerinj@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-18_07:2020-03-18, 2020-03-18 signatures=0 Subject: [dpdk-dev] [PATCH v1 06/32] eal/trace: get bootup timestamp for trace 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: Jerin Jacob Find epoch_sec, epoch_nsec and uptime_ticks time information on eal_trace_init()/bootup to derive the time in the trace. Signed-off-by: Jerin Jacob --- lib/librte_eal/common/eal_common_trace.c | 3 +++ .../common/eal_common_trace_utils.c | 22 +++++++++++++++++++ lib/librte_eal/common/eal_trace.h | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index abb221cf3..51c4dd550 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -59,6 +59,9 @@ eal_trace_init(void) if (trace_mkdir()) goto fail; + /* Save current epoch timestamp for future use */ + if (trace_epoch_time_save()) + goto fail; rte_trace_global_mode_set(trace.mode); diff --git a/lib/librte_eal/common/eal_common_trace_utils.c b/lib/librte_eal/common/eal_common_trace_utils.c index f7d59774c..340ab62e4 100644 --- a/lib/librte_eal/common/eal_common_trace_utils.c +++ b/lib/librte_eal/common/eal_common_trace_utils.c @@ -98,6 +98,28 @@ trace_session_name_generate(char *trace_dir) return -rte_errno; } +int +trace_epoch_time_save(void) +{ + struct trace *trace = trace_obj_get(); + struct timespec epoch = { 0, 0 }; + uint64_t avg, start, end; + + start = rte_get_tsc_cycles(); + if (clock_gettime(CLOCK_REALTIME, &epoch) < 0) { + trace_err("failed to get the epoch time"); + return -1; + } + end = rte_get_tsc_cycles(); + avg = (start + end) >> 1; + + trace->epoch_sec = (uint64_t) epoch.tv_sec; + trace->epoch_nsec = (uint64_t) epoch.tv_nsec; + trace->uptime_ticks = avg; + + return 0; +} + static int trace_dir_default_path_get(char *dir_path) { diff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_trace.h index 10c2f03ac..9807613d2 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -5,6 +5,7 @@ #ifndef __EAL_TRACE_H #define __EAL_TRACE_H +#include #include #include #include @@ -38,6 +39,9 @@ struct trace { rte_uuid_t uuid; uint32_t level; uint32_t nb_trace_points; + uint64_t epoch_sec; + uint64_t epoch_nsec; + uint64_t uptime_ticks; rte_spinlock_t lock; }; @@ -60,6 +64,7 @@ struct trace_point_head *trace_list_head_get(void); bool trace_has_duplicate_entry(void); void trace_uuid_generate(void); int trace_mkdir(void); +int trace_epoch_time_save(void); /* EAL interface */ int eal_trace_init(void);