提交 45528f7c 编写于 作者: D David Ahern 提交者: Arnaldo Carvalho de Melo

perf stats: Fix divide by 0 in variance

Number of samples needs to be greater 1 to have a variance.

Fixes nan% in perf-kvm-live output.
Signed-off-by: NDavid Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Runzhen Wang <runzhen@linux.vnet.ibm.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1369527896-3650-9-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 6ca5f308
...@@ -37,7 +37,7 @@ double stddev_stats(struct stats *stats) ...@@ -37,7 +37,7 @@ double stddev_stats(struct stats *stats)
{ {
double variance, variance_mean; double variance, variance_mean;
if (!stats->n) if (stats->n < 2)
return 0.0; return 0.0;
variance = stats->M2 / (stats->n - 1); variance = stats->M2 / (stats->n - 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册