linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blkiomon: Fix an output error.
@ 2011-01-14  7:56 Tao Ma
  2011-01-14  8:07 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Tao Ma @ 2011-01-14  7:56 UTC (permalink / raw)
  To: linux-btrace

From: Tao Ma <boyu.mt@taobao.com>

When we give out some statistics in blkiomon, we don't consider
the situation that the device has no correspoinding action. See
if there is no disk read during the interval, the output in my box is
like:
sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg nan, var nan

With the fix, now it looks like:
sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg 0.0, var 0.0

Cc: Jens Axboe <axboe@kernel.dk>
Cc: Martin Peschke <mpeschke@linux.vnet.ibm.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 stats.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/stats.h b/stats.h
index fdedf27..5b9a313 100644
--- a/stats.h
+++ b/stats.h
@@ -75,6 +75,9 @@ static inline void minmax_to_be(struct minmax *mm)
 
 static inline double minmax_avg(struct minmax *mm)
 {
+	if (!mm->num)
+		return 0;
+
 	return (mm->sum / (double)mm->num);
 }
 
@@ -82,6 +85,9 @@ static inline double minmax_var(struct minmax *mm)
 {
 	double num = (double)mm->num;
 
+	if (!mm->num)
+		return 0;
+
 	return ((mm->sos - ((mm->sum * mm->sum) / num)) / num);
 }
 
-- 
1.6.3.GIT

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] blkiomon: Fix an output error.
  2011-01-14  7:56 [PATCH] blkiomon: Fix an output error Tao Ma
@ 2011-01-14  8:07 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2011-01-14  8:07 UTC (permalink / raw)
  To: linux-btrace

On 2011-01-14 08:56, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> When we give out some statistics in blkiomon, we don't consider
> the situation that the device has no correspoinding action. See
> if there is no disk read during the interval, the output in my box is
> like:
> sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg nan, var nan
> 
> With the fix, now it looks like:
> sizes read (bytes): num 0, min -1, max 0, sum 0, squ 0, avg 0.0, var 0.0

Thanks, applied!

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-14  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14  7:56 [PATCH] blkiomon: Fix an output error Tao Ma
2011-01-14  8:07 ` Jens Axboe

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).