Skip to contentSkip to conversation

jobstats: added function abort for job

PATCH Superseded Marcin Kerlin 5 participants 8 messages Jan 26, 2016 – Feb 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jobstats: added function abort for job

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occure, condition is defined by the application for example when receiving n>0 packets.

---
 lib/librte_jobstats/rte_jobstats.c           | 22 ++++++++++++++++++++++
 lib/librte_jobstats/rte_jobstats.h           | 17 +++++++++++++++++
 lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
 3 files changed, 46 insertions(+)
lib/librte_jobstats/rte_jobstats.c +22 -0
index 2eaac0c..b603125 100644
@@ -170,6 +170,26 @@ rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job)
 }
 
 int
+rte_jobstats_abort(struct rte_jobstats *job)
+{
+	struct rte_jobstats_context *ctx;
+	uint64_t now, exec_time;
+
+	/* Some sanity check. */
+	if (unlikely(job == NULL || job->context == NULL))
+		return -EINVAL;
+
+	ctx = job->context;
+	now = get_time();
+	exec_time = now - ctx->state_time;
+	ADD_TIME_MIN_MAX(ctx, management, exec_time);
+	ctx->state_time = now;
+	job->context = NULL;
+
+	return 0;
+}
+
+int
 rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value)
 {
 	struct rte_jobstats_context *ctx;
@@ -191,6 +211,7 @@ rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value)
 	 * executed. */
 	now = get_time();
 	exec_time = now - ctx->state_time;
+	job->last_job_time = exec_time;
 	ADD_TIME_MIN_MAX(job, exec, exec_time);
 	ADD_TIME_MIN_MAX(ctx, exec, exec_time);
 
@@ -269,5 +290,6 @@ void
 rte_jobstats_reset(struct rte_jobstats *job)
 {
 	RESET_TIME_MIN_MAX(job, exec);
+	job->last_job_time = 0;
 	job->exec_cnt = 0;
 }
lib/librte_jobstats/rte_jobstats.h +17 -0
index de6a89a..9995319 100644
@@ -90,6 +90,9 @@ struct rte_jobstats {
 	uint64_t exec_cnt;
 	/**< Execute count. */
 
+	uint64_t last_job_time;
+	/**< Last job time */
+
 	char name[RTE_JOBSTATS_NAMESIZE];
 	/**< Name of this job */
 
@@ -237,6 +240,20 @@ int
 rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);
 
 /**
+ * Mark that *job* finished its execution, but time of this work will be skipped
+ * and added to management time.
+ *
+ * @param job
+ *  Job object.
+ *
+ * @return
+ *  0 on success
+ *  -EINVAL if job is NULL or job was not started (it have no context).
+ */
+int
+rte_jobstats_abort(struct rte_jobstats *job);
+
+/**
  * Mark that *job* finished its execution. Context in which it was executing
  * will receive stat update. After this function call *job* object is ready to
  * be executed in other context.
lib/librte_jobstats/rte_jobstats_version.map +7 -0
index cb01bfd..0ec0650 100644
@@ -17,3 +17,10 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_2.3 {
+	global:
+
+	rte_jobstats_abort;
+
+} DPDK_2.0;
\ No newline at end of file

-- 1
1.9.1

#1 lore raw
Quoted 12 lines · Marcin Kerlin

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occure, condition is defined by the application for example when receiving n>0 packets.

---
  lib/librte_jobstats/rte_jobstats.c           | 22 ++++++++++++++++++++++
  lib/librte_jobstats/rte_jobstats.h           | 17 +++++++++++++++++
  lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
  3 files changed, 46 insertions(+)

[...]

Quoted 5 lines
lib/librte_jobstats/rte_jobstats.h +0 -0
index de6a89a..9995319 100644

lib/librte_jobstats/rte_jobstats.h struct rte_jobstats { · line 98

Quoted 9 lines
lib/librte_jobstats/rte_jobstats.h +3 -0
@@ -90,6 +90,9 @@ struct rte_jobstats {
  	uint64_t exec_cnt;
  	/**< Execute count. */
 
+	uint64_t last_job_time;
+	/**< Last job time */
+
  	char name[RTE_JOBSTATS_NAMESIZE];
  	/**< Name of this job */
 

AFAICS this is an ABI break and as such, needs to be preannounced, see http://dpdk.org/doc/guides/contributing/versioning.html
For 2.3 it'd need to be a CONFIG_RTE_NEXT_ABI feature.

- Panu -

#2 lore raw
Quoted 43 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Panu Matilainen
Sent: Wednesday, January 27, 2016 2:38 PM
To: Kerlin, MarcinX <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH V1 1/1] jobstats: added function abort for job

Quoted 2 lines · Marcin Kerlin

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution

time.

Quoted 1 line

This function should be used instead of rte_jobstats_finish if condition

