xref: /openbmc/linux/include/trace/events/iocost.h (revision be58f710)
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 DECLARE_EVENT_CLASS(iocost_iocg_state,
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, vtime)
30 		__field(u32, weight)
31 		__field(u32, inuse)
32 		__field(u64, hweight_active)
33 		__field(u64, hweight_inuse)
34 	),
35 
36 	TP_fast_assign(
37 		__assign_str(devname, ioc_name(iocg->ioc));
38 		__assign_str(cgroup, path);
39 		__entry->now = now->now;
40 		__entry->vnow = now->vnow;
41 		__entry->vrate = now->vrate;
42 		__entry->last_period = last_period;
43 		__entry->cur_period = cur_period;
44 		__entry->vtime = vtime;
45 		__entry->weight = iocg->weight;
46 		__entry->inuse = iocg->inuse;
47 		__entry->hweight_active = iocg->hweight_active;
48 		__entry->hweight_inuse = iocg->hweight_inuse;
49 	),
50 
51 	TP_printk("[%s:%s] now=%llu:%llu vrate=%llu "
52 		  "period=%llu->%llu vtime=%llu "
53 		  "weight=%u/%u hweight=%llu/%llu",
54 		__get_str(devname), __get_str(cgroup),
55 		__entry->now, __entry->vnow, __entry->vrate,
56 		__entry->last_period, __entry->cur_period,
57 		__entry->vtime, __entry->inuse, __entry->weight,
58 		__entry->hweight_inuse, __entry->hweight_active
59 	)
60 );
61 
62 DEFINE_EVENT(iocost_iocg_state, iocost_iocg_activate,
63 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
64 		 u64 last_period, u64 cur_period, u64 vtime),
65 
66 	TP_ARGS(iocg, path, now, last_period, cur_period, vtime)
67 );
68 
69 DEFINE_EVENT(iocost_iocg_state, iocost_iocg_idle,
70 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
71 		 u64 last_period, u64 cur_period, u64 vtime),
72 
73 	TP_ARGS(iocg, path, now, last_period, cur_period, vtime)
74 );
75 
76 DECLARE_EVENT_CLASS(iocg_inuse_update,
77 
78 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
79 		u32 old_inuse, u32 new_inuse,
80 		u64 old_hw_inuse, u64 new_hw_inuse),
81 
82 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
83 		old_hw_inuse, new_hw_inuse),
84 
85 	TP_STRUCT__entry (
86 		__string(devname, ioc_name(iocg->ioc))
87 		__string(cgroup, path)
88 		__field(u64, now)
89 		__field(u32, old_inuse)
90 		__field(u32, new_inuse)
91 		__field(u64, old_hweight_inuse)
92 		__field(u64, new_hweight_inuse)
93 	),
94 
95 	TP_fast_assign(
96 		__assign_str(devname, ioc_name(iocg->ioc));
97 		__assign_str(cgroup, path);
98 		__entry->now = now->now;
99 		__entry->old_inuse = old_inuse;
100 		__entry->new_inuse = new_inuse;
101 		__entry->old_hweight_inuse = old_hw_inuse;
102 		__entry->new_hweight_inuse = new_hw_inuse;
103 	),
104 
105 	TP_printk("[%s:%s] now=%llu inuse=%u->%u hw_inuse=%llu->%llu",
106 		__get_str(devname), __get_str(cgroup), __entry->now,
107 		__entry->old_inuse, __entry->new_inuse,
108 		__entry->old_hweight_inuse, __entry->new_hweight_inuse
109 	)
110 );
111 
112 DEFINE_EVENT(iocg_inuse_update, iocost_inuse_shortage,
113 
114 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
115 		u32 old_inuse, u32 new_inuse,
116 		u64 old_hw_inuse, u64 new_hw_inuse),
117 
118 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
119 		old_hw_inuse, new_hw_inuse)
120 );
121 
122 DEFINE_EVENT(iocg_inuse_update, iocost_inuse_transfer,
123 
124 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
125 		u32 old_inuse, u32 new_inuse,
126 		u64 old_hw_inuse, u64 new_hw_inuse),
127 
128 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
129 		old_hw_inuse, new_hw_inuse)
130 );
131 
132 DEFINE_EVENT(iocg_inuse_update, iocost_inuse_adjust,
133 
134 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
135 		u32 old_inuse, u32 new_inuse,
136 		u64 old_hw_inuse, u64 new_hw_inuse),
137 
138 	TP_ARGS(iocg, path, now, old_inuse, new_inuse,
139 		old_hw_inuse, new_hw_inuse)
140 );
141 
142 TRACE_EVENT(iocost_ioc_vrate_adj,
143 
144 	TP_PROTO(struct ioc *ioc, u64 new_vrate, u32 *missed_ppm,
145 		u32 rq_wait_pct, int nr_lagging, int nr_shortages),
146 
147 	TP_ARGS(ioc, new_vrate, missed_ppm, rq_wait_pct, nr_lagging, nr_shortages),
148 
149 	TP_STRUCT__entry (
150 		__string(devname, ioc_name(ioc))
151 		__field(u64, old_vrate)
152 		__field(u64, new_vrate)
153 		__field(int, busy_level)
154 		__field(u32, read_missed_ppm)
155 		__field(u32, write_missed_ppm)
156 		__field(u32, rq_wait_pct)
157 		__field(int, nr_lagging)
158 		__field(int, nr_shortages)
159 	),
160 
161 	TP_fast_assign(
162 		__assign_str(devname, ioc_name(ioc));
163 		__entry->old_vrate = atomic64_read(&ioc->vtime_rate);;
164 		__entry->new_vrate = new_vrate;
165 		__entry->busy_level = ioc->busy_level;
166 		__entry->read_missed_ppm = missed_ppm[READ];
167 		__entry->write_missed_ppm = missed_ppm[WRITE];
168 		__entry->rq_wait_pct = rq_wait_pct;
169 		__entry->nr_lagging = nr_lagging;
170 		__entry->nr_shortages = nr_shortages;
171 	),
172 
173 	TP_printk("[%s] vrate=%llu->%llu busy=%d missed_ppm=%u:%u rq_wait_pct=%u lagging=%d shortages=%d",
174 		__get_str(devname), __entry->old_vrate, __entry->new_vrate,
175 		__entry->busy_level,
176 		__entry->read_missed_ppm, __entry->write_missed_ppm,
177 		__entry->rq_wait_pct, __entry->nr_lagging, __entry->nr_shortages
178 	)
179 );
180 
181 TRACE_EVENT(iocost_iocg_forgive_debt,
182 
183 	TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
184 		u32 usage_pct, u64 old_debt, u64 new_debt,
185 		u64 old_delay, u64 new_delay),
186 
187 	TP_ARGS(iocg, path, now, usage_pct,
188 		old_debt, new_debt, old_delay, new_delay),
189 
190 	TP_STRUCT__entry (
191 		__string(devname, ioc_name(iocg->ioc))
192 		__string(cgroup, path)
193 		__field(u64, now)
194 		__field(u64, vnow)
195 		__field(u32, usage_pct)
196 		__field(u64, old_debt)
197 		__field(u64, new_debt)
198 		__field(u64, old_delay)
199 		__field(u64, new_delay)
200 	),
201 
202 	TP_fast_assign(
203 		__assign_str(devname, ioc_name(iocg->ioc));
204 		__assign_str(cgroup, path);
205 		__entry->now = now->now;
206 		__entry->vnow = now->vnow;
207 		__entry->usage_pct = usage_pct;
208 		__entry->old_debt = old_debt;
209 		__entry->new_debt = new_debt;
210 		__entry->old_delay = old_delay;
211 		__entry->new_delay = new_delay;
212 	),
213 
214 	TP_printk("[%s:%s] now=%llu:%llu usage=%u debt=%llu->%llu delay=%llu->%llu",
215 		__get_str(devname), __get_str(cgroup),
216 		__entry->now, __entry->vnow, __entry->usage_pct,
217 		__entry->old_debt, __entry->new_debt,
218 		__entry->old_delay, __entry->new_delay
219 	)
220 );
221 
222 #endif /* _TRACE_BLK_IOCOST_H */
223 
224 /* This part must be outside protection */
225 #include <trace/define_trace.h>
226