• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2018 Google, Inc.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 
7 #ifndef _LTP_TRACE_PARSE_H_
8 #define _LTP_TRACE_PARSE_H_
9 
10 enum {
11 	TRACE_RECORD_OTHER = 0,
12 	TRACE_RECORD_SCHED_PROCESS_EXIT,
13 	TRACE_RECORD_SCHED_PROCESS_FORK,
14 	TRACE_RECORD_SCHED_SWITCH,
15 	TRACE_RECORD_SCHED_WAKEUP,
16 	TRACE_RECORD_SUGOV_UTIL_UPDATE,
17 	TRACE_RECORD_SUGOV_NEXT_FREQ,
18 	TRACE_RECORD_CPU_FREQUENCY,
19 	TRACE_RECORD_TRACING_MARK_WRITE,
20 };
21 
22 #define IRQ_CONTEXT_NORMAL '.'
23 #define IRQ_CONTEXT_SOFT 's'
24 #define IRQ_CONTEXT_HARD 'h'
25 #define IRQ_CONTEXT_HARD_IN_SOFT 'H'
26 #define IRQ_CONTEXT_NMI 'z'
27 #define IRQ_CONTEXT_NMI_IN_HARD 'Z'
28 
29 struct trace_timestamp {
30 	unsigned int sec;
31 	unsigned int usec;
32 };
33 
34 struct trace_cpu_frequency {
35 	unsigned int state;
36 	unsigned short cpu;
37 };
38 
39 struct trace_sched_switch {
40 	char prev_comm[17];
41 	unsigned short prev_pid;
42 	unsigned short prev_prio;
43 	char prev_state;
44 	char next_comm[17];
45 	unsigned short next_pid;
46 	unsigned short next_prio;
47 };
48 
49 struct trace_sched_wakeup {
50 	char comm[17];
51 	unsigned short pid;
52 	unsigned short prio;
53 	unsigned short cpu;
54 };
55 
56 struct trace_sugov_util_update {
57 	int cpu;
58 	int util;
59 	int avg_cap;
60 	int max_cap;
61 };
62 
63 struct trace_sugov_next_freq {
64 	int cpu;
65 	int util;
66 	int max;
67 	int freq;
68 };
69 
70 struct trace_record {
71 	char task[17];
72 	unsigned short pid;
73 	unsigned short cpu;
74 
75 #define TRACE_RECORD_IRQS_OFF 0x1
76 #define TRACE_RECORD_TIF_NEED_RESCHED 0x2
77 #define TRACE_RECORD_PREEMPT_NEED_RESCHED 0x4
78 	unsigned short flags;
79 	unsigned char irq_context;
80 	unsigned short preempt_depth;
81 
82 	struct trace_timestamp ts;
83 
84 	unsigned int event_type;
85 	void *event_data;
86 };
87 
88 extern int num_trace_records;
89 extern struct trace_record *trace;
90 extern char *ftrace_root_dir;
91 
92 void tracefs_write(const char *file_name, const char *value);
93 void trace_setup(void);
94 void trace_cleanup(void);
95 void print_trace_record(struct trace_record *tr);
96 struct trace_record *load_trace(void);
97 
98 #define LOAD_TRACE() \
99 	if (!load_trace()) \
100 		tst_brk(TBROK, "Failed to load trace.\n");
101 
102 #endif /* _LTP_TRACE_PARSE_H_ */
103