mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: uptime: add note about caveats
@ 2022-11-02  8:50 Ahmad Fatoum
  2022-11-04  8:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-11-02  8:50 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Normally timer overrun is not that much of a problem, because there
where it matters, we usually have an is_timeout() in the loop that reads
the timer often enough. This doesn't necessarily hold for the new uptime
command and basically anything can happen between subsequent calls and
if get_time_ns() is not called often enough during that time, we end up
with an inaccurate uptime. Mention this in the extended help text.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Can be squashed into original commit.
---
 commands/uptime.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/commands/uptime.c b/commands/uptime.c
index a9a8c650b698..d67538631c8f 100644
--- a/commands/uptime.c
+++ b/commands/uptime.c
@@ -66,6 +66,9 @@ static int do_uptime(int argc, char *argv[])
 BAREBOX_CMD_HELP_START(uptime)
 BAREBOX_CMD_HELP_TEXT("This command formats the number of elapsed nanoseconds")
 BAREBOX_CMD_HELP_TEXT("as measured with the current clocksource")
+BAREBOX_CMD_HELP_TEXT("Note: Timekeeping is co-operative. If long running code does")
+BAREBOX_CMD_HELP_TEXT("not use delay/is_timeout/get_time_ns/getchar functions")
+BAREBOX_CMD_HELP_TEXT("timer may overrun resulting in incorrect results")
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT ("-n",     "output elapsed time in nanoseconds")
 BAREBOX_CMD_HELP_END
-- 
2.30.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] commands: uptime: add note about caveats
  2022-11-02  8:50 [PATCH] commands: uptime: add note about caveats Ahmad Fatoum
@ 2022-11-04  8:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-11-04  8:54 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Nov 02, 2022 at 09:50:17AM +0100, Ahmad Fatoum wrote:
> Normally timer overrun is not that much of a problem, because there
> where it matters, we usually have an is_timeout() in the loop that reads
> the timer often enough. This doesn't necessarily hold for the new uptime
> command and basically anything can happen between subsequent calls and
> if get_time_ns() is not called often enough during that time, we end up
> with an inaccurate uptime. Mention this in the extended help text.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Can be squashed into original commit.
> ---
>  commands/uptime.c | 3 +++
>  1 file changed, 3 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/commands/uptime.c b/commands/uptime.c
> index a9a8c650b698..d67538631c8f 100644
> --- a/commands/uptime.c
> +++ b/commands/uptime.c
> @@ -66,6 +66,9 @@ static int do_uptime(int argc, char *argv[])
>  BAREBOX_CMD_HELP_START(uptime)
>  BAREBOX_CMD_HELP_TEXT("This command formats the number of elapsed nanoseconds")
>  BAREBOX_CMD_HELP_TEXT("as measured with the current clocksource")
> +BAREBOX_CMD_HELP_TEXT("Note: Timekeeping is co-operative. If long running code does")
> +BAREBOX_CMD_HELP_TEXT("not use delay/is_timeout/get_time_ns/getchar functions")
> +BAREBOX_CMD_HELP_TEXT("timer may overrun resulting in incorrect results")
>  BAREBOX_CMD_HELP_TEXT("Options:")
>  BAREBOX_CMD_HELP_OPT ("-n",     "output elapsed time in nanoseconds")
>  BAREBOX_CMD_HELP_END
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-04  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02  8:50 [PATCH] commands: uptime: add note about caveats Ahmad Fatoum
2022-11-04  8:54 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox