]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/trace/events/signal.h
Merge branch 'perf/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/acme...
[mirror_ubuntu-bionic-kernel.git] / include / trace / events / signal.h
CommitLineData
d1eb650f
MH
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM signal
3
4#if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_SIGNAL_H
6
7#include <linux/signal.h>
8#include <linux/sched.h>
9#include <linux/tracepoint.h>
10
11#define TP_STORE_SIGINFO(__entry, info) \
12 do { \
13 if (info == SEND_SIG_NOINFO) { \
14 __entry->errno = 0; \
15 __entry->code = SI_USER; \
16 } else if (info == SEND_SIG_PRIV) { \
17 __entry->errno = 0; \
18 __entry->code = SI_KERNEL; \
19 } else { \
20 __entry->errno = info->si_errno; \
21 __entry->code = info->si_code; \
22 } \
23 } while (0)
24
25/**
26 * signal_generate - called when a signal is generated
27 * @sig: signal number
28 * @info: pointer to struct siginfo
29 * @task: pointer to struct task_struct
30 *
31 * Current process sends a 'sig' signal to 'task' process with
32 * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
33 * 'info' is not a pointer and you can't access its field. Instead,
34 * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
35 * means that si_code is SI_KERNEL.
36 */
37TRACE_EVENT(signal_generate,
38
39 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
40
41 TP_ARGS(sig, info, task),
42
43 TP_STRUCT__entry(
44 __field( int, sig )
45 __field( int, errno )
46 __field( int, code )
47 __array( char, comm, TASK_COMM_LEN )
48 __field( pid_t, pid )
49 ),
50
51 TP_fast_assign(
52 __entry->sig = sig;
53 TP_STORE_SIGINFO(__entry, info);
54 memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
55 __entry->pid = task->pid;
56 ),
57
58 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d",
59 __entry->sig, __entry->errno, __entry->code,
60 __entry->comm, __entry->pid)
61);
62
f9d4257e
MH
63/**
64 * signal_deliver - called when a signal is delivered
65 * @sig: signal number
66 * @info: pointer to struct siginfo
67 * @ka: pointer to struct k_sigaction
68 *
69 * A 'sig' signal is delivered to current process with 'info' siginfo,
70 * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
71 * SIG_DFL.
72 * Note that some signals reported by signal_generate tracepoint can be
73 * lost, ignored or modified (by debugger) before hitting this tracepoint.
74 * This means, this can show which signals are actually delivered, but
75 * matching generated signals and delivered signals may not be correct.
76 */
77TRACE_EVENT(signal_deliver,
78
79 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
80
81 TP_ARGS(sig, info, ka),
82
83 TP_STRUCT__entry(
84 __field( int, sig )
85 __field( int, errno )
86 __field( int, code )
87 __field( unsigned long, sa_handler )
88 __field( unsigned long, sa_flags )
89 ),
90
91 TP_fast_assign(
92 __entry->sig = sig;
93 TP_STORE_SIGINFO(__entry, info);
94 __entry->sa_handler = (unsigned long)ka->sa.sa_handler;
95 __entry->sa_flags = ka->sa.sa_flags;
96 ),
97
98 TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
99 __entry->sig, __entry->errno, __entry->code,
100 __entry->sa_handler, __entry->sa_flags)
101);
ba005e1f 102
4bdde044 103DECLARE_EVENT_CLASS(signal_queue_overflow,
ba005e1f
MH
104
105 TP_PROTO(int sig, int group, struct siginfo *info),
106
107 TP_ARGS(sig, group, info),
108
109 TP_STRUCT__entry(
110 __field( int, sig )
111 __field( int, group )
112 __field( int, errno )
113 __field( int, code )
114 ),
115
116 TP_fast_assign(
117 __entry->sig = sig;
118 __entry->group = group;
119 TP_STORE_SIGINFO(__entry, info);
120 ),
121
122 TP_printk("sig=%d group=%d errno=%d code=%d",
123 __entry->sig, __entry->group, __entry->errno, __entry->code)
124);
125
4bdde044
LZ
126/**
127 * signal_overflow_fail - called when signal queue is overflow
128 * @sig: signal number
129 * @group: signal to process group or not (bool)
130 * @info: pointer to struct siginfo
131 *
132 * Kernel fails to generate 'sig' signal with 'info' siginfo, because
133 * siginfo queue is overflow, and the signal is dropped.
134 * 'group' is not 0 if the signal will be sent to a process group.
135 * 'sig' is always one of RT signals.
136 */
137DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,
138
139 TP_PROTO(int sig, int group, struct siginfo *info),
140
141 TP_ARGS(sig, group, info)
142);
143
ba005e1f
MH
144/**
145 * signal_lose_info - called when siginfo is lost
146 * @sig: signal number
147 * @group: signal to process group or not (bool)
148 * @info: pointer to struct siginfo
149 *
150 * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
151 * queue is overflow.
152 * 'group' is not 0 if the signal will be sent to a process group.
153 * 'sig' is always one of non-RT signals.
154 */
4bdde044 155DEFINE_EVENT(signal_queue_overflow, signal_lose_info,
ba005e1f
MH
156
157 TP_PROTO(int sig, int group, struct siginfo *info),
158
4bdde044 159 TP_ARGS(sig, group, info)
ba005e1f 160);
4bdde044 161
d1eb650f
MH
162#endif /* _TRACE_SIGNAL_H */
163
164/* This part must be outside protection */
165#include <trace/define_trace.h>