From: Ilya Pronin <>

When printing stats in CSV mode, 'perf stat' appends extra separators
when a counter is not supported:


Which causes a failure when parsing fields. The numbers of separators
should be the same for each line, no matter if the counter is or not

Signed-off-by: Ilya Pronin <>
Acked-by: Jiri Olsa <>
Cc: Andi Kleen <>
Fixes: 92a61f6412d3 ("perf stat: Implement CSV metrics output")
Signed-off-by: Cong Wang <>
Signed-off-by: Arnaldo Carvalho de Melo <>
 tools/perf/builtin-stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 98bf9d32f222..54a4c152edb3 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -917,7 +917,7 @@ static void print_metric_csv(void *ctx,
        char buf[64], *vals, *ends;
        if (unit == NULL || fmt == NULL) {
-               fprintf(out, "%s%s%s%s", csv_sep, csv_sep, csv_sep, csv_sep);
+               fprintf(out, "%s%s", csv_sep, csv_sep);
        snprintf(buf, sizeof(buf), fmt, val);

Reply via email to