From 927e644e606519c1ae6fa7c0ffc3eda42ba4dc24 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Thu, 15 Jan 2015 14:40:12 -0500 Subject: [PATCH] handle special case of sys_sync() Signed-off-by: Julien Desfossez --- LTTngAnalyzes/block.py | 2 +- LTTngAnalyzes/common.py | 5 ++- LTTngAnalyzes/syscalls.py | 3 ++ iotop.py | 82 ++++++++++++++++++++++----------------- 4 files changed, 53 insertions(+), 39 deletions(-) diff --git a/LTTngAnalyzes/block.py b/LTTngAnalyzes/block.py index 581dbb5..c945696 100644 --- a/LTTngAnalyzes/block.py +++ b/LTTngAnalyzes/block.py @@ -114,7 +114,7 @@ class Block(): rq["iorequest"].duration = time_per_sector d.rq_list.append(rq["iorequest"]) if "pid" in rq.keys(): - rq["pid"].blockiorequests.append(rq["iorequest"]) + rq["pid"].iorequests.append(rq["iorequest"]) del d.pending_requests[sector] def dump_orphan_requests(self): diff --git a/LTTngAnalyzes/common.py b/LTTngAnalyzes/common.py index af7c120..62b79fa 100644 --- a/LTTngAnalyzes/common.py +++ b/LTTngAnalyzes/common.py @@ -52,8 +52,9 @@ class Process(): self.allocated_pages = 0 self.freed_pages = 0 self.total_syscalls = 0 - # array of IORequest objects for freq analysis later - self.blockiorequests = [] + # array of IORequest objects for freq analysis later (block and + # syscalls with no FD like sys_sync) + self.iorequests = [] class CPU(): diff --git a/LTTngAnalyzes/syscalls.py b/LTTngAnalyzes/syscalls.py index fb7148c..29896d1 100644 --- a/LTTngAnalyzes/syscalls.py +++ b/LTTngAnalyzes/syscalls.py @@ -545,6 +545,9 @@ class Syscalls(): current_syscall["iorequest"].operation = IORequest.OP_SYNC self.track_rw_latency(name, ret, c, event.timestamp, started, event) + if name in ["sys_sync", "syscall_entry_sync"]: + t = self.tids[c.current_tid] + t.iorequests.append(current_syscall["iorequest"]) self.tids[c.current_tid].current_syscall = {} return ret_string diff --git a/iotop.py b/iotop.py index fd99d15..be1be6a 100755 --- a/iotop.py +++ b/iotop.py @@ -528,47 +528,51 @@ class IOTop(): _max = "%0.03f" % (_max / 1000) print(fmt.format(name, count, _min, avg, _max, stdev)) + def account_syscall_iorequests(self, args, s, iorequests): + for rq in iorequests: + if rq.iotype != IORequest.IO_SYSCALL: + continue + if not self.filter_size(args, rq.size): + continue + if not self.filter_latency(args, rq.duration): + continue + if rq.operation == IORequest.OP_READ: + s.read_count += 1 + s.read_total += rq.duration + s.read_rq.append(rq.duration) + s.all_read.append(rq) + s.read_min, s.read_max = self.iostats_minmax( + rq.duration, s.read_min, s.read_max) + elif rq.operation == IORequest.OP_WRITE: + s.write_count += 1 + s.write_total += rq.duration + s.write_rq.append(rq.duration) + s.all_write.append(rq) + s.write_min, s.write_max = self.iostats_minmax( + rq.duration, s.write_min, s.write_max) + elif rq.operation == IORequest.OP_SYNC: + s.sync_count += 1 + s.sync_total += rq.duration + s.sync_rq.append(rq.duration) + s.all_sync.append(rq) + s.sync_min, s.sync_max = self.iostats_minmax( + rq.duration, s.sync_min, s.sync_max) + elif rq.operation == IORequest.OP_OPEN: + s.open_count += 1 + s.open_total += rq.duration + s.open_rq.append(rq.duration) + s.all_open.append(rq) + s.open_min, s.open_max = self.iostats_minmax( + rq.duration, s.open_min, s.open_max) + def compute_syscalls_latency_stats(self, args): s = Syscalls_stats() for tid in self.state.tids.values(): if not self.filter_process(args, tid): continue + self.account_syscall_iorequests(args, s, tid.iorequests) for fd in tid.fds.values(): - for rq in fd.iorequests: - if rq.iotype != IORequest.IO_SYSCALL: - continue - if not self.filter_size(args, rq.size): - continue - if not self.filter_latency(args, rq.duration): - continue - if rq.operation == IORequest.OP_READ: - s.read_count += 1 - s.read_total += rq.duration - s.read_rq.append(rq.duration) - s.all_read.append(rq) - s.read_min, s.read_max = self.iostats_minmax( - rq.duration, s.read_min, s.read_max) - elif rq.operation == IORequest.OP_WRITE: - s.write_count += 1 - s.write_total += rq.duration - s.write_rq.append(rq.duration) - s.all_write.append(rq) - s.write_min, s.write_max = self.iostats_minmax( - rq.duration, s.write_min, s.write_max) - elif rq.operation == IORequest.OP_SYNC: - s.sync_count += 1 - s.sync_total += rq.duration - s.sync_rq.append(rq.duration) - s.all_sync.append(rq) - s.sync_min, s.sync_max = self.iostats_minmax( - rq.duration, s.sync_min, s.sync_max) - elif rq.operation == IORequest.OP_OPEN: - s.open_count += 1 - s.open_total += rq.duration - s.open_rq.append(rq.duration) - s.all_open.append(rq) - s.open_min, s.open_max = self.iostats_minmax( - rq.duration, s.open_min, s.open_max) + self.account_syscall_iorequests(args, s, fd.iorequests) return s def iostats_output_syscalls(self, args): @@ -643,6 +647,12 @@ class IOTop(): else: extra = "" name = rq.name.replace("syscall_entry_", "").replace("sys_", "") + if rq.fd is None: + filename = "None" + fd = "None" + else: + filename = rq.fd.filename + fd = rq.fd.fd print(fmt.format("[" + ns_to_hour_nsec(rq.begin, args.multi_day, args.gmt) + "," + ns_to_hour_nsec(rq.end, args.multi_day, @@ -651,7 +661,7 @@ class IOTop(): "%0.03f" % (rq.duration/1000), size, rq.proc.comm, rq.proc.pid, extra, - "%s (fd=%d)" % (rq.fd.filename, rq.fd.fd))) + "%s (fd=%s)" % (filename, fd))) count += 1 def iolatency_syscalls_top_output(self, args): -- 2.34.1