summaryrefslogtreecommitdiff
path: root/lib/librte_jobstats
diff options
context:
space:
mode:
authorMarcin Kerlin <marcinx.kerlin@intel.com>2016-02-12 17:04:41 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-02-29 11:22:53 +0100
commit930cd79735d082ba7c9b37a9f0490c359b2f244a (patch)
tree55d390702ce12a140aadbef5cef01cf89ccaa036 /lib/librte_jobstats
parenta3af38a1db5a6f5b8e5090ec45a1c58a8af362c3 (diff)
downloaddpdk-930cd79735d082ba7c9b37a9f0490c359b2f244a.zip
dpdk-930cd79735d082ba7c9b37a9f0490c359b2f244a.tar.gz
dpdk-930cd79735d082ba7c9b37a9f0490c359b2f244a.tar.xz
jobstats: add abort function
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(). Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Diffstat (limited to 'lib/librte_jobstats')
-rw-r--r--lib/librte_jobstats/rte_jobstats.c20
-rw-r--r--lib/librte_jobstats/rte_jobstats.h14
-rw-r--r--lib/librte_jobstats/rte_jobstats_version.map7
3 files changed, 41 insertions, 0 deletions
diff --git a/lib/librte_jobstats/rte_jobstats.c b/lib/librte_jobstats/rte_jobstats.c
index 2eaac0c..2b42050 100644
--- a/lib/librte_jobstats/rte_jobstats.c
+++ b/lib/librte_jobstats/rte_jobstats.c
@@ -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;
diff --git a/lib/librte_jobstats/rte_jobstats.h b/lib/librte_jobstats/rte_jobstats.h
index de6a89a..c2b285f 100644
--- a/lib/librte_jobstats/rte_jobstats.h
+++ b/lib/librte_jobstats/rte_jobstats.h
@@ -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.
diff --git a/lib/librte_jobstats/rte_jobstats_version.map b/lib/librte_jobstats/rte_jobstats_version.map
index cb01bfd..f894414 100644
--- a/lib/librte_jobstats/rte_jobstats_version.map
+++ b/lib/librte_jobstats/rte_jobstats_version.map
@@ -17,3 +17,10 @@ DPDK_2.0 {
local: *;
};
+
+DPDK_16.04 {
+ global:
+
+ rte_jobstats_abort;
+
+} DPDK_2.0;