diff mbox

[2/3,v4] linux-generic: odp_timer: warn if tick is late

Message ID 1447166428-23791-3-git-send-email-ivan.khoronzhuk@linaro.org
State New
Headers show

Commit Message

Ivan Khoronzhuk Nov. 10, 2015, 2:40 p.m. UTC
If tick is late then application should be warned about this.
It means that actual timer resolution is worse than expected.
The default timer resolution is set 10ms, that is equal to jiffy
on most systems. The default resolution is set bearing in mind
that on a CPU runs maximum two threads that ideally fits in 10ms.
But user can change it to be smaller, in case if CPU0 is isolated
and it handles only the timer ticks. This patch helps user to set
correct timer resolution.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 platform/linux-generic/odp_timer.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Ola Liljedahl Nov. 10, 2015, 2:47 p.m. UTC | #1
On 10 November 2015 at 15:40, Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
wrote:

> If tick is late then application should be warned about this.

> It means that actual timer resolution is worse than expected.

> The default timer resolution is set 10ms, that is equal to jiffy

> on most systems. The default resolution is set bearing in mind

> that on a CPU runs maximum two threads that ideally fits in 10ms.

> But user can change it to be smaller, in case if CPU0 is isolated

> and it handles only the timer ticks. This patch helps user to set

> correct timer resolution.

>

> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

> ---

>  platform/linux-generic/odp_timer.c | 6 ++++++

>  1 file changed, 6 insertions(+)

>

> diff --git a/platform/linux-generic/odp_timer.c

> b/platform/linux-generic/odp_timer.c

> index e8f0267..917ee5a 100644

> --- a/platform/linux-generic/odp_timer.c

> +++ b/platform/linux-generic/odp_timer.c

> @@ -632,7 +632,13 @@ static unsigned

> odp_timer_pool_expire(odp_timer_pool_t tpid, uint64_t tick)

>

>  static void timer_notify(sigval_t sigval)

>  {

> +       int overrun;

>         odp_timer_pool *tp = (odp_timer_pool *)sigval.sival_ptr;

> +

> +       overrun = timer_getoverrun(tp->timerid);

> +       if (overrun)

> +               ODP_ERR("\n\tlow resolution!, overrun ticks: %d\n",

> overrun);

>

Actually the timer resolution isn't too low (low resolution <=> long
period) but too high (too short period for the system to handle).

"Ticks lost on timer %s, timer resolution too high\n", tpid->name



> +

>  #ifdef __ARM_ARCH

>         odp_timer *array = &tp->timers[0];

>         uint32_t i;

> --

> 1.9.1

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
Ivan Khoronzhuk Nov. 10, 2015, 2:57 p.m. UTC | #2
On 10.11.15 16:47, Ola Liljedahl wrote:
>
>
> On 10 November 2015 at 15:40, Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org <mailto:ivan.khoronzhuk@linaro.org>> wrote:
>
>     If tick is late then application should be warned about this.
>     It means that actual timer resolution is worse than expected.
>     The default timer resolution is set 10ms, that is equal to jiffy
>     on most systems. The default resolution is set bearing in mind
>     that on a CPU runs maximum two threads that ideally fits in 10ms.
>     But user can change it to be smaller, in case if CPU0 is isolated
>     and it handles only the timer ticks. This patch helps user to set
>     correct timer resolution.
>
>     Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org <mailto:ivan.khoronzhuk@linaro.org>>
>     ---
>       platform/linux-generic/odp_timer.c | 6 ++++++
>       1 file changed, 6 insertions(+)
>
>     diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
>     index e8f0267..917ee5a 100644
>     --- a/platform/linux-generic/odp_timer.c
>     +++ b/platform/linux-generic/odp_timer.c
>     @@ -632,7 +632,13 @@ static unsigned odp_timer_pool_expire(odp_timer_pool_t tpid, uint64_t tick)
>
>       static void timer_notify(sigval_t sigval)
>       {
>     +       int overrun;
>              odp_timer_pool *tp = (odp_timer_pool *)sigval.sival_ptr;
>     +
>     +       overrun = timer_getoverrun(tp->timerid);
>     +       if (overrun)
>     +               ODP_ERR("\n\tlow resolution!, overrun ticks: %d\n", overrun);
>
> Actually the timer resolution isn't too low (low resolution <=> long period)
> but too high (too short period for the system to handle).

Yes. rename low resolution => too high

>
> "Ticks lost on timer %s, timer resolution too high\n", tpid->name

Not lost, rather late and for timer pool instead of timer.
Will pass timer pool name here in new version.
Thanks

>
>     +
>       #ifdef __ARM_ARCH
>              odp_timer *array = &tp->timers[0];
>              uint32_t i;
>     --
>     1.9.1
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Ivan Khoronzhuk Nov. 11, 2015, 12:23 p.m. UTC | #3
Ola,

I've sent new v2 series with your suggestions,
Could you please review it,
[lng-odp] [PATCH 0/3 v2] add warnings to improve timer usage
https://lists.linaro.org/pipermail/lng-odp/2015-November/017195.html

On 10.11.15 16:47, Ola Liljedahl wrote:
>
>
> On 10 November 2015 at 15:40, Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org <mailto:ivan.khoronzhuk@linaro.org>> wrote:
>
>     If tick is late then application should be warned about this.
>     It means that actual timer resolution is worse than expected.
>     The default timer resolution is set 10ms, that is equal to jiffy
>     on most systems. The default resolution is set bearing in mind
>     that on a CPU runs maximum two threads that ideally fits in 10ms.
>     But user can change it to be smaller, in case if CPU0 is isolated
>     and it handles only the timer ticks. This patch helps user to set
>     correct timer resolution.
>
>     Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org <mailto:ivan.khoronzhuk@linaro.org>>
>     ---
>       platform/linux-generic/odp_timer.c | 6 ++++++
>       1 file changed, 6 insertions(+)
>
>     diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
>     index e8f0267..917ee5a 100644
>     --- a/platform/linux-generic/odp_timer.c
>     +++ b/platform/linux-generic/odp_timer.c
>     @@ -632,7 +632,13 @@ static unsigned odp_timer_pool_expire(odp_timer_pool_t tpid, uint64_t tick)
>
>       static void timer_notify(sigval_t sigval)
>       {
>     +       int overrun;
>              odp_timer_pool *tp = (odp_timer_pool *)sigval.sival_ptr;
>     +
>     +       overrun = timer_getoverrun(tp->timerid);
>     +       if (overrun)
>     +               ODP_ERR("\n\tlow resolution!, overrun ticks: %d\n", overrun);
>
> Actually the timer resolution isn't too low (low resolution <=> long period) but too high (too short period for the system to handle).
>
> "Ticks lost on timer %s, timer resolution too high\n", tpid->name
>
>     +
>       #ifdef __ARM_ARCH
>              odp_timer *array = &tp->timers[0];
>              uint32_t i;
>     --
>     1.9.1
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index e8f0267..917ee5a 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -632,7 +632,13 @@  static unsigned odp_timer_pool_expire(odp_timer_pool_t tpid, uint64_t tick)
 
 static void timer_notify(sigval_t sigval)
 {
+	int overrun;
 	odp_timer_pool *tp = (odp_timer_pool *)sigval.sival_ptr;
+
+	overrun = timer_getoverrun(tp->timerid);
+	if (overrun)
+		ODP_ERR("\n\tlow resolution!, overrun ticks: %d\n", overrun);
+
 #ifdef __ARM_ARCH
 	odp_timer *array = &tp->timers[0];
 	uint32_t i;