xref: /openbmc/linux/include/trace/events/iocost.h (revision f125e2d4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM iocost
4 
5 struct ioc;
6 struct ioc_now;
7 struct ioc_gq;
8 
9 #if !defined(_TRACE_BLK_IOCOST_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_BLK_IOCOST_H
11 
12 #include <linux/tracepoint.h>
13 
14 TRACE_EVENT(iocost_iocg_activate,
15 
16 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
17 		u64 last_period, u64 cur_period, u64 vtime),
18 
19 	TP_ARGS(iocg, path, now, last_period, cur_period, vtime),
20 
21 	TP_STRUCT__entry (
22 		__string(devname, ioc_name(iocg->ioc))
23 		__string(cgroup, path)
24 		__field(u64, now)
25 		__field(u64, vnow)
26 		__field(u64, vrate)
27 		__field(u64, last_period)
28 		__field(u64, cur_period)
29 		__field(u64, last_vtime)
30 		__field(u64, vtime)
31 		__field(u32, weight)
32 		__field(u32, inuse)
33 		__field(u64, hweight_active)
34 		__field(u64, hweight_inuse)
35 	),
36 
37 	TP_fast_assign(
38 		__assign_str(devname, ioc_name(iocg->ioc));
39 		__assign_str(cgroup, path);
40 		__entry->now = now->now;
41 		__entry->vnow = now->vnow;
42 		__entry->vrate = now->vrate;
43 		__entry->last_period = last_period;
44 		__entry->cur_period = cur_period;
45 		__entry->last_vtime = iocg->last_vtime;
46 		__entry->vtime = vtime;
47 		__entry->weight = iocg->weight;
48 		__entry->inuse = iocg->inuse;
49 		__entry->hweight_active = iocg->hweight_active;
50 		__entry->hweight_inuse = iocg->hweight_inuse;
51 	),
52 
53 	TP_printk("[%s:%s] now=%llu:%llu vrate=%llu "
54 		  "period=%llu->%llu vtime=%llu->%llu "
55 		  "weight=%u/%u hweight=%llu/%llu",
56 		__get_str(devname), __get_str(cgroup),
57 		__entry->now, __entry->vnow, __entry->vrate,
58 		__entry->last_period, __entry->cur_period,
59 		__entry->last_vtime, __entry->vtime,
60 		__entry->inuse, __entry->weight,
61 		__entry->hweight_inuse, __entry->hweight_active
62 	)
63 );
64 
65 DECLARE_EVENT_CLASS(iocg_inuse_update,
66 
67 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
68 		u32 old_inuse, u32 new_inuse,
69 		u64 old_hw_inuse, u64 new_hw_inuse),
70 
71 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
72 		old_hw_inuse, new_hw_inuse),
73 
74 	TP_STRUCT__entry (
75 		__string(devname, ioc_name(iocg->ioc))
76 		__string(cgroup, path)
77 		__field(u64, now)
78 		__field(u32, old_inuse)
79 		__field(u32, new_inuse)
80 		__field(u64, old_hweight_inuse)
81 		__field(u64, new_hweight_inuse)
82 	),
83 
84 	TP_fast_assign(
85 		__assign_str(devname, ioc_name(iocg->ioc));
86 		__assign_str(cgroup, path);
87 		__entry->now = now->now;
88 		__entry->old_inuse = old_inuse;
89 		__entry->new_inuse = new_inuse;
90 		__entry->old_hweight_inuse = old_hw_inuse;
91 		__entry->new_hweight_inuse = new_hw_inuse;
92 	),
93 
94 	TP_printk("[%s:%s] now=%llu inuse=%u->%u hw_inuse=%llu->%llu",
95 		__get_str(devname), __get_str(cgroup), __entry->now,
96 		__entry->old_inuse, __entry->new_inuse,
97 		__entry->old_hweight_inuse, __entry->new_hweight_inuse
98 	)
99 );
100 
101 DEFINE_EVENT(iocg_inuse_update, iocost_inuse_takeback,
102 
103 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
104 		u32 old_inuse, u32 new_inuse,
105 		u64 old_hw_inuse, u64 new_hw_inuse),
106 
107 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
108 		old_hw_inuse, new_hw_inuse)
109 );
110 
111 DEFINE_EVENT(iocg_inuse_update, iocost_inuse_giveaway,
112 
113 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
114 		u32 old_inuse, u32 new_inuse,
115 		u64 old_hw_inuse, u64 new_hw_inuse),
116 
117 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
118 		old_hw_inuse, new_hw_inuse)
119 );
120 
121 DEFINE_EVENT(iocg_inuse_update, iocost_inuse_reset,
122 
123 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
124 		u32 old_inuse, u32 new_inuse,
125 		u64 old_hw_inuse, u64 new_hw_inuse),
126 
127 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
128 		old_hw_inuse, new_hw_inuse)
129 );
130 
131 TRACE_EVENT(iocost_ioc_vrate_adj,
132 
133 	TP_PROTO(struct ioc *ioc, u64 new_vrate, u32 (*missed_ppm)[2],
134 		u32 rq_wait_pct, int nr_lagging, int nr_shortages,
135 		int nr_surpluses),
136 
137 	TP_ARGS(ioc, new_vrate, missed_ppm, rq_wait_pct, nr_lagging, nr_shortages,
138 		nr_surpluses),
139 
140 	TP_STRUCT__entry (
141 		__string(devname, ioc_name(ioc))
142 		__field(u64, old_vrate)
143 		__field(u64, new_vrate)
144 		__field(int, busy_level)
145 		__field(u32, read_missed_ppm)
146 		__field(u32, write_missed_ppm)
147 		__field(u32, rq_wait_pct)
148 		__field(int, nr_lagging)
149 		__field(int, nr_shortages)
150 		__field(int, nr_surpluses)
151 	),
152 
153 	TP_fast_assign(
154 		__assign_str(devname, ioc_name(ioc));
155 		__entry->old_vrate = atomic64_read(&ioc->vtime_rate);;
156 		__entry->new_vrate = new_vrate;
157 		__entry->busy_level = ioc->busy_level;
158 		__entry->read_missed_ppm = (*missed_ppm)[READ];
159 		__entry->write_missed_ppm = (*missed_ppm)[WRITE];
160 		__entry->rq_wait_pct = rq_wait_pct;
161 		__entry->nr_lagging = nr_lagging;
162 		__entry->nr_shortages = nr_shortages;
163 		__entry->nr_surpluses = nr_surpluses;
164 	),
165 
166 	TP_printk("[%s] vrate=%llu->%llu busy=%d missed_ppm=%u:%u rq_wait_pct=%u lagging=%d shortages=%d surpluses=%d",
167 		__get_str(devname), __entry->old_vrate, __entry->new_vrate,
168 		__entry->busy_level,
169 		__entry->read_missed_ppm, __entry->write_missed_ppm,
170 		__entry->rq_wait_pct, __entry->nr_lagging, __entry->nr_shortages,
171 		__entry->nr_surpluses
172 	)
173 );
174 
175 #endif /* _TRACE_BLK_IOCOST_H */
176 
177 /* This part must be outside protection */
178 #include <trace/define_trace.h>
179