|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xenbaked.c: Avoid divide by zero issue on dump_stats()
On Tue, Mar 13, 2018 at 06:38:24PM -0700, Joe Jin wrote:
> run_time on dump_stats() maybe zero if break xenmon.py immediately after it
s/maybe/can be/
> 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."
>
> Signed-off-by: Joe Jin <joe.jin@xxxxxxxxxx>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
> ---
> tools/xenmon/xenbaked.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
> index 3d9e0ed900..d3f940a26b 100644
> --- a/tools/xenmon/xenbaked.c
> +++ b/tools/xenmon/xenbaked.c
> @@ -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();
> }
> --
> 2.14.3 (Apple Git-98)
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |