From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Joe Jin <joe.jin@oracle.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Philip Lee <philip.lee@oracle.com>, Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH] xenbaked.c: Avoid divide by zero issue on dump_stats()
Date: Tue, 13 Mar 2018 22:24:26 -0400 [thread overview]
Message-ID: <20180314022426.GQ3543@char.us.oracle.com> (raw)
In-Reply-To: <560fcc42-d01f-f60d-0c9f-4373d4e8e8f4@oracle.com>
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@oracle.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> ---
> 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-03-14 2:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-14 1:38 [PATCH] xenbaked.c: Avoid divide by zero issue on dump_stats() Joe Jin
2018-03-14 2:24 ` Konrad Rzeszutek Wilk [this message]
2018-03-14 10:54 ` George Dunlap
2018-03-14 14:04 ` Konrad Rzeszutek Wilk
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=20180314022426.GQ3543@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=ian.campbell@citrix.com \
--cc=joe.jin@oracle.com \
--cc=philip.lee@oracle.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).