occure,

Quoted 1 line

condition is defined by the application for example when receiving n>0

packets.

Quoted 8 lines
---
  lib/librte_jobstats/rte_jobstats.c           | 22 ++++++++++++++++++++++
  lib/librte_jobstats/rte_jobstats.h           | 17 +++++++++++++++++
  lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
  3 files changed, 46 insertions(+)

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/lib/librte_jobstats/rte_jobstats.h

lib/librte_jobstats/rte_jobstats.h struct rte_jobstats { · line 98

Quoted 13 lines

index de6a89a..9995319 100644

lib/librte_jobstats/rte_jobstats.h +3 -0
@@ -90,6 +90,9 @@ struct rte_jobstats {
  	uint64_t exec_cnt;
  	/**< Execute count. */
 
+	uint64_t last_job_time;
+	/**< Last job time */
+
  	char name[RTE_JOBSTATS_NAMESIZE];
  	/**< Name of this job */
 

AFAICS this is an ABI break and as such, needs to be preannounced, see
http://dpdk.org/doc/guides/contributing/versioning.html
For 2.3 it'd need to be a CONFIG_RTE_NEXT_ABI feature.

Quoted 1 line

- Panu -

Hi Panu,
Thanks for Your notice. This last_job_time field is actually not necessary here and will be removed from this structure.

Best regards
Michal

#3 lore raw
Quoted 43 lines · MichalX K
Quoted 43 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Panu Matilainen
Sent: Wednesday, January 27, 2016 2:38 PM
To: Kerlin, MarcinX <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH V1 1/1] jobstats: added function abort for job

Quoted 2 lines · Marcin Kerlin

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution

time.

Quoted 1 line

This function should be used instead of rte_jobstats_finish if condition

occure,

Quoted 1 line

condition is defined by the application for example when receiving n>0

packets.

Quoted 8 lines
---
   lib/librte_jobstats/rte_jobstats.c           | 22 ++++++++++++++++++++++
   lib/librte_jobstats/rte_jobstats.h           | 17 +++++++++++++++++
   lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
   3 files changed, 46 insertions(+)

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/lib/librte_jobstats/rte_jobstats.h

lib/librte_jobstats/rte_jobstats.h struct rte_jobstats { · line 98

Quoted 13 lines

index de6a89a..9995319 100644

lib/librte_jobstats/rte_jobstats.h +3 -0
@@ -90,6 +90,9 @@ struct rte_jobstats {
   	uint64_t exec_cnt;
   	/**< Execute count. */
 
+	uint64_t last_job_time;
+	/**< Last job time */
+
   	char name[RTE_JOBSTATS_NAMESIZE];
   	/**< Name of this job */
 

AFAICS this is an ABI break and as such, needs to be preannounced, see
http://dpdk.org/doc/guides/contributing/versioning.html
For 2.3 it'd need to be a CONFIG_RTE_NEXT_ABI feature.

Quoted 5 lines
Quoted 1 line

- Panu -

Hi Panu,
Thanks for Your notice. This last_job_time field is actually not necessary here and will be removed from this structure.

Right, makes sense. You can always add it later on when there's a more pressing need to break the ABI.

- Panu -

#4 lore raw

PATCH v2 1/1 jobstats: added function abort for job

In reply to Marcin Kerlin

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occurs, condition is defined by the application for example when receiving n>0 packets.

v2:
* removed redundant field

---
 lib/librte_jobstats/rte_jobstats.c           | 20 ++++++++++++++++++++
 lib/librte_jobstats/rte_jobstats.h           | 14 ++++++++++++++
 lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
 3 files changed, 41 insertions(+)
lib/librte_jobstats/rte_jobstats.c +20 -0
index 2eaac0c..2b42050 100644
@@ -170,6 +170,26 @@ rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job)
 }
 
 int
+rte_jobstats_abort(struct rte_jobstats *job)
+{
+	struct rte_jobstats_context *ctx;
+	uint64_t now, exec_time;
+
+	/* Some sanity check. */
+	if (unlikely(job == NULL || job->context == NULL))
+		return -EINVAL;
+
+	ctx = job->context;
+	now = get_time();
+	exec_time = now - ctx->state_time;
+	ADD_TIME_MIN_MAX(ctx, management, exec_time);
+	ctx->state_time = now;
+	job->context = NULL;
+
+	return 0;
+}
+
+int
 rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value)
 {
 	struct rte_jobstats_context *ctx;
lib/librte_jobstats/rte_jobstats.h +14 -0
index de6a89a..c2b285f 100644
@@ -237,6 +237,20 @@ int
 rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);
 
 /**
+ * Mark that *job* finished its execution, but time of this work will be skipped
+ * and added to management time.
+ *
+ * @param job
+ *  Job object.
+ *
+ * @return
+ *  0 on success
+ *  -EINVAL if job is NULL or job was not started (it have no context).
+ */
+int
+rte_jobstats_abort(struct rte_jobstats *job);
+
+/**
  * Mark that *job* finished its execution. Context in which it was executing
  * will receive stat update. After this function call *job* object is ready to
  * be executed in other context.
lib/librte_jobstats/rte_jobstats_version.map +7 -0
index cb01bfd..e3b21ca 100644
@@ -17,3 +17,10 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_2.3 {
+	global:
+
+	rte_jobstats_abort;
+
+} DPDK_2.0;
Signature · 1 line
1.9.1
#5 lore raw

PATCH v3 1/1 jobstats: added function abort for job

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occurs, condition is defined by the application for example when receiving n>0 packets. Example of usage is added to the example l2fwd-jobstats. At maximum load do-while loop inside Idle job will be execute once because one or more jobs waiting to be executed, so this time should not be include as the execution time by calling rte_jobstats_abort().

v2:
* removed redundant field
v3:
* added an example of using

---
 examples/l2fwd-jobstats/main.c               |  9 ++++++++-
 lib/librte_jobstats/rte_jobstats.c           | 20 ++++++++++++++++++++
 lib/librte_jobstats/rte_jobstats.h           | 14 ++++++++++++++
 lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
 4 files changed, 49 insertions(+), 1 deletion(-)
examples/l2fwd-jobstats/main.c +8 -1
index 7b59f4e..bd64e74 100644
@@ -577,10 +577,13 @@ l2fwd_main_loop(void)
 			 */
 			rte_jobstats_start(&qconf->jobs_context, &qconf->idle_job);
 
+			uint64_t repeats = 0;
+
 			do {
 				uint8_t i;
 				uint64_t now = rte_get_timer_cycles();
 
+				repeats++;
 				need_manage = qconf->flush_timer.expire < now;
 				/* Check if we was esked to give a stats. */
 				stats_read_pending =
@@ -591,7 +594,11 @@ l2fwd_main_loop(void)
 					need_manage = qconf->rx_timers[i].expire < now;
 
 			} while (!need_manage);
-			rte_jobstats_finish(&qconf->idle_job, qconf->idle_job.target);
+
+			if (likely(repeats != 1))
+				rte_jobstats_finish(&qconf->idle_job, qconf->idle_job.target);
+			else
+				rte_jobstats_abort(&qconf->idle_job);
 
 			rte_timer_manage();
 			rte_jobstats_context_finish(&qconf->jobs_context);
lib/librte_jobstats/rte_jobstats.c +20 -0
index 2eaac0c..2b42050 100644
@@ -170,6 +170,26 @@ rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job)
 }
 
 int
+rte_jobstats_abort(struct rte_jobstats *job)
+{
+	struct rte_jobstats_context *ctx;
+	uint64_t now, exec_time;
+
+	/* Some sanity check. */
+	if (unlikely(job == NULL || job->context == NULL))
+		return -EINVAL;
+
+	ctx = job->context;
+	now = get_time();
+	exec_time = now - ctx->state_time;
+	ADD_TIME_MIN_MAX(ctx, management, exec_time);
+	ctx->state_time = now;
+	job->context = NULL;
+
+	return 0;
+}
+
+int
 rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value)
 {
 	struct rte_jobstats_context *ctx;
lib/librte_jobstats/rte_jobstats.h +14 -0
index de6a89a..c2b285f 100644
@@ -237,6 +237,20 @@ int
 rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);
 
 /**
+ * Mark that *job* finished its execution, but time of this work will be skipped
+ * and added to management time.
+ *
+ * @param job
+ *  Job object.
+ *
+ * @return
+ *  0 on success
+ *  -EINVAL if job is NULL or job was not started (it have no context).
+ */
+int
+rte_jobstats_abort(struct rte_jobstats *job);
+
+/**
  * Mark that *job* finished its execution. Context in which it was executing
  * will receive stat update. After this function call *job* object is ready to
  * be executed in other context.
lib/librte_jobstats/rte_jobstats_version.map +7 -0
index cb01bfd..e3b21ca 100644
@@ -17,3 +17,10 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_2.3 {
+	global:
+
+	rte_jobstats_abort;
+
+} DPDK_2.0;
Signature · 1 line
1.9.1
Acked-by on v3 1/1
#6 lore raw
Quoted 114 lines · Marcin Kerlin

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occurs, condition is defined by the application for example when receiving n>0 packets. Example of usage is added to the example l2fwd-jobstats. At maximum load do-while loop inside Idle job will be execute once because one or more jobs waiting to be executed, so this time should not be include as the execution time by calling rte_jobstats_abort().

v2:
* removed redundant field
v3:
* added an example of using

---
  examples/l2fwd-jobstats/main.c               |  9 ++++++++-
  lib/librte_jobstats/rte_jobstats.c           | 20 ++++++++++++++++++++
  lib/librte_jobstats/rte_jobstats.h           | 14 ++++++++++++++
  lib/librte_jobstats/rte_jobstats_version.map |  7 +++++++
  4 files changed, 49 insertions(+), 1 deletion(-)
examples/l2fwd-jobstats/main.c +8 -1
index 7b59f4e..bd64e74 100644
@@ -577,10 +577,13 @@ l2fwd_main_loop(void)
  			 */
  			rte_jobstats_start(&qconf->jobs_context, &qconf->idle_job);
 
