Skip to contentSkip to conversation

examples/ip_pipeline: CPU utilization measurement and display

PATCH Applied Fan Zhang 4 participants 5 messages Feb 22, 2016 – Mar 9, 2016

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH v2 1/1 examples/ip_pipeline: CPU utilization measurement and display

This patch adds CPU utilization measurement and idle cycle rate computation to packet framework. The measurement is done by measuring the cycles spent while a thread pulls zero packet from RX queue. These cycles are treated as idle cycles (or headroom). A CLI command is added to display idle cycle rate of specific thread. The CLI command format is shown as following:

t <thread_id> headroom

---
 examples/ip_pipeline/app.h       |   8 +++
 examples/ip_pipeline/init.c      |   8 ++-
 examples/ip_pipeline/thread.c    |  66 ++++++++++++++++++++++-
 examples/ip_pipeline/thread.h    |  14 +++++
 examples/ip_pipeline/thread_fe.c | 113 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/thread_fe.h |   6 +++
 6 files changed, 211 insertions(+), 4 deletions(-)
examples/ip_pipeline/app.h +8 -0
index 6510d6d..2c91256 100644
@@ -263,6 +263,10 @@ struct app_thread_data {
 
 	struct rte_ring *msgq_in;
 	struct rte_ring *msgq_out;
+
+	uint64_t headroom_time;
+	uint64_t headroom_cycles;
+	double headroom_ratio;
 };
 
 struct app_eal_params {
@@ -421,6 +425,10 @@ struct app_eal_params {
 #define APP_MAX_CMDS                             64
 #endif
 
+#ifndef APP_THREAD_HEADROOM_STATS_COLLECT
+#define APP_THREAD_HEADROOM_STATS_COLLECT        1
+#endif
+
 struct app_params {
 	/* Config */
 	char app_name[APP_APPNAME_SIZE];
examples/ip_pipeline/init.c +6 -2
index 186ca03..af33e8f 100644
@@ -1343,8 +1343,8 @@ app_init_pipelines(struct app_params *app)
 
 		data->ptype = ptype;
 
-		data->timer_period = (rte_get_tsc_hz() * params->timer_period)
-			/ 1000;
+		data->timer_period = (rte_get_tsc_hz() *
+			params->timer_period) / 100;
 	}
 }
 
@@ -1379,6 +1379,10 @@ app_init_threads(struct app_params *app)
 		t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000;
 		t->thread_req_deadline = time + t->timer_period;
 
+		t->headroom_cycles = 0;
+		t->headroom_time = rte_get_tsc_cycles();
+		t->headroom_ratio = 0.0;
+
 		t->msgq_in = app_thread_msgq_in_get(app,
 				params->socket_id,
 				params->core_id,
examples/ip_pipeline/thread.c +64 -2

108 lines not on this page · raw message

examples/ip_pipeline/thread.h +14 -0
index dc877c0..e52b22e 100644
@@ -40,6 +40,7 @@
 enum thread_msg_req_type {
 	THREAD_MSG_REQ_PIPELINE_ENABLE = 0,
 	THREAD_MSG_REQ_PIPELINE_DISABLE,
+	THREAD_MSG_REQ_HEADROOM_READ,
 	THREAD_MSG_REQS
 };
 
@@ -81,4 +82,17 @@ struct thread_pipeline_disable_msg_rsp {
 	int status;
 };
 
+/*
+ * THREAD HEADROOM
+ */
+struct thread_headroom_read_msg_req {
+	enum thread_msg_req_type type;
+};
+
+struct thread_headroom_read_msg_rsp {
+	int status;
+
+	double headroom_ratio;
+};
+
 #endif /* THREAD_H_ */
examples/ip_pipeline/thread_fe.c +113 -0

128 lines not on this page · raw message

examples/ip_pipeline/thread_fe.h +6 -0
index 52352c1..2fd4ee8 100644
@@ -92,4 +92,10 @@ app_pipeline_disable(struct app_params *app,
 		uint32_t hyper_th_id,
 		uint32_t pipeline_id);
 
+int
+app_thread_headroom(struct app_params *app,
+		uint32_t core_id,
+		uint32_t socket_id,
+		uint32_t hyper_th_id);
+
 #endif /* THREAD_FE_H_ */
Signature · 1 line
2.5.0
#1 lore raw

2016-02-22 14:07, Fan Zhang:

Quoted 11 lines

This patch adds CPU utilization measurement and idle cycle rate computation to packet framework. The measurement is done by measuring the cycles spent while a thread pulls zero packet from RX queue. These cycles are treated as idle cycles (or headroom). A CLI command is added to display idle cycle rate of specific thread. The CLI command format is shown as following:

t <thread_id> headroom

Applied, thanks

#2 lore raw

2016-03-07 12:31, Thomas Monjalon:

Quoted 8 lines

2016-02-22 14:07, Fan Zhang:

Quoted 7 lines

This patch adds CPU utilization measurement and idle cycle rate computation to packet framework. The measurement is done by measuring the cycles spent while a thread pulls zero packet from RX queue. These cycles are treated as idle cycles (or headroom). A CLI command is added to display idle cycle rate of specific thread. The CLI command format is shown as following:

Quoted 6 lines
Quoted 4 lines

t <thread_id> headroom

Applied, thanks

Question: Would you be helped by librte_jobstats?

#3 lore raw
Quoted 20 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, March 7, 2016 11:34 AM
To: Zhang, Roy Fan <[email protected]>
Cc: [email protected]; Wodkowski, PawelX <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] examples/ip_pipeline: CPU utilization measurement and display

2016-03-07 12:31, Thomas Monjalon:

Quoted 3 lines

2016-02-22 14:07, Fan Zhang:

Quoted 2 lines

This patch adds CPU utilization measurement and idle cycle rate computation to packet framework. The measurement is done by

measuring

Quoted 5 lines
Quoted 5 lines

the cycles spent while a thread pulls zero packet from RX queue. These cycles are treated as idle cycles (or headroom). A CLI command is added to display idle cycle rate of specific thread. The CLI command format is shown as following:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

t <thread_id> headroom

Applied, thanks

Question: Would you be helped by librte_jobstats?

All we needed for now is retrieving the current TSC value. We might consider using librte_jobstats for the next release.

Acked-by Cristian Dumitrescu on v2 1/1
#4 lore raw
In reply to Fan Zhang

Tested-ny: Qun Wan <[email protected]>
pipeline> t s1c1 headroom
57.085%

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Fan Zhang
Sent: Monday, February 22, 2016 10:07 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2] examples/ip_pipeline: CPU utilization measurement and display

