DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Roy Fan" <roy.fan.zhang@intel.com>
To: Marcin Kerlin <marcinx.kerlin@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3 1/1] jobstats: added function abort for job
Date: Tue, 16 Feb 2016 13:19:25 +0000	[thread overview]
Message-ID: <56C321DD.6080906@intel.com> (raw)
In-Reply-To: <1455293081-13094-1-git-send-email-marcinx.kerlin@intel.com>



On 12/02/2016 16:04, Marcin Kerlin wrote:
> 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
>
> Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
> ---
>   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(-)
>
> diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
> index 7b59f4e..bd64e74 100644
> --- a/examples/l2fwd-jobstats/main.c
> +++ b/examples/l2fwd-jobstats/main.c
> @@ -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);
> 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..e3b21ca 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_2.3 {
> +	global:
> +
> +	rte_jobstats_abort;
> +
> +} DPDK_2.0;

Acked-by : Fan Zhang<roy.fan.zhang@intel.com>

  reply	other threads:[~2016-02-16 13:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26 16:15 [dpdk-dev] [PATCH V1 " Marcin Kerlin
2016-01-27 13:37 ` Panu Matilainen
2016-01-27 15:57   ` Jastrzebski, MichalX K
2016-01-28  7:41     ` Panu Matilainen
2016-01-29 15:31 ` [dpdk-dev] [PATCH v2 " Marcin Kerlin
2016-02-12 16:04   ` [dpdk-dev] [PATCH v3 " Marcin Kerlin
2016-02-16 13:19     ` Zhang, Roy Fan [this message]
2016-02-29 10:21       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C321DD.6080906@intel.com \
    --to=roy.fan.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=marcinx.kerlin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).