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>
*/
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 =
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);
return 0;
}
+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)
{
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
local: *;
};
+
+DPDK_16.04 {
+ global:
+
+ rte_jobstats_abort;
+
+} DPDK_2.0;