From 2bf3ff3dfc335dd140f71a57b90fcbbf9392c52f Mon Sep 17 00:00:00 2001 From: Sasha Goldshtein Date: Wed, 8 Feb 2017 23:25:00 -0500 Subject: [PATCH] stacksnoop: Migrate to new symbols API and remove addresses --- tools/old/stacksnoop.py | 5 +--- tools/stacksnoop.py | 4 +-- tools/stacksnoop_example.txt | 68 ++++++++++++++++++++++---------------------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/tools/old/stacksnoop.py b/tools/old/stacksnoop.py index 3bf4732..ae89468 100755 --- a/tools/old/stacksnoop.py +++ b/tools/old/stacksnoop.py @@ -119,10 +119,7 @@ while 1: (task, pid, cpu, flags, ts, msg) = b.trace_fields() if msg != "": (reg, addr) = msg.split(" ") - if offset: - ip = b.ksymaddr(int(addr, 16)) - else: - ip = b.ksym(int(addr, 16)) + ip = b.ksym(int(addr, 16), show_address=offset) msg = msg + " " + ip if verbose: print("%-18.9f %-12.12s %-6d %-3d %s" % (ts, task, pid, cpu, msg)) diff --git a/tools/stacksnoop.py b/tools/stacksnoop.py index 1eefc0a..52be79b 100755 --- a/tools/stacksnoop.py +++ b/tools/stacksnoop.py @@ -120,8 +120,8 @@ def print_event(cpu, data, size): print("%-18.9f %s" % (ts, function)) for addr in stack_traces.walk(event.stack_id): - sym = b.ksymaddr(addr) if offset else b.ksym(addr) - print("\t%016x %s" % (addr, sym)) + sym = b.ksym(addr, show_address=offset) + print("\t%s" % sym) print() diff --git a/tools/stacksnoop_example.txt b/tools/stacksnoop_example.txt index 377057b..76784fd 100644 --- a/tools/stacksnoop_example.txt +++ b/tools/stacksnoop_example.txt @@ -8,12 +8,12 @@ to see how they were invoked. For example, tracing the submit_bio() call: # ./stacksnoop submit_bio TIME(s) SYSCALL 3592.838736000 submit_bio - ffffffff813bd961 submit_bio - ffffffff81257c12 submit_bh - ffffffff81301948 jbd2_journal_commit_transaction - ffffffff8130653a kjournald2 - ffffffff810a2df8 kthread - ffffffff8183a122 ret_from_fork + submit_bio + submit_bh + jbd2_journal_commit_transaction + kjournald2 + kthread + ret_from_fork This shows that submit_bio() was called by submit_bh(), which was called by jbd2_journal_commit_transaction(), and so on. @@ -28,12 +28,12 @@ The -v option includes more fields, including the on-CPU process (COMM and PID): # ./stacksnoop -v submit_bio TIME(s) COMM PID CPU SYSCALL 3734.855027000 jbd2/dm-0-8 313 0 submit_bio - ffffffff813bd961 submit_bio - ffffffff81257c12 submit_bh - ffffffff81301948 jbd2_journal_commit_transaction - ffffffff8130653a kjournald2 - ffffffff810a2df8 kthread - ffffffff8183a122 ret_from_fork + submit_bio + submit_bh + jbd2_journal_commit_transaction + kjournald2 + kthread + ret_from_fork This identifies the application issuing the sync syscall: the jbd2 process (COMM column). @@ -45,30 +45,30 @@ process: # ./stacksnoop -v second_overflow TIME(s) COMM PID CPU SYSCALL 3837.526433000 0 1 second_overflow - ffffffff810fac41 second_overflow - ffffffff81102320 tick_do_update_jiffies64 - ffffffff81102bf0 tick_irq_enter - ffffffff810882ac irq_enter - ffffffff8183c7df smp_apic_timer_interrupt - ffffffff8183aae2 apic_timer_interrupt - ffffffff81038f9e default_idle - ffffffff8103979f arch_cpu_idle - ffffffff810c69da default_idle_call - ffffffff810c6cd7 cpu_startup_entry - ffffffff81051cbe start_secondary + second_overflow + tick_do_update_jiffies64 + tick_irq_enter + irq_enter + smp_apic_timer_interrupt + apic_timer_interrupt + default_idle + arch_cpu_idle + default_idle_call + cpu_startup_entry + start_secondary 3838.526953000 0 1 second_overflow - ffffffff810fac41 second_overflow - ffffffff81102320 tick_do_update_jiffies64 - ffffffff81102bf0 tick_irq_enter - ffffffff810882ac irq_enter - ffffffff8183c7df smp_apic_timer_interrupt - ffffffff8183aae2 apic_timer_interrupt - ffffffff81038f9e default_idle - ffffffff8103979f arch_cpu_idle - ffffffff810c69da default_idle_call - ffffffff810c6cd7 cpu_startup_entry - ffffffff81051cbe start_secondary + second_overflow + tick_do_update_jiffies64 + tick_irq_enter + irq_enter + smp_apic_timer_interrupt + apic_timer_interrupt + default_idle + arch_cpu_idle + default_idle_call + cpu_startup_entry + start_secondary This fires every second (see TIME(s)), and is from tick_do_update_jiffies64(). -- 2.7.4