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 DA939A00C2; Wed, 22 Apr 2020 21:05:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 07FE01D5CF; Wed, 22 Apr 2020 21:04:53 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 9B9391D595 for ; Wed, 22 Apr 2020 21:04:34 +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 03MJ1Mam005798; Wed, 22 Apr 2020 12:04:34 -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=jeXUCTXcWX0rRLNacrflzBWNGqx0zsJGORoaOFWqh9w=; b=YagJj0Xp1ptb12mYNub1Zqq3EWc0aJlrXQDPBw1vbdVY1AlNyOulBtKOErVlK/6gpXfV ux6gZ6YmnuavANUhVdb3khBxUCgsWM0cu08jPfcw7PIwXGDDkG0rNNm/QMSA/caiSrou DpjGgRKZefWZUu6NA7HPhJSVaACRMLYocKI/i8XxjDN3tkQbdDpZA99dWCsCFzN4ugQb Xf/wuwVMJ21AJUbJ7OEruLR83RNWvv2X/wrK/+I893O5PhK+GlaBbME3iUbHQ0NMqMsm 9agLZZVobTluxPF3TQiYJ1E7VnHShoLXFSbTwD2ICq6qlXpfUE2JkB+09TGLdc/fUz+r sQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 30jd013jfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 22 Apr 2020 12:04:33 -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; Wed, 22 Apr 2020 12:04:31 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 22 Apr 2020 12:04:31 -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; Wed, 22 Apr 2020 12:04:31 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id C1F503F703F; Wed, 22 Apr 2020 12:04:28 -0700 (PDT) From: To: Jerin Jacob , Sunil Kumar Kori CC: , , , , Date: Thu, 23 Apr 2020 00:33:27 +0530 Message-ID: <20200422190349.3768487-11-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200422190349.3768487-1-jerinj@marvell.com> References: <20200419100133.3232316-1-jerinj@marvell.com> <20200422190349.3768487-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-22_06:2020-04-22, 2020-04-22 signatures=0 Subject: [dpdk-dev] [PATCH v7 10/32] eal/trace: implement debug dump function 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 Implement rte_trace_metadata_dump() and rte_trace_dump() functions. Former one used to dump the CTF metadata file and the latter one to dump all the registered events and its status. Signed-off-by: Jerin Jacob Signed-off-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace.c | 57 +++++++++++++++++ lib/librte_eal/common/eal_common_trace_ctf.c | 67 ++++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 2 + 3 files changed, 126 insertions(+) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index 43f51df62..bca1232f9 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -230,6 +230,63 @@ rte_trace_point_lookup(const char *name) return NULL; } +static void +trace_point_dump(FILE *f, struct trace_point *tp) +{ + rte_trace_point_t *handle = tp->handle; + + fprintf(f, "\tid %d, %s, size is %d, %s\n", + trace_id_get(handle), tp->name, + (uint16_t)(*handle & __RTE_TRACE_FIELD_SIZE_MASK), + rte_trace_point_is_enabled(handle) ? "enabled" : "disabled"); +} + +static void +trace_lcore_mem_dump(FILE *f) +{ + struct trace *trace = trace_obj_get(); + struct __rte_trace_header *header; + uint32_t count; + + if (trace->nb_trace_mem_list == 0) + return; + + rte_spinlock_lock(&trace->lock); + fprintf(f, "nb_trace_mem_list = %d\n", trace->nb_trace_mem_list); + fprintf(f, "\nTrace mem info\n--------------\n"); + for (count = 0; count < trace->nb_trace_mem_list; count++) { + header = trace->lcore_meta[count].mem; + fprintf(f, "\tid %d, mem=%p, area=%s, lcore_id=%d, name=%s\n", + count, header, + trace_area_to_string(trace->lcore_meta[count].area), + header->stream_header.lcore_id, + header->stream_header.thread_name); + } + rte_spinlock_unlock(&trace->lock); +} + +void +rte_trace_dump(FILE *f) +{ + struct trace_point_head *tp_list = trace_list_head_get(); + struct trace *trace = trace_obj_get(); + struct trace_point *tp; + + fprintf(f, "\nGlobal info\n-----------\n"); + fprintf(f, "status = %s\n", + rte_trace_is_enabled() ? "enabled" : "disabled"); + fprintf(f, "mode = %s\n", + trace_mode_to_string(rte_trace_mode_get())); + fprintf(f, "dir = %s\n", trace->dir); + fprintf(f, "buffer len = %d\n", trace->buff_len); + fprintf(f, "number of trace points = %d\n", trace->nb_trace_points); + + trace_lcore_mem_dump(f); + fprintf(f, "\nTrace point info\n----------------\n"); + STAILQ_FOREACH(tp, tp_list, next) + trace_point_dump(f, tp); +} + static inline size_t list_sz(uint32_t index) { diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index c4f00bf22..302e2bb74 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -419,3 +419,70 @@ trace_metadata_destroy(void) } } +static void +meta_fix_freq(struct trace *trace, char *meta) +{ + char *str; + int rc; + + str = RTE_PTR_ADD(meta, trace->ctf_meta_offset_freq); + rc = sprintf(str, "%20"PRIu64"", rte_get_timer_hz()); + str[rc] = ';'; +} + +static void +meta_fix_freq_offset(struct trace *trace, char *meta) +{ + uint64_t uptime_tickes_floor, uptime_ticks, freq, uptime_sec; + uint64_t offset, offset_s; + char *str; + int rc; + + uptime_ticks = trace->uptime_ticks & + ((1ULL << __RTE_TRACE_EVENT_HEADER_ID_SHIFT) - 1); + freq = rte_get_tsc_hz(); + uptime_tickes_floor = RTE_ALIGN_MUL_FLOOR(uptime_ticks, freq); + + uptime_sec = uptime_tickes_floor / freq; + offset_s = trace->epoch_sec - uptime_sec; + + offset = uptime_ticks - uptime_tickes_floor; + offset += trace->epoch_nsec * (freq / NSEC_PER_SEC); + + str = RTE_PTR_ADD(meta, trace->ctf_meta_offset_freq_off_s); + rc = sprintf(str, "%20"PRIu64"", offset_s); + str[rc] = ';'; + str = RTE_PTR_ADD(meta, trace->ctf_meta_offset_freq_off); + rc = sprintf(str, "%20"PRIu64"", offset); + str[rc] = ';'; +} + +static void +meta_fixup(struct trace *trace, char *meta) +{ + meta_fix_freq(trace, meta); + meta_fix_freq_offset(trace, meta); +} + +int +rte_trace_metadata_dump(FILE *f) +{ + struct trace *trace = trace_obj_get(); + char *ctf_meta = trace->ctf_meta; + int rc; + + if (!rte_trace_is_enabled()) + return 0; + + if (ctf_meta == NULL) + return -EINVAL; + + if (!__atomic_load_n(&trace->ctf_fixup_done, __ATOMIC_SEQ_CST) && + rte_get_timer_hz()) { + meta_fixup(trace, ctf_meta); + __atomic_store_n(&trace->ctf_fixup_done, 1, __ATOMIC_SEQ_CST); + } + + rc = fprintf(f, "%s", ctf_meta); + return rc < 0 ? rc : 0; +} diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 98e0f8413..7bda1704c 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -343,7 +343,9 @@ EXPERIMENTAL { per_lcore_trace_point_sz; rte_log_can_log; rte_thread_getname; + rte_trace_dump; rte_trace_is_enabled; + rte_trace_metadata_dump; rte_trace_mode_get; rte_trace_mode_set; rte_trace_pattern; -- 2.25.1