summaryrefslogtreecommitdiff
path: root/iotop
diff options
context:
space:
mode:
authorMinchan Kim <minchan@google.com>2018-09-07 12:07:00 +0900
committerSandeep Patil <sspatil@google.com>2019-01-04 14:56:45 -0800
commit4f74f32cea6d8fcf174cf93b28c20bc83149e0c1 (patch)
tree9c74fd044b373dc7152988786935204d92ab974a /iotop
parent9de03e3913cc835d90b8d0b880db0247b2b42914 (diff)
downloadextras-4f74f32cea6d8fcf174cf93b28c20bc83149e0c1.tar.gz
iotop: add major/minor fault stats
Provide major/minor fault stats. It would be helpful to see per-process memory consumption speed. It is also useful to see read IO caused by major fault, which is critical for app latency. Bug: 114325007 Test: iotop -h Test: iotop -m 10 -s faults Change-Id: If9670a4efe76bcd67b9caedb3427b69896ebed17 Signed-off-by: Minchan Kim <minchan@google.com> [Added sorter for major+minor faults] Signed-off-by: Sandeep Patil <sspatil@google.com>
Diffstat (limited to 'iotop')
-rw-r--r--iotop/iotop.cpp27
-rw-r--r--iotop/taskstats.cpp5
-rw-r--r--iotop/taskstats.h6
3 files changed, 29 insertions, 9 deletions
diff --git a/iotop/iotop.cpp b/iotop/iotop.cpp
index a292bcfe..fe476bf5 100644
--- a/iotop/iotop.cpp
+++ b/iotop/iotop.cpp
@@ -48,7 +48,7 @@ static void usage(char* myname) {
" -n Set the number of refreshes before exiting.\n"
" -P Show processes instead of the default threads.\n"
" -s Set the column to sort by:\n"
- " pid, read, write, total, io, swap, sched, mem or delay.\n",
+ " pid, read, write, total, io, swap, faults, sched, mem or delay.\n",
myname);
}
@@ -85,6 +85,7 @@ static Sorter GetSorter(const std::string& field) {
{"total", make_sorter(&TaskStatistics::read_write, true)},
{"io", make_sorter(&TaskStatistics::delay_io, true)},
{"swap", make_sorter(&TaskStatistics::delay_swap, true)},
+ {"faults", make_sorter(&TaskStatistics::faults, true)},
{"sched", make_sorter(&TaskStatistics::delay_sched, true)},
{"mem", make_sorter(&TaskStatistics::delay_mem, true)},
{"delay", make_sorter(&TaskStatistics::delay_total, true)},
@@ -223,18 +224,20 @@ int main(int argc, char* argv[]) {
printf("\n");
}
if (accumulated) {
- printf("%6s %-16s %20s %34s\n", "", "",
- "---- IO (KiB) ----", "----------- delayed on ----------");
+ printf("%6s %-16s %20s %14s %34s\n", "", "",
+ "---- IO (KiB) ----", "--- faults ---", "----------- delayed on ----------");
} else {
- printf("%6s %-16s %20s %34s\n", "", "",
- "--- IO (KiB/s) ---", "----------- delayed on ----------");
+ printf("%6s %-16s %20s %14s %34s\n", "", "",
+ "--- IO (KiB/s) ---", "--- faults ---", "----------- delayed on ----------");
}
- printf("%6s %-16s %6s %6s %6s %-5s %-5s %-5s %-5s %-5s\n",
+ printf("%6s %-16s %6s %6s %6s %6s %6s %-5s %-5s %-5s %-5s %-5s\n",
"PID",
"Command",
"read",
"write",
"total",
+ "major",
+ "minor",
"IO",
"swap",
"sched",
@@ -245,10 +248,14 @@ int main(int argc, char* argv[]) {
uint64_t total_read = 0;
uint64_t total_write = 0;
uint64_t total_read_write = 0;
+ uint64_t total_minflt = 0;
+ uint64_t total_majflt = 0;
for (const TaskStatistics& statistics : stats) {
total_read += statistics.read();
total_write += statistics.write();
total_read_write += statistics.read_write();
+ total_minflt += statistics.minflt();
+ total_majflt += statistics.majflt();
if (n == 0) {
continue;
@@ -256,22 +263,24 @@ int main(int argc, char* argv[]) {
n--;
}
- printf("%6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n",
+ printf("%6d %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %6" PRIu64" %5.2f%% %5.2f%% %5.2f%% %5.2f%% %5.2f%%\n",
statistics.pid(),
statistics.comm().c_str(),
BytesToKB(statistics.read()) / delay_div,
BytesToKB(statistics.write()) / delay_div,
BytesToKB(statistics.read_write()) / delay_div,
+ statistics.majflt(), statistics.minflt(),
TimeToTgidPercent(statistics.delay_io(), delay, statistics),
TimeToTgidPercent(statistics.delay_swap(), delay, statistics),
TimeToTgidPercent(statistics.delay_sched(), delay, statistics),
TimeToTgidPercent(statistics.delay_mem(), delay, statistics),
TimeToTgidPercent(statistics.delay_total(), delay, statistics));
}
- printf("%6s %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 "\n", "", "TOTAL",
+ printf("%6s %-16s %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %6" PRIu64 " %6" PRIu64"\n", "", "TOTAL",
BytesToKB(total_read) / delay_div,
BytesToKB(total_write) / delay_div,
- BytesToKB(total_read_write) / delay_div);
+ BytesToKB(total_read_write) / delay_div,
+ total_majflt / delay_div, total_minflt / delay_div);
second = false;
diff --git a/iotop/taskstats.cpp b/iotop/taskstats.cpp
index d8027572..eff1d4df 100644
--- a/iotop/taskstats.cpp
+++ b/iotop/taskstats.cpp
@@ -194,6 +194,9 @@ TaskStatistics::TaskStatistics(const taskstats& taskstats_stats) {
cpu_time_real_ = taskstats_stats.cpu_run_real_total;
cpu_time_virtual_ = taskstats_stats.cpu_run_virtual_total;
+ majflt_ = taskstats_stats.ac_majflt;
+ minflt_ = taskstats_stats.ac_minflt;
+
read_bytes_ = taskstats_stats.read_bytes;
write_bytes_ = taskstats_stats.write_bytes;
read_write_bytes_ = read_bytes_ + write_bytes_;
@@ -221,6 +224,8 @@ void TaskStatistics::AddPidToTgid(const TaskStatistics& pid_statistics) {
// Store new statistics and return the delta from the old statistics
TaskStatistics TaskStatistics::Update(const TaskStatistics& new_statistics) {
TaskStatistics delta = new_statistics;
+ delta.minflt_ -= minflt_;
+ delta.majflt_ -= majflt_;
delta.cpu_delay_count_ -= cpu_delay_count_;
delta.cpu_delay_ns_ -= cpu_delay_ns_;
delta.block_io_delay_count_ -= block_io_delay_count_;
diff --git a/iotop/taskstats.h b/iotop/taskstats.h
index bbf7e9e2..7aaae10a 100644
--- a/iotop/taskstats.h
+++ b/iotop/taskstats.h
@@ -41,6 +41,9 @@ public:
uint64_t delay_sched() const { return cpu_delay_ns_; }
uint64_t delay_mem() const { return reclaim_delay_ns_; }
uint64_t delay_total() const { return total_delay_ns_; }
+ uint64_t majflt() const { return majflt_; }
+ uint64_t minflt() const { return minflt_; }
+ uint64_t faults() const { return majflt_ + minflt_; }
int threads() const { return threads_; }
void set_pid(pid_t pid) { pid_ = pid; }
@@ -69,6 +72,9 @@ private:
uint64_t cpu_time_real_;
uint64_t cpu_time_virtual_;
+ uint64_t majflt_;
+ uint64_t minflt_;
+
uint64_t read_bytes_;
uint64_t write_bytes_;
uint64_t read_write_bytes_;