Whamcloud - gitweb
LU-13676 tools: awk script to find unique backtraces
[fs/lustre-release.git] / contrib / debug_tools / crash-find-unique-traces.awk
1 #!/usr/bin/awk -f
2
3 function add_unique_chain(chain) {
4         for (i = 0; i < unique_nr; i++) {
5                 if (unique[i] == chain) {
6                         return 0
7                 }
8         }
9         unique_pids[unique_nr] = unique_pids[unique_nr] current_pid " "
10         unique[unique_nr++] = chain
11 }
12
13 function dump_chain()
14 {
15         if (collect_chain) {
16                 #print pl_cmdname,pl_pid
17                 add_unique_chain(chain)
18                 chain=""
19                 collect_chain=0
20         }
21 }
22
23 /^PID:/ {
24         traces++
25         dump_chain()
26         collect_chain=1
27         current_pid=$2
28 }
29
30 /#[0-9]* / {
31         tmp=$3
32         #if (start_to_analyze==0)
33         #       next
34         if (collect_chain==0)
35                 next
36         if (index(tmp, "do_syscall_64"))
37                 next
38         if (index(tmp, "ret_from_fork"))
39                 next
40         if (index(tmp, "entry_SYSCALL"))
41                 next
42         #sub("[+]0x[0-9a-f]+[/].*", "", tmp)
43         if (chain=="")
44                 chain=tmp
45         else
46                 chain=chain","tmp
47 }
48
49 /ret_from_fork/ {
50         dump_chain()
51 }
52
53 /entry_SYSCALL/ {
54         dump_chain()
55 }
56
57 END {
58         not_interesting[0]="schedule,ldlm_bl_thread_main,kthread"
59         not_interesting[1]="schedule,ptlrpcd,kthread"
60         not_interesting[2]="schedule,mgc_requeue_thread,kthread"
61         not_interesting[3]="schedule,schedule_timeout,ksocknal_connd,kthread"
62         not_interesting[4]="schedule,ptlrpc_hr_main,kthread"
63         not_interesting[5]="schedule,ksocknal_scheduler"
64         not_interesting[6]="schedule,osp_precreate_thread"
65         not_interesting[7]="schedule,mgs_ir_notify,kthread"
66         not_interesting[8]="schedule,qmt_reba_thread,kthread"
67         not_interesting[9]="schedule,expired_lock_main,kthread"
68         not_interesting[10]="schedule,schedule_timeout,lnet_peer_discovery,kthread"
69         not_interesting[11]="schedule,ping_evictor_main,kthread"
70         not_interesting[12]="schedule,schedule_timeout,qsd_upd_thread,kthread"
71         not_interesting[13]="schedule,ptlrpc_wait_event,ptlrpc_main,kthread"
72         not_interesting[14]="schedule,lnet_sock_accept,lnet_acceptor,kthread"
73         not_interesting[15]="schedule,schedule_timeout,lnet_monitor_thread,kthread"
74         not_interesting[16]="schedule,ofd_inconsistency_verification_main,kthread"
75         not_interesting[17]="schedule,schedule_timeout,ksocknal_reaper,kthread"
76         not_interesting[18]="schedule,kjournald2,kthread"
77         not_interesting[19]="schedule,rescuer_thread,kthread"
78         not_interesting[20]="schedule,oom_reaper,kthread"
79         not_interesting[21]="schedule,worker_thread,kthread"
80         not_interesting[22]="schedule,kthread_worker_fn,kthread"
81         not_interesting[23]="schedule,osp_sync_process_queues,llog_process_thread,llog_process_or_fork,llog_cat_process_cb,llog_process_thread,llog_process_or_fork,llog_cat_process_or_fork,llog_cat_process,osp_sync_thread,kthread"
82         not_interesting[24]="schedule,smpboot_thread_fn,kthread"
83         not_interesting[25]="schedule,schedule_timeout,rcu_gp_kthread,kthread"
84         not_interesting[26]="schedule,rcu_gp_kthread,kthread"
85         not_interesting[27]="schedule,devtmpfsd,kthread"
86         not_interesting[28]="schedule,schedule_timeout,watchdog,kthread"
87         not_interesting[29]="schedule,oom_reaper"
88         not_interesting[30]="schedule,kcompactd,kthread"
89         not_interesting[31]="schedule,schedule_timeout,khugepaged,kthread"
90         not_interesting[32]="schedule,kswapd,kthread"
91         not_interesting[33]="schedule,schedule_hrtimeout_range_clock,do_sys_poll,__se_sys_poll"
92         not_interesting[34]="schedule,schedule_hrtimeout_range_clock,do_select,core_sys_select,kern_select,__x64_sys_select"
93         not_interesting[35]="schedule,schedule_hrtimeout_range_clock,__se_sys_rt_sigtimedwait"
94         not_interesting[36]="schedule,do_wait,kernel_wait4,__se_sys_wait4"
95         not_interesting[37]="schedule,schedule_timeout,wait_for_common,lnet_monitor_thread,kthread"
96         not_interesting[38]="schedule,schedule_hrtimeout_range_clock,ep_poll,do_epoll_wait,__x64_sys_epoll_wait"
97         not_interesting[39]="schedule,kthreadd"
98         not_interesting[40]="schedule,khvcd,kthread"
99         not_interesting[41]="schedule,schedule_timeout,ptlrpcd,kthread"
100         not_interesting[42]="schedule,schedule_timeout,mdt_coordinator,kthread"
101         not_interesting[43]="schedule,distribute_txn_commit_thread,kthread"
102         not_interesting[44]="schedule,lnet_acceptor,kthread"
103         not_interesting[45]="schedule,osp_send_update_thread,kthread"
104         not_interesting[46]="schedule,pipe_wait,pipe_read,__vfs_read,vfs_read,ksys_read"
105         not_interesting[47]="default_idle,do_idle,cpu_startup_entry,start_kernel,secondary_startup_64"
106         not_interesting[48]="default_idle,do_idle,cpu_startup_entry,secondary_startup_64"
107         not_interesting[49]="do_select,core_sys_select,kern_select,__x64_sys_select"
108
109 #not_interesting[]=""
110 #not_interesting[]=""
111 #schedule,kthreadd
112
113         for (i = 0; i < unique_nr; i++) {
114                 dump=1
115                 for (j in not_interesting) {
116                         if (index(unique[i], not_interesting[j])) {
117                                 dump=0
118                                 break
119                         }
120                         if (unique[i]==not_interesting[j]) {
121                                 dump=0
122                                 break
123                         }
124                 }
125                 if (dump)
126                         print unique[i],"PIDs:",unique_pids[i]
127         }
128
129 }
130