[dpdk-dev] [PATCH 2/2] timer bug fix

Olivier MATZ olivier.matz at 6wind.com
Wed May 21 16:31:21 CEST 2014


Hi Vadim,

On 05/16/2014 12:15 PM, Vadim Suraev wrote:
> Description: while running a periodic timer's callback, if another
>   timer is manipulated, the updated flag is raised
>   preventing the periodic timer to reload.
> Fix: move
>   updated flag from priv_timer to rte_timer stucture (one
>   per core)
>
> Signed-off-by: Vadim Suraev <vadim.suraev at gmail.com>
 >
> [...]
 >
> --- a/lib/librte_timer/rte_timer.h
> +++ b/lib/librte_timer/rte_timer.h
> @@ -129,6 +129,10 @@ struct rte_timer
>   	uint64_t period;       /**< Period of timer (0 if not periodic). */
>   	rte_timer_cb_t *f;     /**< Callback function. */
>   	void *arg;             /**< Argument to callback function. */
> +        /** per-core variable that true if a timer was updated on this
> +	 *  core since last reset of the variable */
> +	int updated[RTE_MAX_LCORE];
> +
>   };

I don't think that adding a quite large table in the rte_timer
structure is a good idea.

Instead, I suggest to add a new field in the per-core structure
priv_timer:

	struct rte_timer *cur_timer;

This timer pointer is set before invoking the callback of the
timer. Then, you could do this in rte_timer_reset() and
rte_timer_stop():

	if (tim == priv_timer[lcore_id].cur_timer)
		priv_timer[lcore_id].updated = 1;

I think it will also fix the problem you are describing (which
is a real problem), in a more simple way.

Regards,
Olivier



More information about the dev mailing list