* [PATCH 1/2] trace: support expression for blob length
@ 2025-01-24 16:14 David Marchand
2025-01-24 16:14 ` [PATCH 2/2] dmadev: avoid copies in tracepoints David Marchand
0 siblings, 1 reply; 2+ messages in thread
From: David Marchand @ 2025-01-24 16:14 UTC (permalink / raw)
To: dev
Cc: Jerin Jacob, Sunil Kumar Kori, Tyler Retzlaff, Thomas Monjalon,
Ferruh Yigit, Andrew Rybchenko
Support any expression as a blob length by using an intermediate
variable in the trace point emitter itself.
This also avoids any side effect on the passed variable.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
lib/eal/include/rte_trace_point.h | 11 +++++----
lib/eal/include/rte_trace_point_register.h | 3 ++-
lib/ethdev/ethdev_trace.h | 27 ++++++----------------
3 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h
index b24db3b6da..62a972db92 100644
--- a/lib/eal/include/rte_trace_point.h
+++ b/lib/eal/include/rte_trace_point.h
@@ -392,13 +392,14 @@ do { \
#define rte_trace_point_emit_blob(in, len) \
do { \
+ uint8_t size = len; \
if (unlikely(in == NULL)) \
return; \
- if (len > RTE_TRACE_BLOB_LEN_MAX) \
- len = RTE_TRACE_BLOB_LEN_MAX; \
- __rte_trace_point_emit(len, uint8_t); \
- memcpy(mem, in, len); \
- memset(RTE_PTR_ADD(mem, len), 0, RTE_TRACE_BLOB_LEN_MAX - len); \
+ if (size > RTE_TRACE_BLOB_LEN_MAX) \
+ size = RTE_TRACE_BLOB_LEN_MAX; \
+ __rte_trace_point_emit(size, uint8_t); \
+ memcpy(mem, in, size); \
+ memset(RTE_PTR_ADD(mem, size), 0, RTE_TRACE_BLOB_LEN_MAX - size); \
mem = RTE_PTR_ADD(mem, RTE_TRACE_BLOB_LEN_MAX); \
} while (0)
diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h
index 748c931830..cb1015eb88 100644
--- a/lib/eal/include/rte_trace_point_register.h
+++ b/lib/eal/include/rte_trace_point_register.h
@@ -51,8 +51,9 @@ do { \
#define rte_trace_point_emit_blob(in, len) \
do { \
+ uint8_t size = len; \
RTE_SET_USED(in); \
- __rte_trace_point_emit(len, uint8_t); \
+ __rte_trace_point_emit(size, uint8_t); \
__rte_trace_point_emit_field(RTE_TRACE_BLOB_LEN_MAX, \
RTE_STR(in)"[" RTE_STR(RTE_TRACE_BLOB_LEN_MAX)"]", \
RTE_STR(uint8_t)); \
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index 5951ae2d99..c65b78590a 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -860,10 +860,8 @@ RTE_TRACE_POINT(
rte_ethdev_trace_mac_addr_add,
RTE_TRACE_POINT_ARGS(uint16_t port_id,
const struct rte_ether_addr *addr, uint32_t pool, int ret),
- uint8_t len = RTE_ETHER_ADDR_LEN;
-
rte_trace_point_emit_u16(port_id);
- rte_trace_point_emit_blob(addr->addr_bytes, len);
+ rte_trace_point_emit_blob(addr->addr_bytes, RTE_ETHER_ADDR_LEN);
rte_trace_point_emit_u32(pool);
rte_trace_point_emit_int(ret);
)
@@ -872,20 +870,16 @@ RTE_TRACE_POINT(
rte_ethdev_trace_mac_addr_remove,
RTE_TRACE_POINT_ARGS(uint16_t port_id,
const struct rte_ether_addr *addr),
- uint8_t len = RTE_ETHER_ADDR_LEN;
-
rte_trace_point_emit_u16(port_id);
- rte_trace_point_emit_blob(addr->addr_bytes, len);
+ rte_trace_point_emit_blob(addr->addr_bytes, RTE_ETHER_ADDR_LEN);
)
RTE_TRACE_POINT(
rte_ethdev_trace_default_mac_addr_set,
RTE_TRACE_POINT_ARGS(uint16_t port_id,
const struct rte_ether_addr *addr),
- uint8_t len = RTE_ETHER_ADDR_LEN;
-
rte_trace_point_emit_u16(port_id);
- rte_trace_point_emit_blob(addr->addr_bytes, len);
+ rte_trace_point_emit_blob(addr->addr_bytes, RTE_ETHER_ADDR_LEN);
)
RTE_TRACE_POINT(
@@ -1102,11 +1096,9 @@ RTE_TRACE_POINT(
RTE_TRACE_POINT_ARGS(uint16_t port_id,
const struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr,
int ret),
- uint8_t len = nb_mc_addr * RTE_ETHER_ADDR_LEN;
-
rte_trace_point_emit_u16(port_id);
rte_trace_point_emit_u32(nb_mc_addr);
- rte_trace_point_emit_blob(mc_addr_set, len);
+ rte_trace_point_emit_blob(mc_addr_set, nb_mc_addr * RTE_ETHER_ADDR_LEN);
rte_trace_point_emit_int(ret);
)
@@ -1214,13 +1206,10 @@ RTE_TRACE_POINT(
rte_ethdev_trace_get_dcb_info,
RTE_TRACE_POINT_ARGS(uint16_t port_id,
const struct rte_eth_dcb_info *dcb_info, int ret),
- uint8_t num_user_priorities = RTE_ETH_DCB_NUM_USER_PRIORITIES;
- uint8_t num_tcs = RTE_ETH_DCB_NUM_TCS;
-
rte_trace_point_emit_u16(port_id);
rte_trace_point_emit_u8(dcb_info->nb_tcs);
- rte_trace_point_emit_blob(dcb_info->prio_tc, num_user_priorities);
- rte_trace_point_emit_blob(dcb_info->tc_bws, num_tcs);
+ rte_trace_point_emit_blob(dcb_info->prio_tc, RTE_ETH_DCB_NUM_USER_PRIORITIES);
+ rte_trace_point_emit_blob(dcb_info->tc_bws, RTE_ETH_DCB_NUM_TCS);
rte_trace_point_emit_int(ret);
)
@@ -2126,10 +2115,8 @@ RTE_TRACE_POINT_FP(
rte_eth_trace_macaddr_get,
RTE_TRACE_POINT_ARGS(uint16_t port_id,
const struct rte_ether_addr *mac_addr),
- uint8_t len = RTE_ETHER_ADDR_LEN;
-
rte_trace_point_emit_u16(port_id);
- rte_trace_point_emit_blob(mac_addr->addr_bytes, len);
+ rte_trace_point_emit_blob(mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN);
)
/* Called in loop in examples/ip_pipeline */
--
2.47.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] dmadev: avoid copies in tracepoints
2025-01-24 16:14 [PATCH 1/2] trace: support expression for blob length David Marchand
@ 2025-01-24 16:14 ` David Marchand
0 siblings, 0 replies; 2+ messages in thread
From: David Marchand @ 2025-01-24 16:14 UTC (permalink / raw)
To: dev; +Cc: Chengwen Feng, Kevin Laatz, Bruce Richardson
No need to copy values in intermediate variables.
Just use the right trace point emitters.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
lib/dmadev/rte_dmadev_trace.h | 20 ++++++--------------
lib/dmadev/rte_dmadev_trace_fp.h | 12 ++++--------
2 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/lib/dmadev/rte_dmadev_trace.h b/lib/dmadev/rte_dmadev_trace.h
index be089c065c..ddf60b9649 100644
--- a/lib/dmadev/rte_dmadev_trace.h
+++ b/lib/dmadev/rte_dmadev_trace.h
@@ -46,11 +46,10 @@ RTE_TRACE_POINT(
const struct rte_dma_conf __dev_conf = {0};
dev_conf = &__dev_conf;
#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
- int enable_silent = (int)dev_conf->enable_silent;
rte_trace_point_emit_i16(dev_id);
rte_trace_point_emit_u16(dev_conf->nb_vchans);
rte_trace_point_emit_u16(dev_conf->priority);
- rte_trace_point_emit_int(enable_silent);
+ rte_trace_point_emit_u8(dev_conf->enable_silent);
rte_trace_point_emit_int(ret);
)
@@ -83,21 +82,14 @@ RTE_TRACE_POINT(
const struct rte_dma_vchan_conf __conf = {0};
conf = &__conf;
#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
- int src_port_type = conf->src_port.port_type;
- int dst_port_type = conf->dst_port.port_type;
- int direction = conf->direction;
- uint64_t src_pcie_cfg;
- uint64_t dst_pcie_cfg;
rte_trace_point_emit_i16(dev_id);
rte_trace_point_emit_u16(vchan);
- rte_trace_point_emit_int(direction);
+ rte_trace_point_emit_int(conf->direction);
rte_trace_point_emit_u16(conf->nb_desc);
- rte_trace_point_emit_int(src_port_type);
- memcpy(&src_pcie_cfg, &conf->src_port.pcie, sizeof(uint64_t));
- rte_trace_point_emit_u64(src_pcie_cfg);
- memcpy(&dst_pcie_cfg, &conf->dst_port.pcie, sizeof(uint64_t));
- rte_trace_point_emit_int(dst_port_type);
- rte_trace_point_emit_u64(dst_pcie_cfg);
+ rte_trace_point_emit_int(conf->src_port.port_type);
+ rte_trace_point_emit_blob(&conf->src_port.pcie, sizeof(uint64_t));
+ rte_trace_point_emit_int(conf->dst_port.port_type);
+ rte_trace_point_emit_blob(&conf->dst_port.pcie, sizeof(uint64_t));
rte_trace_point_emit_ptr(conf->auto_free.m2d.pool);
rte_trace_point_emit_int(ret);
)
diff --git a/lib/dmadev/rte_dmadev_trace_fp.h b/lib/dmadev/rte_dmadev_trace_fp.h
index f5b96838bc..4950f58cd2 100644
--- a/lib/dmadev/rte_dmadev_trace_fp.h
+++ b/lib/dmadev/rte_dmadev_trace_fp.h
@@ -37,10 +37,9 @@ RTE_TRACE_POINT_FP(
enum rte_dma_vchan_status __status = 0;
status = &__status;
#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
- int vchan_status = *status;
rte_trace_point_emit_i16(dev_id);
rte_trace_point_emit_u16(vchan);
- rte_trace_point_emit_int(vchan_status);
+ rte_trace_point_emit_int(*status);
rte_trace_point_emit_int(ret);
)
@@ -107,13 +106,11 @@ RTE_TRACE_POINT_FP(
last_idx = &__last_idx;
has_error = &__has_error;
#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
- int has_error_val = *has_error;
- int last_idx_val = *last_idx;
rte_trace_point_emit_i16(dev_id);
rte_trace_point_emit_u16(vchan);
rte_trace_point_emit_u16(nb_cpls);
- rte_trace_point_emit_int(last_idx_val);
- rte_trace_point_emit_int(has_error_val);
+ rte_trace_point_emit_u16(*last_idx);
+ rte_trace_point_emit_u8(*has_error);
rte_trace_point_emit_u16(ret);
)
@@ -126,11 +123,10 @@ RTE_TRACE_POINT_FP(
uint16_t __last_idx = 0;
last_idx = &__last_idx;
#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
- int last_idx_val = *last_idx;
rte_trace_point_emit_i16(dev_id);
rte_trace_point_emit_u16(vchan);
rte_trace_point_emit_u16(nb_cpls);
- rte_trace_point_emit_int(last_idx_val);
+ rte_trace_point_emit_u16(*last_idx);
rte_trace_point_emit_ptr(status);
rte_trace_point_emit_u16(ret);
)
--
2.47.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-24 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-24 16:14 [PATCH 1/2] trace: support expression for blob length David Marchand
2025-01-24 16:14 ` [PATCH 2/2] dmadev: avoid copies in tracepoints David Marchand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).