idle-prof: Fix segment fault issue when run with '--idle-prof' and multiple output...
authorFriendy.Su@sony.com <Friendy.Su@sony.com>
Fri, 8 Jun 2018 02:27:25 +0000 (20:27 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 8 Jun 2018 02:27:25 +0000 (20:27 -0600)
Original issue:

./fio --output-format=normal,json --idle-prof=system jobfile.job

job1: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=sync, iodepth=1
fio-3.7-19-ga43f
Starting 1 process
Segmentation fault (core dumped)

Fix solution:

do fio_idle_prof_cleanup() after all formats of output shown.

Signed-off-by: friendy-su <friendy.su@sony.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
idletime.c
idletime.h
stat.c

index 8762c8565ea8e66116a7e98ed5b544ddc3b1d624..2f59f5104b4152c7b156a1bd255f898eb1ba7c72 100644 (file)
@@ -397,7 +397,7 @@ static double fio_idle_prof_cpu_stat(int cpu)
        return p * 100.0;
 }
 
        return p * 100.0;
 }
 
-static void fio_idle_prof_cleanup(void)
+void fio_idle_prof_cleanup(void)
 {
        if (ipc.ipts) {
                free(ipc.ipts);
 {
        if (ipc.ipts) {
                free(ipc.ipts);
@@ -471,10 +471,6 @@ void show_idle_prof_stats(int output, struct json_object *parent,
                        log_buf(out, " stddev=%3.2f\n", ipc.cali_stddev);
                }
 
                        log_buf(out, " stddev=%3.2f\n", ipc.cali_stddev);
                }
 
-               /* dynamic mem allocations can now be freed */
-               if (ipc.opt != IDLE_PROF_OPT_NONE)
-                       fio_idle_prof_cleanup();
-
                return;
        }
 
                return;
        }
 
@@ -498,7 +494,5 @@ void show_idle_prof_stats(int output, struct json_object *parent,
 
                json_object_add_value_float(tmp, "unit_mean", ipc.cali_mean);
                json_object_add_value_float(tmp, "unit_stddev", ipc.cali_stddev);
 
                json_object_add_value_float(tmp, "unit_mean", ipc.cali_mean);
                json_object_add_value_float(tmp, "unit_stddev", ipc.cali_stddev);
-               
-               fio_idle_prof_cleanup();
        }
 }
        }
 }
index 6c1161a7c258d07efb0b41f1be7b9f2ef8d7e53c..91ca95f5ee5ba69901b41a25346954a7bbec172b 100644 (file)
@@ -58,4 +58,6 @@ extern void fio_idle_prof_stop(void);
 
 extern void show_idle_prof_stats(int, struct json_object *, struct buf_output *);
 
 
 extern void show_idle_prof_stats(int, struct json_object *, struct buf_output *);
 
+extern void fio_idle_prof_cleanup(void);
+
 #endif
 #endif
diff --git a/stat.c b/stat.c
index 5b49dddbb1d0786341902bd4a2b75271db30f466..58edf047b34f51106889cb1f315baa00c3bcf783 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1934,6 +1934,8 @@ void __show_run_stats(void)
                buf_output_free(out);
        }
 
                buf_output_free(out);
        }
 
+       fio_idle_prof_cleanup();
+
        log_info_flush();
        free(runstats);
        free(threadstats);
        log_info_flush();
        free(runstats);
        free(threadstats);