[dpdk-dev,V1,1/1] jobstats: added function abort for job

Message ID 1453824934-10650-1-git-send-email-marcinx.kerlin@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Marcin Kerlin Jan. 26, 2016, 4:15 p.m. UTC
  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.

Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
---
 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(+)

\ No newline at end of file
-- 1
1.9.1
  

Comments

Panu Matilainen Jan. 27, 2016, 1:37 p.m. UTC | #1
On 01/26/2016 06:15 PM, 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 occure,
> condition is defined by the application for example when receiving n>0 packets.
>
> Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
> ---
>   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(+)
>
[...]
> diff --git a/lib/librte_jobstats/rte_jobstats.h b/lib/librte_jobstats/rte_jobstats.h
> index de6a89a..9995319 100644
> --- a/lib/librte_jobstats/rte_jobstats.h
> +++ b/lib/librte_jobstats/rte_jobstats.h
> @@ -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 -
  
Michal Jastrzebski Jan. 27, 2016, 3:57 p.m. UTC | #2
> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Panu Matilainen

> Sent: Wednesday, January 27, 2016 2:38 PM

> To: Kerlin, MarcinX <marcinx.kerlin@intel.com>; dev@dpdk.org

> Subject: Re: [dpdk-dev] [PATCH V1 1/1] jobstats: added function abort for job

> 

> On 01/26/2016 06:15 PM, 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

> occure,

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

> packets.

> >

> > Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>

> > ---

> >   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(+)

> >

> [...]

> > diff --git a/lib/librte_jobstats/rte_jobstats.h

> b/lib/librte_jobstats/rte_jobstats.h

> > index de6a89a..9995319 100644

> > --- a/lib/librte_jobstats/rte_jobstats.h

> > +++ b/lib/librte_jobstats/rte_jobstats.h

> > @@ -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 -


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
  
Panu Matilainen Jan. 28, 2016, 7:41 a.m. UTC | #3
On 01/27/2016 05:57 PM, Jastrzebski, MichalX K wrote:
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Panu Matilainen
>> Sent: Wednesday, January 27, 2016 2:38 PM
>> To: Kerlin, MarcinX <marcinx.kerlin@intel.com>; dev@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH V1 1/1] jobstats: added function abort for job
>>
>> On 01/26/2016 06:15 PM, 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
>> occure,
>>> condition is defined by the application for example when receiving n>0
>> packets.
>>>
>>> Signed-off-by: Marcin Kerlin <marcinx.kerlin@intel.com>
>>> ---
>>>    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(+)
>>>
>> [...]
>>> diff --git a/lib/librte_jobstats/rte_jobstats.h
>> b/lib/librte_jobstats/rte_jobstats.h
>>> index de6a89a..9995319 100644
>>> --- a/lib/librte_jobstats/rte_jobstats.h
>>> +++ b/lib/librte_jobstats/rte_jobstats.h
>>> @@ -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 -
>
> 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 -
  

Patch

diff --git a/lib/librte_jobstats/rte_jobstats.c b/lib/librte_jobstats/rte_jobstats.c
index 2eaac0c..b603125 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;
@@ -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;
 }
diff --git a/lib/librte_jobstats/rte_jobstats.h b/lib/librte_jobstats/rte_jobstats.h
index de6a89a..9995319 100644
--- a/lib/librte_jobstats/rte_jobstats.h
+++ b/lib/librte_jobstats/rte_jobstats.h
@@ -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.
diff --git a/lib/librte_jobstats/rte_jobstats_version.map b/lib/librte_jobstats/rte_jobstats_version.map
index cb01bfd..0ec0650 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;