+			uint64_t repeats = 0;
+
  			do {
  				uint8_t i;
  				uint64_t now = rte_get_timer_cycles();
 
+				repeats++;
  				need_manage = qconf->flush_timer.expire < now;
  				/* Check if we was esked to give a stats. */
  				stats_read_pending =
@@ -591,7 +594,11 @@ l2fwd_main_loop(void)
  					need_manage = qconf->rx_timers[i].expire < now;
 
  			} while (!need_manage);
-			rte_jobstats_finish(&qconf->idle_job, qconf->idle_job.target);
+
+			if (likely(repeats != 1))
+				rte_jobstats_finish(&qconf->idle_job, qconf->idle_job.target);
+			else
+				rte_jobstats_abort(&qconf->idle_job);
 
  			rte_timer_manage();
  			rte_jobstats_context_finish(&qconf->jobs_context);
lib/librte_jobstats/rte_jobstats.c +20 -0
index 2eaac0c..2b42050 100644
@@ -170,6 +170,26 @@ rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job)
  }
 
  int
+rte_jobstats_abort(struct rte_jobstats *job)
+{
+	struct rte_jobstats_context *ctx;
+	uint64_t now, exec_time;
+
+	/* Some sanity check. */
+	if (unlikely(job == NULL || job->context == NULL))
+		return -EINVAL;
+
+	ctx = job->context;
+	now = get_time();
+	exec_time = now - ctx->state_time;
+	ADD_TIME_MIN_MAX(ctx, management, exec_time);
+	ctx->state_time = now;
+	job->context = NULL;
+
+	return 0;
+}
+
+int
  rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value)
  {
  	struct rte_jobstats_context *ctx;
lib/librte_jobstats/rte_jobstats.h +14 -0
index de6a89a..c2b285f 100644
@@ -237,6 +237,20 @@ int
  rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);
 
  /**
+ * Mark that *job* finished its execution, but time of this work will be skipped
+ * and added to management time.
+ *
+ * @param job
+ *  Job object.
+ *
+ * @return
+ *  0 on success
+ *  -EINVAL if job is NULL or job was not started (it have no context).
+ */
+int
+rte_jobstats_abort(struct rte_jobstats *job);
+
+/**
   * Mark that *job* finished its execution. Context in which it was executing
   * will receive stat update. After this function call *job* object is ready to
   * be executed in other context.
lib/librte_jobstats/rte_jobstats_version.map +0 -0
index cb01bfd..e3b21ca 100644

lib/librte_jobstats/rte_jobstats_version.map DPDK_2.0 { · line 26

Quoted 10 lines
lib/librte_jobstats/rte_jobstats_version.map +7 -0
@@ -17,3 +17,10 @@ DPDK_2.0 {
 
  	local: *;
  };
+
+DPDK_2.3 {
+	global:
+
+	rte_jobstats_abort;
+
+} DPDK_2.0;
#7 lore raw

2016-02-16 13:19, Zhang, Roy Fan:

Quoted 17 lines · Marcin Kerlin
Quoted 15 lines

This patch adds new function rte_jobstats_abort. It marks *job* as finished and time of this work will be add to management time instead of execution time. This function should be used instead of rte_jobstats_finish if condition occurs, condition is defined by the application for example when receiving n>0 packets. Example of usage is added to the example l2fwd-jobstats. At maximum load do-while loop inside Idle job will be execute once because one or more jobs waiting to be executed, so this time should not be include as the execution time by calling rte_jobstats_abort().

v2:
* removed redundant field
v3:
* added an example of using

[...]

Quoted 8 lines

lib/librte_jobstats/rte_jobstats_version.map DPDK_2.0 { · line 21

Quoted 8 lines
lib/librte_jobstats/rte_jobstats_version.map +2 -0
@@ -17,3 +17,10 @@ DPDK_2.0 {
 
  	local: *;
  };
+
+DPDK_2.3 {

updated to 16.04

Quoted 7 lines

lib/librte_jobstats/rte_jobstats_version.map DPDK_2.0 { · line 26

Quoted 5 lines
lib/librte_jobstats/rte_jobstats_version.map +5 -0
+	global:
+
+	rte_jobstats_abort;
+
+} DPDK_2.0;

Applied, thanks