handle special case of sys_sync()
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 15 Jan 2015 19:40:12 +0000 (14:40 -0500)
committerJulien Desfossez <jdesfossez@efficios.com>
Thu, 15 Jan 2015 19:40:12 +0000 (14:40 -0500)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
LTTngAnalyzes/block.py
LTTngAnalyzes/common.py
LTTngAnalyzes/syscalls.py
iotop.py

index 581dbb59d95169cc070169738c1f2405545b08d8..c9456968cc34d6fbbe3bc6176707d7f782388008 100644 (file)
@@ -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):
index af7c120376fce3ef86e02beb4945c5f6bd093339..62b79fa867735c11fe86f561fbbf5089f711e38b 100644 (file)
@@ -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():
index fb7148c4f65fd75bb78c9360d529f6658476cc7b..29896d12f5ade07ff26ac2b56d6d73bde67a3b71 100644 (file)
@@ -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
 
index fd99d1582add24053738fbd55a70ca29b77a71b7..be1be6a0e61e457bed095e6410b2fd1a1d8692de 100755 (executable)
--- 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):
This page took 0.028363 seconds and 5 git commands to generate.