summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-01-26 11:23:55 +0100
committerJens Axboe <axboe@fb.com>2017-01-26 10:06:05 -0700
commit8772bc4fb049bdd879de5952d6f291a34112fae0 (patch)
treedfa287a67374349820f7b666effae2cace0a2866
parentd7a1f72671eb67a7d0cd261ea4520b9551c51f5f (diff)
downloadblktrace-8772bc4fb049bdd879de5952d6f291a34112fae0.tar.gz
blktrace-8772bc4fb049bdd879de5952d6f291a34112fae0.tar.bz2
blktrace: Create empty output files for non-existent cpus
When CPU number space is sparse, we don't start threads for non-existent CPUs. As a result, there are no output files created for these CPUs which confuses tools like blkparse which expect that CPU numbers are contiguous. Create fake empty files for non-existent CPUs so that other tools don't have to bother. Note that in network mode, the server will create all files in the range 0..max_cpus automatically. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--blktrace.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/blktrace.c b/blktrace.c
index 3a25338..e8f2f87 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -1893,6 +1893,26 @@ static int start_tracer(int cpu)
return 0;
}
+static int create_output_files(int cpu)
+{
+ char fname[MAXPATHLEN + 64];
+ struct list_head *p;
+ FILE *f;
+
+ __list_for_each(p, &devpaths) {
+ struct devpath *dpp = list_entry(p, struct devpath, head);
+
+ if (fill_ofname(fname, sizeof(fname), NULL, dpp->buts_name,
+ cpu))
+ return 1;
+ f = my_fopen(fname, "w+");
+ if (!f)
+ return 1;
+ fclose(f);
+ }
+ return 0;
+}
+
static void start_tracers(void)
{
int cpu, started = 0;
@@ -1900,8 +1920,16 @@ static void start_tracers(void)
size_t alloc_size = CPU_ALLOC_SIZE(max_cpus);
for (cpu = 0; cpu < max_cpus; cpu++) {
- if (!CPU_ISSET_S(cpu, alloc_size, online_cpus))
+ if (!CPU_ISSET_S(cpu, alloc_size, online_cpus)) {
+ /*
+ * Create fake empty output files so that other tools
+ * like blkparse don't have to bother with sparse CPU
+ * number space.
+ */
+ if (create_output_files(cpu))
+ break;
continue;
+ }
if (start_tracer(cpu))
break;
started++;