DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Carrillo, Erik G" <erik.g.carrillo@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v1] rte_timer: add rte_timer_next_ticks
Date: Fri, 20 Dec 2019 22:43:06 +0000	[thread overview]
Message-ID: <BYAPR11MB341574BEFFFC7A17D37346C7B92D0@BYAPR11MB3415.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20191217005503.31196-1-stephen@networkplumber.org>

Hi Stephen,

I added a comment  in-line.  With that change, it looks good to me:

Acked-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>

Regards,
Erik

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, December 16, 2019 6:55 PM
> To: dev@dpdk.org
> Cc: Carrillo, Erik G <erik.g.carrillo@intel.com>; Stephen Hemminger
> <stephen@networkplumber.org>
> Subject: [PATCH v1] rte_timer: add rte_timer_next_ticks
> 
> It is useful to know when the next timer will expire when using
> rte_epoll_wait (or sleep when idle). This experimental API provides a hook
> to query the number of ticks remaining.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v1 - incorporate feedback from old RFC
> 
>  lib/librte_timer/rte_timer.c           | 27 ++++++++++++++++++++++++++
>  lib/librte_timer/rte_timer.h           | 16 +++++++++++++++
>  lib/librte_timer/rte_timer_version.map |  1 +
>  3 files changed, 44 insertions(+)
> 
> diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index
> ca88454ff68a..a1ed186cf591 100644
> --- a/lib/librte_timer/rte_timer.c
> +++ b/lib/librte_timer/rte_timer.c
> @@ -978,6 +978,33 @@ rte_timer_stop_all(uint32_t timer_data_id,
> unsigned int *walk_lcores,
>  	return 0;
>  }
> 
> +int64_t
> +rte_timer_next_ticks(void)
> +{
> +	unsigned int lcore_id = rte_lcore_id();
> +	struct rte_timer_data *timer_data;
> +	struct priv_timer *priv_timer;
> +	const struct rte_timer *tm;
> +	uint64_t cur_time;
> +	int64_t left = -ENOENT;
> +
> +	TIMER_DATA_VALID_GET_OR_ERR_RET(default_data_id,
> timer_data, -EINVAL);
> +
> +	priv_timer = timer_data->priv_timer;
> +	cur_time = rte_get_timer_cycles();
> +
> +	rte_spinlock_lock(&priv_timer[lcore_id].list_lock);
> +	tm = priv_timer[lcore_id].pending_head.sl_next[0];
> +	if (tm) {
> +		left = tm->expire - cur_time;
> +		if (left < 0)
> +			left = 0;
> +	}
> +	rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
> +
> +	return left;
> +}
> +
>  /* dump statistics about timers */
>  static void
>  __rte_timer_dump_stats(struct rte_timer_data *timer_data __rte_unused,
> FILE *f) diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte_timer.h
> index 9dc5fc309249..c5031d0448ba 100644
> --- a/lib/librte_timer/rte_timer.h
> +++ b/lib/librte_timer/rte_timer.h
> @@ -331,6 +331,22 @@ void rte_timer_stop_sync(struct rte_timer *tim);
>   */
>  int rte_timer_pending(struct rte_timer *tim);
> 
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change without prior notice
> + *
> + * Time until the next timer

s/next timer/next timer on the current lcore

> + * This function gives the ticks until the next timer will be active.
> + *
> + * @return
> + *   - -EINVAL: invalid timer data instance identifier
> + *   - -ENOENT: no timer pending
> + *   - 0: a timer is pending and will run at next rte_timer_manage()
> + *   - >0: ticks until the next timer is ready
> + */
> +__rte_experimental
> +int64_t rte_timer_next_ticks(void);
> +
>  /**
>   * Manage the timer list and execute callback functions.
>   *
> diff --git a/lib/librte_timer/rte_timer_version.map
> b/lib/librte_timer/rte_timer_version.map
> index 2a59d3f081c4..4471cef92be5 100644
> --- a/lib/librte_timer/rte_timer_version.map
> +++ b/lib/librte_timer/rte_timer_version.map
> @@ -23,6 +23,7 @@ EXPERIMENTAL {
>  	rte_timer_alt_stop;
>  	rte_timer_data_alloc;
>  	rte_timer_data_dealloc;
> +	rte_timer_next_ticks;
>  	rte_timer_stop_all;
>  	rte_timer_subsystem_finalize;
>  };
> --
> 2.20.1


  reply	other threads:[~2019-12-20 22:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10 22:44 [dpdk-dev] [RFC] " Stephen Hemminger
2019-06-11 13:37 ` Sanford, Robert
2019-06-11 14:27   ` Stephen Hemminger
2019-06-11 14:45     ` Sanford, Robert
2019-06-12 18:19 ` Carrillo, Erik G
2019-12-17  0:55 ` [dpdk-dev] [PATCH v1] " Stephen Hemminger
2019-12-20 22:43   ` Carrillo, Erik G [this message]
2020-01-20  0:38     ` 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=BYAPR11MB341574BEFFFC7A17D37346C7B92D0@BYAPR11MB3415.namprd11.prod.outlook.com \
    --to=erik.g.carrillo@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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).