diff options
author | 2017-06-12 11:28:37 -0700 | |
---|---|---|
committer | 2017-06-13 16:01:47 +0000 | |
commit | 1dc1ef5af577d0cacc7b86a83d243d9750b0dd6d (patch) | |
tree | c269ff8f9af3ab6f4ddc110c07bb5deb6b55358d | |
parent | 516e0c3738c5264b966011cb968bf4f3031df9fc (diff) |
dumpstate: Better format for dumping block stat
After CL the format looks like:
------ BLOCK STAT (/sys/block/mmcblk0) ------
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/stat : 11299 16093 1262592 31863 3895 2968 63232 6463 0 10260 38243
/mmcblk0/stat : perf(ios) rd: 75622KB/s(1322/s) wr: 18671KB/s(2246/s) q: 4
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p1/stat : 37 29 66 6 0 0 0 0 0 6 6
/mmcblk0/mmcblk0p1/stat : perf(ios) rd: 5632KB/s(6167/s) q: 1
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p24/stat : 12 32 346 0 1 0 8 0 0 0 0
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p26/stat : 0 0 0 0 3 381 3072 296 0 100 296
/mmcblk0/mmcblk0p26/stat : perf(ios) rd: 0KB/s(0/s) wr: 15729KB/s(30/s) q: 3
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p30/stat : 11 33 352 23 0 0 0 0 0 23 23
/mmcblk0/mmcblk0p30/stat : perf(ios) rd: 7836KB/s(478/s) q: 1
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p38/stat : 1 3 32 0 0 0 0 0 0 0 0
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p39/stat : 816 1072 47000 3460 0 0 0 0 0 273 3460
/mmcblk0/mmcblk0p39/stat : perf(ios) rd: 88147KB/s(2989/s) q: 13
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p40/stat : 17 13 228 0 4 0 32 3 0 3 3
/mmcblk0/mmcblk0p40/stat : perf(ios) rd: 0KB/s(0/s) wr: 5461KB/s(1333/s) q: 1
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p41/stat : 4831 14319 453376 17336 0 0 0 0 0 3273 17330
/mmcblk0/mmcblk0p41/stat : perf(ios) rd: 70898KB/s(1476/s) q: 5
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p42/stat : 8 124 1056 3 0 0 0 0 0 3 3
/mmcblk0/mmcblk0p42/stat : perf(ios) rd: 180224KB/s(2667/s) q: 1
Block-Dev : R-IOs R-merg R-sect R-wait W-IOs W-merg W-sect W-wait in-fli activ T-wait
/mmcblk0/mmcblk0p45/stat : 5560 468 760088 11033 3046 2587 60120 5490 0 6840 16453
Bug: 62319771
Test: adb bugreport and check the result
Change-Id: I9464c4758f03479d433bdb7a907dd4953f226e1e
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index d3138cd037..95dc8ddef6 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -656,8 +656,10 @@ static int dump_stat_from_fd(const char *title __unused, const char *path, int f if (!strncmp(path, BLK_DEV_SYS_DIR, sizeof(BLK_DEV_SYS_DIR) - 1)) { path += sizeof(BLK_DEV_SYS_DIR) - 1; } - printf("Block-Dev:\tR-IOs\tR-merg\tR-sect\tR-wait\tW-IOs\tW-merg\tW-sect\tW-wait" - "\tin-fli\tactiv\tT-wait\n%s:\t%s\n", path, buffer); + + printf("%-30s:%9s%9s%9s%9s%9s%9s%9s%9s%9s%9s%9s\n%-30s:\t%s\n", "Block-Dev", + "R-IOs", "R-merg", "R-sect", "R-wait", "W-IOs", "W-merg", "W-sect", + "W-wait", "in-fli", "activ", "T-wait", path, buffer); free(buffer); if (fields[__STAT_IO_TICKS]) { @@ -694,9 +696,9 @@ static int dump_stat_from_fd(const char *title __unused, const char *path, int f / fields[__STAT_IO_TICKS]; if (!write_perf && !write_ios) { - printf("%s: perf(ios) rd: %luKB/s(%lu/s) q: %u\n", path, read_perf, read_ios, queue); + printf("%-30s: perf(ios) rd: %luKB/s(%lu/s) q: %u\n", path, read_perf, read_ios, queue); } else { - printf("%s: perf(ios) rd: %luKB/s(%lu/s) wr: %luKB/s(%lu/s) q: %u\n", path, read_perf, + printf("%-30s: perf(ios) rd: %luKB/s(%lu/s) wr: %luKB/s(%lu/s) q: %u\n", path, read_perf, read_ios, write_perf, write_ios, queue); } @@ -1063,16 +1065,16 @@ static void AddAnrTraceFiles() { static void DumpBlockStatFiles() { DurationReporter duration_reporter("DUMP BLOCK STAT"); - struct dirent *d; - DIR *dirp = opendir(BLK_DEV_SYS_DIR); - if (dirp == NULL) { + std::unique_ptr<DIR, std::function<int(DIR*)>> dirptr(opendir(BLK_DEV_SYS_DIR), closedir); + + if (dirptr == nullptr) { MYLOGE("Failed to open %s: %s\n", BLK_DEV_SYS_DIR, strerror(errno)); return; } printf("------ DUMP BLOCK STAT ------\n\n"); - while ((d = readdir(dirp))) { + while (struct dirent *d = readdir(dirptr.get())) { if ((d->d_name[0] == '.') && (((d->d_name[1] == '.') && (d->d_name[2] == '\0')) || (d->d_name[1] == '\0'))) { @@ -1084,8 +1086,7 @@ static void DumpBlockStatFiles() { dump_files("", new_path.c_str(), skip_not_stat, dump_stat_from_fd); printf("\n"); } - closedir(dirp); - return; + return; } static void dumpstate() { DurationReporter duration_reporter("DUMPSTATE"); |