Xenomai  3.1-devel
cobalt-core.h
1 /*
2  * Copyright (C) 2014 Jan Kiszka <jan.kiszka@siemens.com>.
3  * Copyright (C) 2014 Philippe Gerum <rpm@xenomai.org>.
4  *
5  * Xenomai is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 2 of the License,
8  * or (at your option) any later version.
9  *
10  * Xenomai is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Xenomai; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #undef TRACE_SYSTEM
21 #define TRACE_SYSTEM cobalt_core
22 
23 #if !defined(_TRACE_COBALT_CORE_H) || defined(TRACE_HEADER_MULTI_READ)
24 #define _TRACE_COBALT_CORE_H
25 
26 #include <linux/tracepoint.h>
27 
28 DECLARE_EVENT_CLASS(thread_event,
29  TP_PROTO(struct xnthread *thread),
30  TP_ARGS(thread),
31 
32  TP_STRUCT__entry(
33  __field(pid_t, pid)
34  __field(unsigned long, state)
35  __field(unsigned long, info)
36  ),
37 
38  TP_fast_assign(
39  __entry->state = thread->state;
40  __entry->info = thread->info;
41  __entry->pid = xnthread_host_pid(thread);
42  ),
43 
44  TP_printk("pid=%d state=0x%lx info=0x%lx",
45  __entry->pid, __entry->state, __entry->info)
46 );
47 
48 DECLARE_EVENT_CLASS(curr_thread_event,
49  TP_PROTO(struct xnthread *thread),
50  TP_ARGS(thread),
51 
52  TP_STRUCT__entry(
53  __field(struct xnthread *, thread)
54  __field(unsigned long, state)
55  __field(unsigned long, info)
56  ),
57 
58  TP_fast_assign(
59  __entry->state = thread->state;
60  __entry->info = thread->info;
61  ),
62 
63  TP_printk("state=0x%lx info=0x%lx",
64  __entry->state, __entry->info)
65 );
66 
67 DECLARE_EVENT_CLASS(synch_wait_event,
68  TP_PROTO(struct xnsynch *synch),
69  TP_ARGS(synch),
70 
71  TP_STRUCT__entry(
72  __field(struct xnsynch *, synch)
73  ),
74 
75  TP_fast_assign(
76  __entry->synch = synch;
77  ),
78 
79  TP_printk("synch=%p", __entry->synch)
80 );
81 
82 DECLARE_EVENT_CLASS(synch_post_event,
83  TP_PROTO(struct xnsynch *synch),
84  TP_ARGS(synch),
85 
86  TP_STRUCT__entry(
87  __field(struct xnsynch *, synch)
88  ),
89 
90  TP_fast_assign(
91  __entry->synch = synch;
92  ),
93 
94  TP_printk("synch=%p", __entry->synch)
95 );
96 
97 DECLARE_EVENT_CLASS(irq_event,
98  TP_PROTO(unsigned int irq),
99  TP_ARGS(irq),
100 
101  TP_STRUCT__entry(
102  __field(unsigned int, irq)
103  ),
104 
105  TP_fast_assign(
106  __entry->irq = irq;
107  ),
108 
109  TP_printk("irq=%u", __entry->irq)
110 );
111 
112 DECLARE_EVENT_CLASS(clock_event,
113  TP_PROTO(unsigned int irq),
114  TP_ARGS(irq),
115 
116  TP_STRUCT__entry(
117  __field(unsigned int, irq)
118  ),
119 
120  TP_fast_assign(
121  __entry->irq = irq;
122  ),
123 
124  TP_printk("clock_irq=%u", __entry->irq)
125 );
126 
127 DECLARE_EVENT_CLASS(timer_event,
128  TP_PROTO(struct xntimer *timer),
129  TP_ARGS(timer),
130 
131  TP_STRUCT__entry(
132  __field(struct xntimer *, timer)
133  ),
134 
135  TP_fast_assign(
136  __entry->timer = timer;
137  ),
138 
139  TP_printk("timer=%p", __entry->timer)
140 );
141 
142 TRACE_EVENT(cobalt_schedule,
143  TP_PROTO(struct xnsched *sched),
144  TP_ARGS(sched),
145 
146  TP_STRUCT__entry(
147  __field(unsigned long, status)
148  ),
149 
150  TP_fast_assign(
151  __entry->status = sched->status;
152  ),
153 
154  TP_printk("status=0x%lx", __entry->status)
155 );
156 
157 TRACE_EVENT(cobalt_schedule_remote,
158  TP_PROTO(struct xnsched *sched),
159  TP_ARGS(sched),
160 
161  TP_STRUCT__entry(
162  __field(unsigned long, status)
163  ),
164 
165  TP_fast_assign(
166  __entry->status = sched->status;
167  ),
168 
169  TP_printk("status=0x%lx", __entry->status)
170 );
171 
172 TRACE_EVENT(cobalt_switch_context,
173  TP_PROTO(struct xnthread *prev, struct xnthread *next),
174  TP_ARGS(prev, next),
175 
176  TP_STRUCT__entry(
177  __field(struct xnthread *, prev)
178  __string(prev_name, prev->name)
179  __field(pid_t, prev_pid)
180  __field(int, prev_prio)
181  __field(unsigned long, prev_state)
182  __field(struct xnthread *, next)
183  __string(next_name, next->name)
184  __field(pid_t, next_pid)
185  __field(int, next_prio)
186  ),
187 
188  TP_fast_assign(
189  __entry->prev = prev;
190  __assign_str(prev_name, prev->name);
191  __entry->prev_pid = xnthread_host_pid(prev);
192  __entry->prev_prio = xnthread_current_priority(prev);
193  __entry->prev_state = prev->state;
194  __entry->next = next;
195  __assign_str(next_name, next->name);
196  __entry->next_pid = xnthread_host_pid(next);
197  __entry->next_prio = xnthread_current_priority(next);
198  ),
199 
200  TP_printk("prev_name=%s prev_pid=%d prev_prio=%d prev_state=0x%lx ==> next_name=%s next_pid=%d next_prio=%d",
201  __get_str(prev_name), __entry->prev_pid,
202  __entry->prev_prio, __entry->prev_state,
203  __get_str(next_name), __entry->next_pid, __entry->next_prio)
204 );
205 
206 TRACE_EVENT(cobalt_thread_init,
207  TP_PROTO(struct xnthread *thread,
208  const struct xnthread_init_attr *attr,
209  struct xnsched_class *sched_class),
210  TP_ARGS(thread, attr, sched_class),
211 
212  TP_STRUCT__entry(
213  __field(struct xnthread *, thread)
214  __string(thread_name, thread->name)
215  __string(class_name, sched_class->name)
216  __field(unsigned long, flags)
217  __field(int, cprio)
218  ),
219 
220  TP_fast_assign(
221  __entry->thread = thread;
222  __assign_str(thread_name, thread->name);
223  __entry->flags = attr->flags;
224  __assign_str(class_name, sched_class->name);
225  __entry->cprio = thread->cprio;
226  ),
227 
228  TP_printk("thread=%p name=%s flags=0x%lx class=%s prio=%d",
229  __entry->thread, __get_str(thread_name), __entry->flags,
230  __get_str(class_name), __entry->cprio)
231 );
232 
233 TRACE_EVENT(cobalt_thread_suspend,
234  TP_PROTO(struct xnthread *thread, unsigned long mask, xnticks_t timeout,
235  xntmode_t timeout_mode, struct xnsynch *wchan),
236  TP_ARGS(thread, mask, timeout, timeout_mode, wchan),
237 
238  TP_STRUCT__entry(
239  __field(pid_t, pid)
240  __field(unsigned long, mask)
241  __field(xnticks_t, timeout)
242  __field(xntmode_t, timeout_mode)
243  __field(struct xnsynch *, wchan)
244  ),
245 
246  TP_fast_assign(
247  __entry->pid = xnthread_host_pid(thread);
248  __entry->mask = mask;
249  __entry->timeout = timeout;
250  __entry->timeout_mode = timeout_mode;
251  __entry->wchan = wchan;
252  ),
253 
254  TP_printk("pid=%d mask=0x%lx timeout=%Lu timeout_mode=%d wchan=%p",
255  __entry->pid, __entry->mask,
256  __entry->timeout, __entry->timeout_mode, __entry->wchan)
257 );
258 
259 TRACE_EVENT(cobalt_thread_resume,
260  TP_PROTO(struct xnthread *thread, unsigned long mask),
261  TP_ARGS(thread, mask),
262 
263  TP_STRUCT__entry(
264  __string(name, thread->name)
265  __field(pid_t, pid)
266  __field(unsigned long, mask)
267  ),
268 
269  TP_fast_assign(
270  __assign_str(name, thread->name);
271  __entry->pid = xnthread_host_pid(thread);
272  __entry->mask = mask;
273  ),
274 
275  TP_printk("name=%s pid=%d mask=0x%lx",
276  __get_str(name), __entry->pid, __entry->mask)
277 );
278 
279 TRACE_EVENT(cobalt_thread_fault,
280  TP_PROTO(struct ipipe_trap_data *td),
281  TP_ARGS(td),
282 
283  TP_STRUCT__entry(
284  __field(void *, ip)
285  __field(unsigned int, type)
286  ),
287 
288  TP_fast_assign(
289  __entry->ip = (void *)xnarch_fault_pc(td);
290  __entry->type = xnarch_fault_trap(td);
291  ),
292 
293  TP_printk("ip=%p type=%x",
294  __entry->ip, __entry->type)
295 );
296 
297 TRACE_EVENT(cobalt_thread_set_current_prio,
298  TP_PROTO(struct xnthread *thread),
299  TP_ARGS(thread),
300 
301  TP_STRUCT__entry(
302  __field(struct xnthread *, thread)
303  __field(pid_t, pid)
304  __field(int, cprio)
305  ),
306 
307  TP_fast_assign(
308  __entry->thread = thread;
309  __entry->pid = xnthread_host_pid(thread);
310  __entry->cprio = xnthread_current_priority(thread);
311  ),
312 
313  TP_printk("thread=%p pid=%d prio=%d",
314  __entry->thread, __entry->pid, __entry->cprio)
315 );
316 
317 DEFINE_EVENT(thread_event, cobalt_thread_start,
318  TP_PROTO(struct xnthread *thread),
319  TP_ARGS(thread)
320 );
321 
322 DEFINE_EVENT(thread_event, cobalt_thread_cancel,
323  TP_PROTO(struct xnthread *thread),
324  TP_ARGS(thread)
325 );
326 
327 DEFINE_EVENT(thread_event, cobalt_thread_join,
328  TP_PROTO(struct xnthread *thread),
329  TP_ARGS(thread)
330 );
331 
332 DEFINE_EVENT(thread_event, cobalt_thread_unblock,
333  TP_PROTO(struct xnthread *thread),
334  TP_ARGS(thread)
335 );
336 
337 DEFINE_EVENT(curr_thread_event, cobalt_thread_wait_period,
338  TP_PROTO(struct xnthread *thread),
339  TP_ARGS(thread)
340 );
341 
342 DEFINE_EVENT(curr_thread_event, cobalt_thread_missed_period,
343  TP_PROTO(struct xnthread *thread),
344  TP_ARGS(thread)
345 );
346 
347 DEFINE_EVENT(curr_thread_event, cobalt_thread_set_mode,
348  TP_PROTO(struct xnthread *thread),
349  TP_ARGS(thread)
350 );
351 
352 TRACE_EVENT(cobalt_thread_migrate,
353  TP_PROTO(unsigned int cpu),
354  TP_ARGS(cpu),
355 
356  TP_STRUCT__entry(
357  __field(unsigned int, cpu)
358  ),
359 
360  TP_fast_assign(
361  __entry->cpu = cpu;
362  ),
363 
364  TP_printk("cpu=%u", __entry->cpu)
365 );
366 
367 TRACE_EVENT(cobalt_thread_migrate_passive,
368  TP_PROTO(struct xnthread *thread, unsigned int cpu),
369  TP_ARGS(thread, cpu),
370 
371  TP_STRUCT__entry(
372  __field(struct xnthread *, thread)
373  __field(pid_t, pid)
374  __field(unsigned int, cpu)
375  ),
376 
377  TP_fast_assign(
378  __entry->thread = thread;
379  __entry->pid = xnthread_host_pid(thread);
380  __entry->cpu = cpu;
381  ),
382 
383  TP_printk("thread=%p pid=%d cpu=%u",
384  __entry->thread, __entry->pid, __entry->cpu)
385 );
386 
387 DEFINE_EVENT(curr_thread_event, cobalt_shadow_gohard,
388  TP_PROTO(struct xnthread *thread),
389  TP_ARGS(thread)
390 );
391 
392 DEFINE_EVENT(curr_thread_event, cobalt_watchdog_signal,
393  TP_PROTO(struct xnthread *thread),
394  TP_ARGS(thread)
395 );
396 
397 DEFINE_EVENT(curr_thread_event, cobalt_shadow_hardened,
398  TP_PROTO(struct xnthread *thread),
399  TP_ARGS(thread)
400 );
401 
402 #define cobalt_print_relax_reason(reason) \
403  __print_symbolic(reason, \
404  { SIGDEBUG_UNDEFINED, "undefined" }, \
405  { SIGDEBUG_MIGRATE_SIGNAL, "signal" }, \
406  { SIGDEBUG_MIGRATE_SYSCALL, "syscall" }, \
407  { SIGDEBUG_MIGRATE_FAULT, "fault" })
408 
409 TRACE_EVENT(cobalt_shadow_gorelax,
410  TP_PROTO(int reason),
411  TP_ARGS(reason),
412 
413  TP_STRUCT__entry(
414  __field(int, reason)
415  ),
416 
417  TP_fast_assign(
418  __entry->reason = reason;
419  ),
420 
421  TP_printk("reason=%s", cobalt_print_relax_reason(__entry->reason))
422 );
423 
424 DEFINE_EVENT(curr_thread_event, cobalt_shadow_relaxed,
425  TP_PROTO(struct xnthread *thread),
426  TP_ARGS(thread)
427 );
428 
429 DEFINE_EVENT(curr_thread_event, cobalt_shadow_entry,
430  TP_PROTO(struct xnthread *thread),
431  TP_ARGS(thread)
432 );
433 
434 TRACE_EVENT(cobalt_shadow_map,
435  TP_PROTO(struct xnthread *thread),
436  TP_ARGS(thread),
437 
438  TP_STRUCT__entry(
439  __field(struct xnthread *, thread)
440  __field(pid_t, pid)
441  __field(int, prio)
442  ),
443 
444  TP_fast_assign(
445  __entry->thread = thread;
446  __entry->pid = xnthread_host_pid(thread);
447  __entry->prio = xnthread_base_priority(thread);
448  ),
449 
450  TP_printk("thread=%p pid=%d prio=%d",
451  __entry->thread, __entry->pid, __entry->prio)
452 );
453 
454 DEFINE_EVENT(curr_thread_event, cobalt_shadow_unmap,
455  TP_PROTO(struct xnthread *thread),
456  TP_ARGS(thread)
457 );
458 
459 TRACE_EVENT(cobalt_lostage_request,
460  TP_PROTO(const char *type, struct task_struct *task),
461  TP_ARGS(type, task),
462 
463  TP_STRUCT__entry(
464  __field(pid_t, pid)
465  __array(char, comm, TASK_COMM_LEN)
466  __field(const char *, type)
467  ),
468 
469  TP_fast_assign(
470  __entry->type = type;
471  __entry->pid = task_pid_nr(task);
472  memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
473  ),
474 
475  TP_printk("request=%s pid=%d comm=%s",
476  __entry->type, __entry->pid, __entry->comm)
477 );
478 
479 TRACE_EVENT(cobalt_lostage_wakeup,
480  TP_PROTO(struct task_struct *task),
481  TP_ARGS(task),
482 
483  TP_STRUCT__entry(
484  __field(pid_t, pid)
485  __array(char, comm, TASK_COMM_LEN)
486  ),
487 
488  TP_fast_assign(
489  __entry->pid = task_pid_nr(task);
490  memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
491  ),
492 
493  TP_printk("pid=%d comm=%s",
494  __entry->pid, __entry->comm)
495 );
496 
497 TRACE_EVENT(cobalt_lostage_signal,
498  TP_PROTO(struct task_struct *task, int sig),
499  TP_ARGS(task, sig),
500 
501  TP_STRUCT__entry(
502  __field(pid_t, pid)
503  __array(char, comm, TASK_COMM_LEN)
504  __field(int, sig)
505  ),
506 
507  TP_fast_assign(
508  __entry->pid = task_pid_nr(task);
509  __entry->sig = sig;
510  memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
511  ),
512 
513  TP_printk("pid=%d comm=%s sig=%d",
514  __entry->pid, __entry->comm, __entry->sig)
515 );
516 
517 DEFINE_EVENT(irq_event, cobalt_irq_entry,
518  TP_PROTO(unsigned int irq),
519  TP_ARGS(irq)
520 );
521 
522 DEFINE_EVENT(irq_event, cobalt_irq_exit,
523  TP_PROTO(unsigned int irq),
524  TP_ARGS(irq)
525 );
526 
527 DEFINE_EVENT(irq_event, cobalt_irq_attach,
528  TP_PROTO(unsigned int irq),
529  TP_ARGS(irq)
530 );
531 
532 DEFINE_EVENT(irq_event, cobalt_irq_detach,
533  TP_PROTO(unsigned int irq),
534  TP_ARGS(irq)
535 );
536 
537 DEFINE_EVENT(irq_event, cobalt_irq_enable,
538  TP_PROTO(unsigned int irq),
539  TP_ARGS(irq)
540 );
541 
542 DEFINE_EVENT(irq_event, cobalt_irq_disable,
543  TP_PROTO(unsigned int irq),
544  TP_ARGS(irq)
545 );
546 
547 DEFINE_EVENT(clock_event, cobalt_clock_entry,
548  TP_PROTO(unsigned int irq),
549  TP_ARGS(irq)
550 );
551 
552 DEFINE_EVENT(clock_event, cobalt_clock_exit,
553  TP_PROTO(unsigned int irq),
554  TP_ARGS(irq)
555 );
556 
557 DEFINE_EVENT(timer_event, cobalt_timer_stop,
558  TP_PROTO(struct xntimer *timer),
559  TP_ARGS(timer)
560 );
561 
562 DEFINE_EVENT(timer_event, cobalt_timer_expire,
563  TP_PROTO(struct xntimer *timer),
564  TP_ARGS(timer)
565 );
566 
567 #define cobalt_print_timer_mode(mode) \
568  __print_symbolic(mode, \
569  { XN_RELATIVE, "rel" }, \
570  { XN_ABSOLUTE, "abs" }, \
571  { XN_REALTIME, "rt" })
572 
573 TRACE_EVENT(cobalt_timer_start,
574  TP_PROTO(struct xntimer *timer, xnticks_t value, xnticks_t interval,
575  xntmode_t mode),
576  TP_ARGS(timer, value, interval, mode),
577 
578  TP_STRUCT__entry(
579  __field(struct xntimer *, timer)
580 #ifdef CONFIG_XENO_OPT_STATS
581  __string(name, timer->name)
582 #endif
583  __field(xnticks_t, value)
584  __field(xnticks_t, interval)
585  __field(xntmode_t, mode)
586  ),
587 
588  TP_fast_assign(
589  __entry->timer = timer;
590 #ifdef CONFIG_XENO_OPT_STATS
591  __assign_str(name, timer->name);
592 #endif
593  __entry->value = value;
594  __entry->interval = interval;
595  __entry->mode = mode;
596  ),
597 
598  TP_printk("timer=%p(%s) value=%Lu interval=%Lu mode=%s",
599  __entry->timer,
600 #ifdef CONFIG_XENO_OPT_STATS
601  __get_str(name),
602 #else
603  "(anon)",
604 #endif
605  __entry->value, __entry->interval,
606  cobalt_print_timer_mode(__entry->mode))
607 );
608 
609 #ifdef CONFIG_SMP
610 
611 TRACE_EVENT(cobalt_timer_migrate,
612  TP_PROTO(struct xntimer *timer, unsigned int cpu),
613  TP_ARGS(timer, cpu),
614 
615  TP_STRUCT__entry(
616  __field(struct xntimer *, timer)
617  __field(unsigned int, cpu)
618  ),
619 
620  TP_fast_assign(
621  __entry->timer = timer;
622  __entry->cpu = cpu;
623  ),
624 
625  TP_printk("timer=%p cpu=%u",
626  __entry->timer, __entry->cpu)
627 );
628 
629 #endif /* CONFIG_SMP */
630 
631 DEFINE_EVENT(synch_wait_event, cobalt_synch_sleepon,
632  TP_PROTO(struct xnsynch *synch),
633  TP_ARGS(synch)
634 );
635 
636 DEFINE_EVENT(synch_wait_event, cobalt_synch_try_acquire,
637  TP_PROTO(struct xnsynch *synch),
638  TP_ARGS(synch)
639 );
640 
641 DEFINE_EVENT(synch_wait_event, cobalt_synch_acquire,
642  TP_PROTO(struct xnsynch *synch),
643  TP_ARGS(synch)
644 );
645 
646 DEFINE_EVENT(synch_post_event, cobalt_synch_release,
647  TP_PROTO(struct xnsynch *synch),
648  TP_ARGS(synch)
649 );
650 
651 DEFINE_EVENT(synch_post_event, cobalt_synch_wakeup,
652  TP_PROTO(struct xnsynch *synch),
653  TP_ARGS(synch)
654 );
655 
656 DEFINE_EVENT(synch_post_event, cobalt_synch_wakeup_many,
657  TP_PROTO(struct xnsynch *synch),
658  TP_ARGS(synch)
659 );
660 
661 DEFINE_EVENT(synch_post_event, cobalt_synch_flush,
662  TP_PROTO(struct xnsynch *synch),
663  TP_ARGS(synch)
664 );
665 
666 DEFINE_EVENT(synch_post_event, cobalt_synch_forget,
667  TP_PROTO(struct xnsynch *synch),
668  TP_ARGS(synch)
669 );
670 
671 #endif /* _TRACE_COBALT_CORE_H */
672 
673 /* This part must be outside protection */
674 #undef TRACE_INCLUDE_PATH
675 #undef TRACE_INCLUDE_FILE
676 #define TRACE_INCLUDE_FILE cobalt-core
677 #include <trace/define_trace.h>
Scheduling information structure.
Definition: sched.h:58
unsigned long status
Definition: sched.h:60