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 DA3E7A0562; Fri, 3 Apr 2020 17:40:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6524E1C1DF; Fri, 3 Apr 2020 17:37:50 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id B6A3C1C12B for ; Fri, 3 Apr 2020 17:37:48 +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 033FaIjl029207; Fri, 3 Apr 2020 08:37:48 -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=0vKVB4pYT1Se8DTY1dnMXEfxTXwf7MRxX+x/oXoNQuA=; b=bitTQ6E6KuJnvfaJuY6KwUibAQiBTiB8Li9bg+cbJMAengYvEn8x+IFU04EJoUjnn7Nf LFM8+wDAIlFVCQU0cOXum/UDyCS50u8D57YygkG+oR4qeUY2ZgK54vBRaJ5cD4+GLQZs 3H+7BJI2Y4yKXCJDyrCIMbRsRoB6rqfUYaoq4VpUYoWqZgvhWO3PdS8x+zZ9qt2HwZuV 51yl13dAt7qN3aOOlpnw/sy1bUBdO/fc+h388eQBiHqzb5uyx/2WqBMJLBBTORG8gc7m JPk9DEvYuMGYCzUPKDXBzhiWak/dVbdPWmPtW4kkD81cQ4eRO1n7642faVhUZP951moD 2A== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 304855y7ev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 03 Apr 2020 08:37:47 -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; Fri, 3 Apr 2020 08:37:46 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 3 Apr 2020 08:37:46 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id D70623F703F; Fri, 3 Apr 2020 08:37:43 -0700 (PDT) From: To: Jerin Jacob , Sunil Kumar Kori CC: , , , , Date: Fri, 3 Apr 2020 21:06:49 +0530 Message-ID: <20200403153709.3703448-14-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200403153709.3703448-1-jerinj@marvell.com> References: <20200329144342.1543749-1-jerinj@marvell.com> <20200403153709.3703448-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-03_11:2020-04-03, 2020-04-03 signatures=0 Subject: [dpdk-dev] [PATCH v4 13/33] eal/trace: implement registration payload 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 The trace function payloads such as rte_trace_ctf_* have dual functions. The first to emit the payload for the registration function and the second one to act as trace memory emitters. When it used as registration payload, it will do the following to fulfill the registration job. - Find out the size of the event - Generate metadata field string using __rte_trace_emit_ctf_field(). Signed-off-by: Jerin Jacob Signed-off-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace.c | 19 ++++++++++++ lib/librte_eal/include/rte_trace.h | 20 +++++++++++++ lib/librte_eal/include/rte_trace_register.h | 33 +++++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 2 ++ 4 files changed, 74 insertions(+) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index 2c2f6c440..6b1600758 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -487,6 +487,25 @@ trace_mem_per_thread_free(void) rte_spinlock_unlock(&trace->lock); } +void +__rte_trace_emit_ctf_field(size_t sz, const char *in, const char *datatype) +{ + char *field = RTE_PER_LCORE(ctf_field); + int count = RTE_PER_LCORE(ctf_count); + int rc; + + RTE_PER_LCORE(trace_point_sz) += sz; + rc = snprintf(RTE_PTR_ADD(field, count), + RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count), + "%s %s;", datatype, in); + if (rc <= 0) { + RTE_PER_LCORE(trace_point_sz) = 0; + trace_crit("CTF field is too long"); + return; + } + RTE_PER_LCORE(ctf_count) += rc; +} + int __rte_trace_point_register(rte_trace_t *handle, const char *name, uint32_t level, void (*register_fn)(void)) diff --git a/lib/librte_eal/include/rte_trace.h b/lib/librte_eal/include/rte_trace.h index 9e83f51e2..3884beb11 100644 --- a/lib/librte_eal/include/rte_trace.h +++ b/lib/librte_eal/include/rte_trace.h @@ -517,6 +517,8 @@ _tp _args \ /** @internal Macro to define maximum emit length of string datatype. */ #define __RTE_TRACE_EMIT_STRING_LEN_MAX 32 +/** @internal Macro to define event header size. */ +#define __RTE_TRACE_EVENT_HEADER_SZ sizeof(uint64_t) /** * @internal @warning @@ -550,6 +552,24 @@ void __rte_trace_mem_per_thread_alloc(void); __rte_experimental int __rte_trace_point_register(rte_trace_t *trace, const char *name, uint32_t level, void (*register_fn)(void)); +/** + * @internal @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Helper function to emit ctf field. + * + * @param sz + * The tracepoint size. + * @param field + * The name of the trace event. + * @param type + * The datatype of the trace event as string. + * @return + * - 0: Success. + * - <0: Failure. + */ +__rte_experimental +void __rte_trace_emit_ctf_field(size_t sz, const char *field, const char *type); #ifdef RTE_TRACE_POINT_REGISTER_SELECT #include diff --git a/lib/librte_eal/include/rte_trace_register.h b/lib/librte_eal/include/rte_trace_register.h index e9940b414..0d9d20266 100644 --- a/lib/librte_eal/include/rte_trace_register.h +++ b/lib/librte_eal/include/rte_trace_register.h @@ -10,6 +10,7 @@ #define _RTE_TRACE_REGISTER_H_ #include +#include RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); @@ -17,4 +18,36 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); __rte_trace_point_register(&__##trace, RTE_STR(name),\ RTE_LOG_ ## level, (void (*)(void)) trace) +#define __rte_trace_emit_header_generic(t)\ + RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ + +#define __rte_trace_emit_header_dp(t) __rte_trace_emit_header_generic(t) + +#define __rte_trace_emit_datatype(in, type)\ +do {\ + RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in)));\ + __rte_trace_emit_ctf_field(sizeof(type), RTE_STR(in), RTE_STR(type));\ +} while (0) + +#define rte_trace_ctf_u64(in) __rte_trace_emit_datatype(in, uint64_t) +#define rte_trace_ctf_i64(in) __rte_trace_emit_datatype(in, int64_t) +#define rte_trace_ctf_u32(in) __rte_trace_emit_datatype(in, uint32_t) +#define rte_trace_ctf_i32(in) __rte_trace_emit_datatype(in, int32_t) +#define rte_trace_ctf_u16(in) __rte_trace_emit_datatype(in, uint16_t) +#define rte_trace_ctf_i16(in) __rte_trace_emit_datatype(in, int16_t) +#define rte_trace_ctf_u8(in) __rte_trace_emit_datatype(in, uint8_t) +#define rte_trace_ctf_i8(in) __rte_trace_emit_datatype(in, int8_t) +#define rte_trace_ctf_int(in) __rte_trace_emit_datatype(in, int32_t) +#define rte_trace_ctf_long(in) __rte_trace_emit_datatype(in, long) +#define rte_trace_ctf_float(in) __rte_trace_emit_datatype(in, float) +#define rte_trace_ctf_double(in) __rte_trace_emit_datatype(in, double) +#define rte_trace_ctf_ptr(in) __rte_trace_emit_datatype(in, uintptr_t) + +#define rte_trace_ctf_string(in)\ +do {\ + RTE_SET_USED(in);\ + __rte_trace_emit_ctf_field(__RTE_TRACE_EMIT_STRING_LEN_MAX,\ + RTE_STR(in)"[32]", "string_bounded_t");\ +} while (0) + #endif /* _RTE_TRACE_REGISTER_H_ */ diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index f841cc7d6..36163287e 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -340,7 +340,9 @@ EXPERIMENTAL { rte_log_can_log; rte_thread_getname; __rte_trace_mem_per_thread_alloc; + __rte_trace_emit_ctf_field; __rte_trace_point_register; + per_lcore_trace_point_sz; per_lcore_trace_mem; rte_trace_global_is_enabled; rte_trace_global_is_disabled; -- 2.25.1