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 52D60A0561; Sun, 19 Apr 2020 12:06:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97FC81D16B; Sun, 19 Apr 2020 12:02:51 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 4B3A71D5D0 for ; Sun, 19 Apr 2020 12:02: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 03JA18b9020141; Sun, 19 Apr 2020 03:02:27 -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=3IEdVwYUBZpwv2ofS/2/iem5fHi2Ge7IzxbdcNR4x5o=; b=Cdrd+HN1/iaBCtePQZF4RhjvZ9M/jGbwFl28Q0pjFnFP06LnBqu0BJNBobLeDZqM0xC3 eHena8dV8lUBtNYpNkMctWUsgpE5ZtXOavPqltszCySfd0P6tWhmkSiBmF1MCRux0PwT pplR3xc7HDECVUohVASefDEQUw+V6aFRmb0xwOzrYfhT4D3HJWodHc8qJzEDkjgtBTp0 TwZfN0TCBVnZUwEhwXHAvlKf4MWy1OQelQnXqghTFwy9RyxNaoujjBj21zxrF8I4Aixs 8etVNdWXIsEnrtXceDcVx9SfRpvrNJ7kNcKD36W4SeLyYuWPTUCJvoxklOON/WefEIAi pg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 30g12njxb8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 19 Apr 2020 03:02:27 -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; Sun, 19 Apr 2020 03:02:26 -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; Sun, 19 Apr 2020 03:02:26 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 196013F703F; Sun, 19 Apr 2020 03:02:23 -0700 (PDT) From: To: Jerin Jacob , Sunil Kumar Kori CC: , , , , Date: Sun, 19 Apr 2020 15:31:13 +0530 Message-ID: <20200419100133.3232316-14-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200419100133.3232316-1-jerinj@marvell.com> References: <20200413150116.734047-1-jerinj@marvell.com> <20200419100133.3232316-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-19_02:2020-04-17, 2020-04-19 signatures=0 Subject: [dpdk-dev] [PATCH v6 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_point_emit_* 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_point_emit_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_point.h | 19 +++++++++++++++++++ .../include/rte_trace_point_register.h | 19 +++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 58 insertions(+) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index e8e1bc693..d55a23df1 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -385,6 +385,25 @@ trace_mem_per_thread_free(void) rte_spinlock_unlock(&trace->lock); } +void +__rte_trace_point_emit_field(size_t sz, const char *in, const char *datatype) +{ + char *field = RTE_PER_LCORE(ctf_field); + int count = RTE_PER_LCORE(ctf_count); + size_t size; + int rc; + + size = RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count); + RTE_PER_LCORE(trace_point_sz) += sz; + rc = snprintf(RTE_PTR_ADD(field, count), size, "%s %s;", datatype, in); + if (rc <= 0 || (size_t)rc >= size) { + 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_point_t *handle, const char *name, void (*register_fn)(void)) diff --git a/lib/librte_eal/include/rte_trace_point.h b/lib/librte_eal/include/rte_trace_point.h index 8e37f971e..f4e6d7e42 100644 --- a/lib/librte_eal/include/rte_trace_point.h +++ b/lib/librte_eal/include/rte_trace_point.h @@ -236,6 +236,25 @@ __rte_trace_point_fp_is_enabled(void) __rte_experimental void __rte_trace_mem_per_thread_alloc(void); +/** + * @internal + * + * Helper function to emit 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_point_emit_field(size_t sz, const char *field, + const char *type); + /** * @internal * diff --git a/lib/librte_eal/include/rte_trace_point_register.h b/lib/librte_eal/include/rte_trace_point_register.h index b21302c3d..3f61f8346 100644 --- a/lib/librte_eal/include/rte_trace_point_register.h +++ b/lib/librte_eal/include/rte_trace_point_register.h @@ -17,4 +17,23 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); __rte_trace_point_register(&__##trace, RTE_STR(name),\ (void (*)(void)) trace) +#define __rte_trace_point_emit_header_generic(t)\ + RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ + +#define __rte_trace_point_emit_header_fp(t) \ + __rte_trace_point_emit_header_generic(t) + +#define __rte_trace_point_emit(in, type)\ +do {\ + RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in)));\ + __rte_trace_point_emit_field(sizeof(type), RTE_STR(in), RTE_STR(type));\ +} while (0) + +#define rte_trace_point_emit_string(in)\ +do {\ + RTE_SET_USED(in);\ + __rte_trace_point_emit_field(__RTE_TRACE_EMIT_STRING_LEN_MAX,\ + RTE_STR(in)"[32]", "string_bounded_t");\ +} while (0) + #endif /* _RTE_TRACE_POINT_REGISTER_H_ */ diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index b4b3a92e5..8b51c8a5b 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -338,6 +338,7 @@ EXPERIMENTAL { # added in 20.05 __rte_trace_mem_per_thread_alloc; + __rte_trace_point_emit_field; __rte_trace_point_register; per_lcore_trace_mem; per_lcore_trace_point_sz; -- 2.25.1