Skip to content

Commit 0508c8b

Browse files
committed
The CPU usage of packet_dispatcher() is modified to usr.
1 parent 0b4a084 commit 0508c8b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/ff_dpdk_if.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static int numa_on;
7777

7878
static unsigned idle_sleep;
7979
static unsigned pkt_tx_delay;
80+
static uint64_t usr_cb_tsc;
8081

8182
static struct rte_timer freebsd_clock;
8283

@@ -1286,7 +1287,9 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
12861287
}
12871288

12881289
if (!pkts_from_ring && packet_dispatcher) {
1290+
uint64_t cur_tsc = rte_rdtsc();
12891291
int ret = (*packet_dispatcher)(data, &len, queue_id, nb_queues);
1292+
usr_cb_tsc += rte_rdtsc() - cur_tsc;
12901293
if (ret == FF_DISPATCH_RESPONSE) {
12911294
rte_pktmbuf_pkt_len(rtem) = rte_pktmbuf_data_len(rtem) = len;
12921295

@@ -1844,6 +1847,7 @@ main_loop(void *arg)
18441847
idle = 1;
18451848
sys_tsc = 0;
18461849
usr_tsc = 0;
1850+
usr_cb_tsc = 0;
18471851

18481852
/*
18491853
* TX burst queue drain
@@ -1925,12 +1929,13 @@ main_loop(void *arg)
19251929
end_tsc = idle_sleep_tsc;
19261930
}
19271931

1932+
usr_tsc = usr_cb_tsc;
19281933
if (usch_tsc == cur_tsc) {
1929-
usr_tsc = idle_sleep_tsc - div_tsc;
1934+
usr_tsc += idle_sleep_tsc - div_tsc;
19301935
}
19311936

19321937
if (!idle) {
1933-
sys_tsc = div_tsc - cur_tsc;
1938+
sys_tsc = div_tsc - cur_tsc - usr_cb_tsc;
19341939
ff_top_status.sys_tsc += sys_tsc;
19351940
}
19361941

0 commit comments

Comments
 (0)