huangcm
2025-07-03 c26084b3642f262f858535ab4e46c1e9b520d3a1
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
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
 
#if !defined(_DISP_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _DISP_TRACE_H_
 
#include <linux/stringify.h>
#include <linux/types.h>
#include <linux/tracepoint.h>
 
#undef  TRACE_SYSTEM
#define TRACE_SYSTEM disp_trace
 
TRACE_EVENT(tracing_mark_write,
   TP_PROTO(int pid, const char *name, bool trace_begin),
   TP_ARGS(pid, name, trace_begin),
   TP_STRUCT__entry(
       __field(int, pid)
       __string(trace_name, name)
       __field(bool, trace_begin)
       ),
   TP_fast_assign(
       __entry->pid = pid;
       __assign_str(trace_name, name);
       __entry->trace_begin = trace_begin;
       ),
 
   TP_printk("%s|%d|%s", __entry->trace_begin ? "B" : "E",
       __entry->pid, __get_str(trace_name))
);
 
TRACE_EVENT(display_trace_counter,
   TP_PROTO(int pid, char *name, int value),
   TP_ARGS(pid, name, value),
   TP_STRUCT__entry(
       __field(int, pid)
       __string(counter_name, name)
       __field(int, value)
       ),
   TP_fast_assign(
       __entry->pid = pid;
       __assign_str(counter_name, name);
       __entry->value = value;
       ),
   TP_printk("C|%d|%s|%d",
       __entry->pid,
       __get_str(counter_name), __entry->value)
);
 
#define DISP_TRACE_END(name)   trace_tracing_mark_write(current->tgid, name, 0)
#define DISP_TRACE_BEGIN(name) trace_tracing_mark_write(current->tgid, name, 1)
#define DISP_TRACE_FUNC()      DISP_TRACE_BEGIN(__func__)
 
#define DISP_TRACE_INT(name, value) \
   trace_display_trace_counter(current->tgid, name, value)
 
/*
 * Using the api in the interrupt context ensures
 * that the systrace information is bound to the same process.
 */
#define __fake_pid__ (0x0624)
#define DISP_TRACE_INT_F(name, value) \
   trace_display_trace_counter(__fake_pid__, name, value)
 
#endif /* _DISP_TRACE_H_ */
 
/*
 * This part must be outside protection
 */
#undef  TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#include <trace/define_trace.h>