This patch adds CPU utilization measurement and idle cycle rate computation to packet framework. The measurement is done by measuring the cycles spent while a thread pulls zero packet from RX queue. These cycles are treated as idle cycles (or headroom). A CLI command is added to display idle cycle rate of specific thread. The CLI command format is shown as following:

t <thread_id> headroom

---
 examples/ip_pipeline/app.h       |   8 +++
 examples/ip_pipeline/init.c      |   8 ++-
 examples/ip_pipeline/thread.c    |  66 ++++++++++++++++++++++-
 examples/ip_pipeline/thread.h    |  14 +++++
 examples/ip_pipeline/thread_fe.c | 113 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/thread_fe.h |   6 +++
 6 files changed, 211 insertions(+), 4 deletions(-)
examples/ip_pipeline/app.h +8 -0
@@ -263,6 +263,10 @@ struct app_thread_data {
 
 	struct rte_ring *msgq_in;
 	struct rte_ring *msgq_out;
+
+	uint64_t headroom_time;
+	uint64_t headroom_cycles;
+	double headroom_ratio;
 };
 
 struct app_eal_params {
@@ -421,6 +425,10 @@ struct app_eal_params {
 #define APP_MAX_CMDS                             64
 #endif
 
+#ifndef APP_THREAD_HEADROOM_STATS_COLLECT
+#define APP_THREAD_HEADROOM_STATS_COLLECT        1
+#endif
+
 struct app_params {
 	/* Config */
 	char app_name[APP_APPNAME_SIZE];
examples/ip_pipeline/init.c +6 -2
@@ -1343,8 +1343,8 @@ app_init_pipelines(struct app_params *app)
 
 		data->ptype = ptype;
 
-		data->timer_period = (rte_get_tsc_hz() * params->timer_period)
-			/ 1000;
+		data->timer_period = (rte_get_tsc_hz() *
+			params->timer_period) / 100;
 	}
 }
 
@@ -1379,6 +1379,10 @@ app_init_threads(struct app_params *app)
 		t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000;
 		t->thread_req_deadline = time + t->timer_period;
 
+		t->headroom_cycles = 0;
+		t->headroom_time = rte_get_tsc_cycles();
+		t->headroom_ratio = 0.0;
+
 		t->msgq_in = app_thread_msgq_in_get(app,
 				params->socket_id,
 				params->core_id,
examples/ip_pipeline/thread.c +62 -2

106 lines not on this page · raw message

examples/ip_pipeline/thread.h +14 -0
@@ -40,6 +40,7 @@
 enum thread_msg_req_type {
 	THREAD_MSG_REQ_PIPELINE_ENABLE = 0,
 	THREAD_MSG_REQ_PIPELINE_DISABLE,
+	THREAD_MSG_REQ_HEADROOM_READ,
 	THREAD_MSG_REQS
 };
 
@@ -81,4 +82,17 @@ struct thread_pipeline_disable_msg_rsp {
 	int status;
 };
 
+/*
+ * THREAD HEADROOM
+ */
+struct thread_headroom_read_msg_req {
+	enum thread_msg_req_type type;
+};
+
+struct thread_headroom_read_msg_rsp {
+	int status;
+
+	double headroom_ratio;
+};
+
 #endif /* THREAD_H_ */
examples/ip_pipeline/thread_fe.c +112 -0

127 lines not on this page · raw message

examples/ip_pipeline/thread_fe.h +6 -0
index 52352c1..2fd4ee8 100644
@@ -92,4 +92,10 @@ app_pipeline_disable(struct app_params *app,
 		uint32_t hyper_th_id,
 		uint32_t pipeline_id);
 
+int
+app_thread_headroom(struct app_params *app,
+		uint32_t core_id,
+		uint32_t socket_id,
+		uint32_t hyper_th_id);
+
 #endif /* THREAD_FE_H_ */

--
2.5.0