Skip to contentSkip to conversation

timer.h: Provide better monotonic time

PATCH In review Pranith Kumar 3 participants 4 messages Apr 18, 2017 – Jun 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 timer.h: Provide better monotonic time

Tested and confirmed that the stretch i386 debian qcow2 image on a raspberry pi 2 works.

---
 include/qemu/timer.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/qemu/timer.h +2 -3
index 8a1eb74839..1b518bca30 100644
@@ -1020,10 +1020,9 @@ static inline int64_t cpu_get_host_ticks(void)
 /* The host CPU doesn't have an easily accessible cycle counter.
    Just return a monotonically increasing value.  This will be
    totally wrong, but hopefully better than nothing.  */
-static inline int64_t cpu_get_host_ticks (void)
+static inline int64_t cpu_get_host_ticks(void)
 {
-    static int64_t ticks = 0;
-    return ticks++;
+    return get_clock();
 }
 #endif
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 15 lines · Pranith Kumar

Tested and confirmed that the stretch i386 debian qcow2 image on a raspberry pi 2 works.

---
 include/qemu/timer.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/qemu/timer.h +0 -0
index 8a1eb74839..1b518bca30 100644
@@ -1020,10 +1020,9 @@ static inline int64_t cpu_get_host_ticks(void)
 /* The host CPU doesn't have an easily accessible cycle counter.

include/qemu/timer.h static inline int64_t cpu_get_host_ticks(void) · line 1027

Quoted 10 lines
include/qemu/timer.h +2 -3
    Just return a monotonically increasing value.  This will be
    totally wrong, but hopefully better than nothing.  */
-static inline int64_t cpu_get_host_ticks (void)
+static inline int64_t cpu_get_host_ticks(void)
 {
-    static int64_t ticks = 0;
-    return ticks++;
+    return get_clock();
 }
 #endif

Hmm, it looks like this patch got lost. Paolo, did you want to give it a reviewed-by? From the discussion on v1 it sounded like you had the best grip on the timer code ;-)

(Does the comment on the function need updating ?)

thanks
-- PMM

Reviewed-by
#2 lore raw
Quoted 22 lines · Peter Maydell
Quoted 21 lines · Pranith Kumar

Tested and confirmed that the stretch i386 debian qcow2 image on a raspberry pi 2 works.

---
 include/qemu/timer.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/qemu/timer.h +1 -2
index 8a1eb74839..1b518bca30 100644
@@ -1020,10 +1020,9 @@ static inline int64_t cpu_get_host_ticks(void)
 /* The host CPU doesn't have an easily accessible cycle counter.
    Just return a monotonically increasing value.  This will be
    totally wrong, but hopefully better than nothing.  */
-static inline int64_t cpu_get_host_ticks (void)
+static inline int64_t cpu_get_host_ticks(void)
 {
-    static int64_t ticks = 0;
Quoted 8 lines

include/qemu/timer.h static inline int64_t cpu_get_host_ticks(void) · line 1027

Quoted 4 lines
include/qemu/timer.h +1 -1
-    return ticks++;
+    return get_clock();
 }
 #endif

Hmm, it looks like this patch got lost. Paolo, did you want to give it a reviewed-by? From the discussion on v1 it sounded like you had the best grip on the timer code ;-)

Sure:

Quoted 1 line

(Does the comment on the function need updating ?)

Apart from "totally", it's still pretty correct. :)

Thanks,

Paolo

#3 lore raw
Quoted 34 lines · Paolo Bonzini
Quoted 22 lines · Peter Maydell
Quoted 21 lines · Pranith Kumar

Tested and confirmed that the stretch i386 debian qcow2 image on a raspberry pi 2 works.

---
 include/qemu/timer.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/qemu/timer.h +1 -2
index 8a1eb74839..1b518bca30 100644
@@ -1020,10 +1020,9 @@ static inline int64_t cpu_get_host_ticks(void)
 /* The host CPU doesn't have an easily accessible cycle counter.
    Just return a monotonically increasing value.  This will be
    totally wrong, but hopefully better than nothing.  */
-static inline int64_t cpu_get_host_ticks (void)
+static inline int64_t cpu_get_host_ticks(void)
 {
-    static int64_t ticks = 0;
Quoted 8 lines

include/qemu/timer.h static inline int64_t cpu_get_host_ticks(void) · line 1027

Quoted 4 lines
include/qemu/timer.h +1 -1
-    return ticks++;
+    return get_clock();
 }
 #endif

Hmm, it looks like this patch got lost. Paolo, did you want to give it a reviewed-by? From the discussion on v1 it sounded like you had the best grip on the timer code ;-)

Quoted 7 lines

Sure:

Quoted 1 line

(Does the comment on the function need updating ?)

Apart from "totally", it's still pretty correct. :)

Thanks. I'll apply this to my arm queue since in practice only ARM hosts are affected by this change.

-- PMM