* [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime()
@ 2024-11-11 1:49 ende.tan
2024-11-19 19:48 ` Marcelo Tosatti
2024-11-21 18:48 ` John Kacur
0 siblings, 2 replies; 3+ messages in thread
From: ende.tan @ 2024-11-11 1:49 UTC (permalink / raw)
To: linux-rt-users, mtosatti; +Cc: williams, jkacur, leyfoon.tan, Tan En De
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime()
2024-11-11 1:49 [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime() ende.tan
@ 2024-11-19 19:48 ` Marcelo Tosatti
2024-11-21 18:48 ` John Kacur
1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2024-11-19 19:48 UTC (permalink / raw)
To: ende.tan; +Cc: linux-rt-users, williams, jkacur, leyfoon.tan
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>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime()
2024-11-11 1:49 [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime() ende.tan
2024-11-19 19:48 ` Marcelo Tosatti
@ 2024-11-21 18:48 ` John Kacur
1 sibling, 0 replies; 3+ messages in thread
From: John Kacur @ 2024-11-21 18:48 UTC (permalink / raw)
To: Tan En De; +Cc: linux-rt-users, mtosatti, williams, leyfoon.tan
On Mon, 11 Nov 2024, 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
>
>
>
Signed-off-by: John Kacur <jkacur@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-21 18:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 1:49 [1/1] rt-tests: queuelat: Fix wraparound in __clock_gettime() ende.tan
2024-11-19 19:48 ` Marcelo Tosatti
2024-11-21 18:48 ` John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox