summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author童宗振 <[email protected]>2024-06-20 06:47:05 +0000
committer童宗振 <[email protected]>2024-06-20 06:47:05 +0000
commita0b9e2713d014ae5293f5fb207dddbd3a6da47d9 (patch)
tree430df3d07f90ce10ba1189caa0e8498e78fd9ded
parentb4c19cdd847fce4cbb32c6981fbaf9d3a3d30b94 (diff)
Data path perf
-rw-r--r--infra/include/dp_trace.h2
-rw-r--r--infra/src/dp_trace.c49
-rw-r--r--service/src/node_eth_ingress.c2
-rw-r--r--service/src/node_shmdev.c17
4 files changed, 29 insertions, 41 deletions
diff --git a/infra/include/dp_trace.h b/infra/include/dp_trace.h
index a8f7c7c..820e966 100644
--- a/infra/include/dp_trace.h
+++ b/infra/include/dp_trace.h
@@ -63,8 +63,8 @@ struct dp_trace_resp
struct dp_trace_job_ctx
{
- struct dp_trace_job_desc desc;
volatile uint8_t used;
+ struct dp_trace_job_desc desc;
struct bpf_program fp;
job_bitmap_t job_id;
RTE_MARKER cacheline1 __rte_cache_min_aligned;
diff --git a/infra/src/dp_trace.c b/infra/src/dp_trace.c
index e28dd6d..d09214f 100644
--- a/infra/src/dp_trace.c
+++ b/infra/src/dp_trace.c
@@ -251,9 +251,11 @@ uint16_t dp_trace_filter_exec_jobs_get(struct dp_trace_process * trace, struct r
job_bitmap_t match_jobs = 0;
struct dp_trace_job_ctx * ctx = NULL;
bool target_packet = false;
+
+ struct dp_trace_job_ctx * global_job_ctx = (struct dp_trace_job_ctx *)&instance->job_ctx;
for (unsigned int i = 0; i < DP_TRACE_JOB_NUM_MAX; i++)
{
- ctx = &instance->job_ctx[i];
+ ctx = &global_job_ctx[i];
if (ctx->used == 0)
{
continue;
@@ -282,7 +284,8 @@ uint16_t dp_trace_filter_exec_jobs_get(struct dp_trace_process * trace, struct r
continue;
}
- if ((pcap_offline_filter(&ctx->fp, &header, pkt) != 0))
+ int ret = pcap_offline_filter(&ctx->fp, &header, pkt);
+ if (ret != 0)
{
// When the maximum number of data packet records is reached, the tag will no longer be added to the
// data packet. unlimit: ctx->desc.pkt_cnt_max == 0
@@ -309,7 +312,7 @@ uint16_t dp_trace_filter_exec_jobs_get(struct dp_trace_process * trace, struct r
}
}
- if (unlikely(target_packet == false))
+ if (likely(target_packet == false))
{
statistics->filter_exec_miss++;
}
@@ -448,34 +451,36 @@ int dp_trace_record_emit_fmt(struct dp_trace_process * trace, struct rte_mbuf *
void dp_trace_record_write(struct dp_trace_process * trace, struct rte_mbuf * mbuf, unsigned int lcore_id)
{
struct mrb_metadata * mrb_meta = rte_mbuf_to_priv(mbuf);
- struct dp_trace_buffer * dp_trace_buffer = mrb_meta->dp_trace_buffer;
+ if (likely((mrb_meta->measurement_type & (DP_TRACE_MEASUREMENT_TYPE_TRACE | DP_TRACE_MEASUREMENT_TYPE_TELEMETRY)) ==
+ 0))
+ {
+ return;
+ }
if (rte_mbuf_refcnt_read(mbuf) != 1)
{
return;
}
- if (dp_trace_buffer != NULL)
- {
- rte_mbuf_refcnt_update(mbuf, 1);
- uint16_t ring_id = mbuf->hash.usr % trace->nr_ring;
- int ret = rte_ring_enqueue(trace->ring[ring_id], (void *)mbuf);
+ assert(lcore_id < RTE_MAX_LCORE);
+ struct dp_trace_stat * statistics = &trace->statistics[lcore_id];
- assert(lcore_id < RTE_MAX_LCORE);
- struct dp_trace_stat * statistics = &trace->statistics[lcore_id];
+ rte_mbuf_refcnt_update(mbuf, 1);
+ uint16_t ring_id = mbuf->hash.usr % trace->nr_ring;
+ int ret = rte_ring_enqueue(trace->ring[ring_id], (void *)mbuf);
- if (unlikely(ret != 0))
- {
- statistics->ring_enqueue_failed++;
- // import: Recycle trace buffer
+ if (unlikely(ret != 0))
+ {
+ statistics->ring_enqueue_failed++;
+ // import: Recycle trace buffer
+ struct dp_trace_buffer * dp_trace_buffer = mrb_meta->dp_trace_buffer;
- rte_mempool_put(trace->inst->pool, (void *)dp_trace_buffer);
- rte_mbuf_refcnt_update(mbuf, -1);
- }
- else
- {
- statistics->ring_enqueue_success++;
- }
+ rte_mempool_put(trace->inst->pool, (void *)dp_trace_buffer);
+ rte_mbuf_refcnt_update(mbuf, -1);
+ }
+ else
+ {
+ statistics->ring_enqueue_success++;
}
}
diff --git a/service/src/node_eth_ingress.c b/service/src/node_eth_ingress.c
index 77c8c06..44f6133 100644
--- a/service/src/node_eth_ingress.c
+++ b/service/src/node_eth_ingress.c
@@ -533,7 +533,7 @@ static __rte_always_inline uint16_t eth_ingress_node_process(struct rte_graph *
}
node_enqueue:
-#if 1
+#if 0
/* Check if tracing is enabled for the current Mbuf */
if (unlikely(dp_trace_record_can_emit(mbuf, DP_TRACE_MEASUREMENT_TYPE_TRACE)))
{
diff --git a/service/src/node_shmdev.c b/service/src/node_shmdev.c
index d840866..f838a78 100644
--- a/service/src/node_shmdev.c
+++ b/service/src/node_shmdev.c
@@ -42,23 +42,6 @@ enum packet_direction
PACKET_DIRECTION_RX
};
-/* Generate and store the trace information */
-static __rte_always_inline void gen_store_trace_info(struct rte_node * node, struct rte_mbuf * mbuf,
- struct vdev * shm_dev_desc, enum packet_direction direction)
-{
- char str_record[MR_STRING_MAX];
- int len = snprintf(str_record, sizeof(str_record), "port:%u,%s", shm_dev_desc->port_id, shm_dev_desc->symbol);
-
- if (direction == PACKET_DIRECTION_RX)
- {
- len += snprintf(str_record + len, sizeof(str_record) - len, ",next:%s", node->nodes[0]->name);
- }
-
- /* Emit the trace record */
- struct dp_trace_record_meta meta = {.appsym = MR_TRACE_APPSYM, .module = node->name};
- dp_trace_record_emit_str(sc_main_get()->trace, mbuf, rte_lcore_id(), &meta, str_record);
-}
-
uint16_t shmdev_rx_node_process(struct rte_graph * graph, struct rte_node * node, void ** objs, uint16_t cnt)
{
struct dev_node_ctx * ctx = (struct dev_node_ctx *)node->ctx;