Skip to contentSkip to conversation

xenbaked.c: Avoid divide by zero issue on dump_stats()

PATCH Superseded Joe Jin 3 participants 4 messages Mar 14, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joe Jin

author
#0 lore raw

PATCH 1/1 xenbaked.c: Avoid divide by zero issue on dump_stats()

run_time on dump_stats() maybe zero if break xenmon.py immediately after it started, then xenbaked hit divide by zero fault.

---
 tools/xenmon/xenbaked.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tools/xenmon/xenbaked.c +5 -3
index 3d9e0ed900..d3f940a26b 100644
@@ -243,10 +243,12 @@ static void dump_stats(void)
     }
 
     printf("processed %d total records in %d seconds (%ld per second)\n",
-           rec_count, (int)run_time, (long)(rec_count/run_time));
+           rec_count, (int)run_time,
+           run_time ? (long)(rec_count/run_time) : 0L);
 
-    printf("woke up %d times in %d seconds (%ld per second)\n", wakeups,
-	   (int) run_time, (long)(wakeups/run_time));
+    printf("woke up %d times in %d seconds (%ld per second)\n",
+           wakeups, (int) run_time,
+           run_time ? (long)(wakeups/run_time) : 0L);
 
     check_gotten_sum();
 }
Signature · 7 lines
2.14.3 (Apple Git-98)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 1 line · Joe Jin

run_time on dump_stats() maybe zero if break xenmon.py immediately after it

s/maybe/can be/

Quoted 1 line

started, then xenbaked hit divide by zero fault.

And:

"Note that run_time is computed using two values which are retrieved using 'time' system call which gives us resolution in seconds."

Quoted 32 lines
---
 tools/xenmon/xenbaked.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tools/xenmon/xenbaked.c +5 -3
index 3d9e0ed900..d3f940a26b 100644
@@ -243,10 +243,12 @@ static void dump_stats(void)
     }
 
     printf("processed %d total records in %d seconds (%ld per second)\n",
-           rec_count, (int)run_time, (long)(rec_count/run_time));
+           rec_count, (int)run_time,
+           run_time ? (long)(rec_count/run_time) : 0L);
 
-    printf("woke up %d times in %d seconds (%ld per second)\n", wakeups,
-	   (int) run_time, (long)(wakeups/run_time));
+    printf("woke up %d times in %d seconds (%ld per second)\n",
+           wakeups, (int) run_time,
+           run_time ? (long)(wakeups/run_time) : 0L);
 
     check_gotten_sum();
 }
Signature · 1 line
2.14.3 (Apple Git-98)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Joe Jin

run_time on dump_stats() maybe zero if break xenmon.py immediately after it

s/maybe/can be/

Quoted 1 line

started, then xenbaked hit divide by zero fault.

And:

"Note that run_time is computed using two values which are retrieved using 'time' system call which gives us resolution in seconds."

Is anyone still using this? Does it even work? I thought we had talked about removing it at some point.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 6 lines · George Dunlap
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Joe Jin

run_time on dump_stats() maybe zero if break xenmon.py immediately after it

s/maybe/can be/

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

started, then xenbaked hit divide by zero fault.

And:

"Note that run_time is computed using two values which are retrieved using 'time' system call which gives us resolution in seconds."

Is anyone still using this? Does it even work? I thought we had

Yes as we found out as folks start coming out of the woods with the need to update their OS thanks to spectre.

They use it with 'xenmon.py' combination.

Quoted 3 lines

talked about removing it at some point.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel