summaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/trace.c
blob: 8322e8352777ecc45d8e7196a6def9378c696a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#include <asm/trace/irq_vectors.h>
#include <linux/trace.h>

#if defined(CONFIG_OSNOISE_TRACER) && defined(CONFIG_X86_LOCAL_APIC)
/*
 * trace_intel_irq_entry - record intel specific IRQ entry
 */
static void trace_intel_irq_entry(void *data, int vector)
{
	osnoise_trace_irq_entry(vector);
}

/*
 * trace_intel_irq_exit - record intel specific IRQ exit
 */
static void trace_intel_irq_exit(void *data, int vector)
{
	char *vector_desc = (char *) data;

	osnoise_trace_irq_exit(vector, vector_desc);
}

/*
 * register_intel_irq_tp - Register intel specific IRQ entry tracepoints
 */
int osnoise_arch_register(void)
{
	int ret;

	ret = register_trace_local_timer_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_err;

	ret = register_trace_local_timer_exit(trace_intel_irq_exit, "local_timer");
	if (ret)
		goto out_timer_entry;

#ifdef CONFIG_X86_THERMAL_VECTOR
	ret = register_trace_thermal_apic_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_timer_exit;

	ret = register_trace_thermal_apic_exit(trace_intel_irq_exit, "thermal_apic");
	if (ret)
		goto out_thermal_entry;
#endif /* CONFIG_X86_THERMAL_VECTOR */

#ifdef CONFIG_X86_MCE_AMD
	ret = register_trace_deferred_error_apic_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_thermal_exit;

	ret = register_trace_deferred_error_apic_exit(trace_intel_irq_exit, "deferred_error");
	if (ret)
		goto out_deferred_entry;
#endif

#ifdef CONFIG_X86_MCE_THRESHOLD
	ret = register_trace_threshold_apic_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_deferred_exit;

	ret = register_trace_threshold_apic_exit(trace_intel_irq_exit, "threshold_apic");
	if (ret)
		goto out_threshold_entry;
#endif /* CONFIG_X86_MCE_THRESHOLD */

#ifdef CONFIG_SMP
	ret = register_trace_call_function_single_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_threshold_exit;

	ret = register_trace_call_function_single_exit(trace_intel_irq_exit,
						       "call_function_single");
	if (ret)
		goto out_call_function_single_entry;

	ret = register_trace_call_function_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_call_function_single_exit;

	ret = register_trace_call_function_exit(trace_intel_irq_exit, "call_function");
	if (ret)
		goto out_call_function_entry;

	ret = register_trace_reschedule_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_call_function_exit;

	ret = register_trace_reschedule_exit(trace_intel_irq_exit, "reschedule");
	if (ret)
		goto out_reschedule_entry;
#endif /* CONFIG_SMP */

#ifdef CONFIG_IRQ_WORK
	ret = register_trace_irq_work_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_reschedule_exit;

	ret = register_trace_irq_work_exit(trace_intel_irq_exit, "irq_work");
	if (ret)
		goto out_irq_work_entry;
#endif

	ret = register_trace_x86_platform_ipi_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_irq_work_exit;

	ret = register_trace_x86_platform_ipi_exit(trace_intel_irq_exit, "x86_platform_ipi");
	if (ret)
		goto out_x86_ipi_entry;

	ret = register_trace_error_apic_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_x86_ipi_exit;

	ret = register_trace_error_apic_exit(trace_intel_irq_exit, "error_apic");
	if (ret)
		goto out_error_apic_entry;

	ret = register_trace_spurious_apic_entry(trace_intel_irq_entry, NULL);
	if (ret)
		goto out_error_apic_exit;

	ret = register_trace_spurious_apic_exit(trace_intel_irq_exit, "spurious_apic");
	if (ret)
		goto out_spurious_apic_entry;

	return 0;

out_spurious_apic_entry:
	unregister_trace_spurious_apic_entry(trace_intel_irq_entry, NULL);
out_error_apic_exit:
	unregister_trace_error_apic_exit(trace_intel_irq_exit, "error_apic");
out_error_apic_entry:
	unregister_trace_error_apic_entry(trace_intel_irq_entry, NULL);
out_x86_ipi_exit:
	unregister_trace_x86_platform_ipi_exit(trace_intel_irq_exit, "x86_platform_ipi");
out_x86_ipi_entry:
	unregister_trace_x86_platform_ipi_entry(trace_intel_irq_entry, NULL);
out_irq_work_exit:

#ifdef CONFIG_IRQ_WORK
	unregister_trace_irq_work_exit(trace_intel_irq_exit, "irq_work");
out_irq_work_entry:
	unregister_trace_irq_work_entry(trace_intel_irq_entry, NULL);
out_reschedule_exit:
#endif

#ifdef CONFIG_SMP
	unregister_trace_reschedule_exit(trace_intel_irq_exit, "reschedule");
out_reschedule_entry:
	unregister_trace_reschedule_entry(trace_intel_irq_entry, NULL);
out_call_function_exit:
	unregister_trace_call_function_exit(trace_intel_irq_exit, "call_function");
out_call_function_entry:
	unregister_trace_call_function_entry(trace_intel_irq_entry, NULL);
out_call_function_single_exit:
	unregister_trace_call_function_single_exit(trace_intel_irq_exit, "call_function_single");
out_call_function_single_entry:
	unregister_trace_call_function_single_entry(trace_intel_irq_entry, NULL);
out_threshold_exit:
#endif

#ifdef CONFIG_X86_MCE_THRESHOLD
	unregister_trace_threshold_apic_exit(trace_intel_irq_exit, "threshold_apic");
out_threshold_entry:
	unregister_trace_threshold_apic_entry(trace_intel_irq_entry, NULL);
out_deferred_exit:
#endif

#ifdef CONFIG_X86_MCE_AMD
	unregister_trace_deferred_error_apic_exit(trace_intel_irq_exit, "deferred_error");
out_deferred_entry:
	unregister_trace_deferred_error_apic_entry(trace_intel_irq_entry, NULL);
out_thermal_exit:
#endif /* CONFIG_X86_MCE_AMD */

#ifdef CONFIG_X86_THERMAL_VECTOR
	unregister_trace_thermal_apic_exit(trace_intel_irq_exit, "thermal_apic");
out_thermal_entry:
	unregister_trace_thermal_apic_entry(trace_intel_irq_entry, NULL);
out_timer_exit:
#endif /* CONFIG_X86_THERMAL_VECTOR */

	unregister_trace_local_timer_exit(trace_intel_irq_exit, "local_timer");
out_timer_entry:
	unregister_trace_local_timer_entry(trace_intel_irq_entry, NULL);
out_err:
	return -EINVAL;
}

void osnoise_arch_unregister(void)
{
	unregister_trace_spurious_apic_exit(trace_intel_irq_exit, "spurious_apic");
	unregister_trace_spurious_apic_entry(trace_intel_irq_entry, NULL);
	unregister_trace_error_apic_exit(trace_intel_irq_exit, "error_apic");
	unregister_trace_error_apic_entry(trace_intel_irq_entry, NULL);
	unregister_trace_x86_platform_ipi_exit(trace_intel_irq_exit, "x86_platform_ipi");
	unregister_trace_x86_platform_ipi_entry(trace_intel_irq_entry, NULL);

#ifdef CONFIG_IRQ_WORK
	unregister_trace_irq_work_exit(trace_intel_irq_exit, "irq_work");
	unregister_trace_irq_work_entry(trace_intel_irq_entry, NULL);
#endif

#ifdef CONFIG_SMP
	unregister_trace_reschedule_exit(trace_intel_irq_exit, "reschedule");
	unregister_trace_reschedule_entry(trace_intel_irq_entry, NULL);
	unregister_trace_call_function_exit(trace_intel_irq_exit, "call_function");
	unregister_trace_call_function_entry(trace_intel_irq_entry, NULL);
	unregister_trace_call_function_single_exit(trace_intel_irq_exit, "call_function_single");
	unregister_trace_call_function_single_entry(trace_intel_irq_entry, NULL);
#endif

#ifdef CONFIG_X86_MCE_THRESHOLD
	unregister_trace_threshold_apic_exit(trace_intel_irq_exit, "threshold_apic");
	unregister_trace_threshold_apic_entry(trace_intel_irq_entry, NULL);
#endif

#ifdef CONFIG_X86_MCE_AMD
	unregister_trace_deferred_error_apic_exit(trace_intel_irq_exit, "deferred_error");
	unregister_trace_deferred_error_apic_entry(trace_intel_irq_entry, NULL);
#endif

#ifdef CONFIG_X86_THERMAL_VECTOR
	unregister_trace_thermal_apic_exit(trace_intel_irq_exit, "thermal_apic");
	unregister_trace_thermal_apic_entry(trace_intel_irq_entry, NULL);
#endif /* CONFIG_X86_THERMAL_VECTOR */

	unregister_trace_local_timer_exit(trace_intel_irq_exit, "local_timer");
	unregister_trace_local_timer_entry(trace_intel_irq_entry, NULL);
}
#endif /* CONFIG_OSNOISE_TRACER && CONFIG_X86_LOCAL_APIC */