From: Marcelo Tosatti <mtosatti@redhat.com>
To: ende.tan@starfivetech.com
Cc: linux-rt-users@vger.kernel.org, williams@redhat.com,
jkacur@redhat.com, leyfoon.tan@starfivetech.com
Subject: Re: [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime()
Date: Tue, 19 Nov 2024 16:48:47 -0300 [thread overview]
Message-ID: <Zzzrn7ceCeAUFfbc@tpad> (raw)
In-Reply-To: <20241111014911.11571-1-ende.tan@starfivetech.com>
On Mon, Nov 11, 2024 at 09:49:11AM +0800, ende.tan@starfivetech.com wrote:
> From: Tan En De <ende.tan@starfivetech.com>
>
> Include tv_sec in addition to tv_nsec in __clock_gettime(). If the value
> of variable 'a' wraps around, it may cause 'delta' to be negative, while
> 'delta' is defined with u64 type.
>
> Signed-off-by: Tan En De <ende.tan@starfivetech.com>
> ---
> src/queuelat/queuelat.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c
> index c549cd8..c057389 100644
> --- a/src/queuelat/queuelat.c
> +++ b/src/queuelat/queuelat.c
> @@ -292,7 +292,8 @@ static inline unsigned long long __clock_gettime(void)
> if (ret < 0)
> return 0;
>
> - return now.tv_nsec;
> + // Combine seconds and nanoseconds into a single value in nanoseconds
> + return (unsigned long long)now.tv_sec * 1000000000ULL + now.tv_nsec;
> }
>
> #define gettick(val) do { (val) = __clock_gettime(); } while (0)
> --
> 2.34.1
>
>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
next prev parent reply other threads:[~2024-11-19 19:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-11 1:49 [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime() ende.tan
2024-11-19 19:48 ` Marcelo Tosatti [this message]
2024-11-21 18:48 ` John Kacur
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=Zzzrn7ceCeAUFfbc@tpad \
--to=mtosatti@redhat.com \
--cc=ende.tan@starfivetech.com \
--cc=jkacur@redhat.com \
--cc=leyfoon.tan@starfivetech.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.