]>
Commit | Line | Data |
---|---|---|
2ff1f2e3 AG |
1 | /* |
2 | * QEMU block throttling group infrastructure | |
3 | * | |
4 | * Copyright (C) Nodalink, EURL. 2014 | |
5 | * Copyright (C) Igalia, S.L. 2015 | |
6 | * | |
7 | * Authors: | |
8 | * BenoƮt Canet <benoit.canet@nodalink.com> | |
9 | * Alberto Garcia <berto@igalia.com> | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU General Public License as | |
13 | * published by the Free Software Foundation; either version 2 or | |
14 | * (at your option) version 3 of the License. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
23 | */ | |
24 | ||
80c71a24 | 25 | #include "qemu/osdep.h" |
31dce3cc | 26 | #include "sysemu/block-backend.h" |
2ff1f2e3 | 27 | #include "block/throttle-groups.h" |
432d889e | 28 | #include "qemu/throttle-options.h" |
db725815 | 29 | #include "qemu/main-loop.h" |
76f4afb4 AG |
30 | #include "qemu/queue.h" |
31 | #include "qemu/thread.h" | |
32 | #include "sysemu/qtest.h" | |
432d889e | 33 | #include "qapi/error.h" |
9af23989 | 34 | #include "qapi/qapi-visit-block-core.h" |
432d889e MP |
35 | #include "qom/object.h" |
36 | #include "qom/object_interfaces.h" | |
37 | ||
38 | static void throttle_group_obj_init(Object *obj); | |
39 | static void throttle_group_obj_complete(UserCreatable *obj, Error **errp); | |
25b8e4db | 40 | static void timer_cb(ThrottleGroupMember *tgm, bool is_write); |
2ff1f2e3 AG |
41 | |
42 | /* The ThrottleGroup structure (with its ThrottleState) is shared | |
022cdc9f | 43 | * among different ThrottleGroupMembers and it's independent from |
2ff1f2e3 AG |
44 | * AioContext, so in order to use it from different threads it needs |
45 | * its own locking. | |
46 | * | |
47 | * This locking is however handled internally in this file, so it's | |
d87d01e1 | 48 | * transparent to outside users. |
2ff1f2e3 AG |
49 | * |
50 | * The whole ThrottleGroup structure is private and invisible to | |
51 | * outside users, that only use it through its ThrottleState. | |
52 | * | |
022cdc9f | 53 | * In addition to the ThrottleGroup structure, ThrottleGroupMember has |
2ff1f2e3 | 54 | * fields that need to be accessed by other members of the group and |
27ccdd52 | 55 | * therefore also need to be protected by this lock. Once a |
022cdc9f | 56 | * ThrottleGroupMember is registered in a group those fields can be accessed |
27ccdd52 | 57 | * by other threads any time. |
2ff1f2e3 AG |
58 | * |
59 | * Again, all this is handled internally and is mostly transparent to | |
60 | * the outside. The 'throttle_timers' field however has an additional | |
61 | * constraint because it may be temporarily invalid (see for example | |
0d2fac8e | 62 | * blk_set_aio_context()). Therefore in this file a thread will |
022cdc9f MP |
63 | * access some other ThrottleGroupMember's timers only after verifying that |
64 | * that ThrottleGroupMember has throttled requests in the queue. | |
2ff1f2e3 | 65 | */ |
7c9dcd6c | 66 | struct ThrottleGroup { |
432d889e MP |
67 | Object parent_obj; |
68 | ||
69 | /* refuse individual property change if initialization is complete */ | |
70 | bool is_initialized; | |
2ff1f2e3 AG |
71 | char *name; /* This is constant during the lifetime of the group */ |
72 | ||
73 | QemuMutex lock; /* This lock protects the following four fields */ | |
74 | ThrottleState ts; | |
022cdc9f MP |
75 | QLIST_HEAD(, ThrottleGroupMember) head; |
76 | ThrottleGroupMember *tokens[2]; | |
2ff1f2e3 | 77 | bool any_timer_armed[2]; |
dbe824cc | 78 | QEMUClockType clock_type; |
2ff1f2e3 | 79 | |
432d889e | 80 | /* This field is protected by the global QEMU mutex */ |
2ff1f2e3 | 81 | QTAILQ_ENTRY(ThrottleGroup) list; |
7c9dcd6c | 82 | }; |
2ff1f2e3 | 83 | |
432d889e | 84 | /* This is protected by the global QEMU mutex */ |
2ff1f2e3 AG |
85 | static QTAILQ_HEAD(, ThrottleGroup) throttle_groups = |
86 | QTAILQ_HEAD_INITIALIZER(throttle_groups); | |
87 | ||
432d889e MP |
88 | |
89 | /* This function reads throttle_groups and must be called under the global | |
90 | * mutex. | |
91 | */ | |
92 | static ThrottleGroup *throttle_group_by_name(const char *name) | |
93 | { | |
94 | ThrottleGroup *iter; | |
95 | ||
96 | /* Look for an existing group with that name */ | |
97 | QTAILQ_FOREACH(iter, &throttle_groups, list) { | |
98 | if (!g_strcmp0(name, iter->name)) { | |
99 | return iter; | |
100 | } | |
101 | } | |
102 | ||
103 | return NULL; | |
104 | } | |
105 | ||
d8e7d87e MP |
106 | /* This function reads throttle_groups and must be called under the global |
107 | * mutex. | |
108 | */ | |
109 | bool throttle_group_exists(const char *name) | |
110 | { | |
111 | return throttle_group_by_name(name) != NULL; | |
112 | } | |
113 | ||
2ff1f2e3 AG |
114 | /* Increments the reference count of a ThrottleGroup given its name. |
115 | * | |
116 | * If no ThrottleGroup is found with the given name a new one is | |
117 | * created. | |
118 | * | |
432d889e MP |
119 | * This function edits throttle_groups and must be called under the global |
120 | * mutex. | |
121 | * | |
2ff1f2e3 | 122 | * @name: the name of the ThrottleGroup |
973f2ddf | 123 | * @ret: the ThrottleState member of the ThrottleGroup |
2ff1f2e3 | 124 | */ |
973f2ddf | 125 | ThrottleState *throttle_group_incref(const char *name) |
2ff1f2e3 AG |
126 | { |
127 | ThrottleGroup *tg = NULL; | |
2ff1f2e3 AG |
128 | |
129 | /* Look for an existing group with that name */ | |
432d889e MP |
130 | tg = throttle_group_by_name(name); |
131 | ||
132 | if (tg) { | |
133 | object_ref(OBJECT(tg)); | |
134 | } else { | |
135 | /* Create a new one if not found */ | |
136 | /* new ThrottleGroup obj will have a refcnt = 1 */ | |
137 | tg = THROTTLE_GROUP(object_new(TYPE_THROTTLE_GROUP)); | |
2ff1f2e3 | 138 | tg->name = g_strdup(name); |
432d889e | 139 | throttle_group_obj_complete(USER_CREATABLE(tg), &error_abort); |
2ff1f2e3 AG |
140 | } |
141 | ||
973f2ddf | 142 | return &tg->ts; |
2ff1f2e3 AG |
143 | } |
144 | ||
145 | /* Decrease the reference count of a ThrottleGroup. | |
146 | * | |
147 | * When the reference count reaches zero the ThrottleGroup is | |
148 | * destroyed. | |
149 | * | |
432d889e MP |
150 | * This function edits throttle_groups and must be called under the global |
151 | * mutex. | |
152 | * | |
973f2ddf | 153 | * @ts: The ThrottleGroup to unref, given by its ThrottleState member |
2ff1f2e3 | 154 | */ |
973f2ddf | 155 | void throttle_group_unref(ThrottleState *ts) |
2ff1f2e3 | 156 | { |
973f2ddf | 157 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); |
432d889e | 158 | object_unref(OBJECT(tg)); |
2ff1f2e3 AG |
159 | } |
160 | ||
022cdc9f | 161 | /* Get the name from a ThrottleGroupMember's group. The name (and the pointer) |
49d2165d | 162 | * is guaranteed to remain constant during the lifetime of the group. |
2ff1f2e3 | 163 | * |
022cdc9f | 164 | * @tgm: a ThrottleGroupMember |
2ff1f2e3 AG |
165 | * @ret: the name of the group. |
166 | */ | |
022cdc9f | 167 | const char *throttle_group_get_name(ThrottleGroupMember *tgm) |
2ff1f2e3 | 168 | { |
022cdc9f | 169 | ThrottleGroup *tg = container_of(tgm->throttle_state, ThrottleGroup, ts); |
2ff1f2e3 AG |
170 | return tg->name; |
171 | } | |
172 | ||
022cdc9f MP |
173 | /* Return the next ThrottleGroupMember in the round-robin sequence, simulating |
174 | * a circular list. | |
2ff1f2e3 AG |
175 | * |
176 | * This assumes that tg->lock is held. | |
177 | * | |
022cdc9f MP |
178 | * @tgm: the current ThrottleGroupMember |
179 | * @ret: the next ThrottleGroupMember in the sequence | |
2ff1f2e3 | 180 | */ |
022cdc9f | 181 | static ThrottleGroupMember *throttle_group_next_tgm(ThrottleGroupMember *tgm) |
2ff1f2e3 | 182 | { |
022cdc9f | 183 | ThrottleState *ts = tgm->throttle_state; |
2ff1f2e3 | 184 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); |
022cdc9f | 185 | ThrottleGroupMember *next = QLIST_NEXT(tgm, round_robin); |
2ff1f2e3 AG |
186 | |
187 | if (!next) { | |
31dce3cc | 188 | next = QLIST_FIRST(&tg->head); |
2ff1f2e3 AG |
189 | } |
190 | ||
022cdc9f | 191 | return next; |
2ff1f2e3 AG |
192 | } |
193 | ||
6bf77e1c | 194 | /* |
022cdc9f | 195 | * Return whether a ThrottleGroupMember has pending requests. |
6bf77e1c AG |
196 | * |
197 | * This assumes that tg->lock is held. | |
198 | * | |
022cdc9f MP |
199 | * @tgm: the ThrottleGroupMember |
200 | * @is_write: the type of operation (read/write) | |
201 | * @ret: whether the ThrottleGroupMember has pending requests. | |
6bf77e1c | 202 | */ |
022cdc9f | 203 | static inline bool tgm_has_pending_reqs(ThrottleGroupMember *tgm, |
6bf77e1c AG |
204 | bool is_write) |
205 | { | |
022cdc9f | 206 | return tgm->pending_reqs[is_write]; |
6bf77e1c AG |
207 | } |
208 | ||
022cdc9f MP |
209 | /* Return the next ThrottleGroupMember in the round-robin sequence with pending |
210 | * I/O requests. | |
76f4afb4 AG |
211 | * |
212 | * This assumes that tg->lock is held. | |
213 | * | |
022cdc9f | 214 | * @tgm: the current ThrottleGroupMember |
76f4afb4 | 215 | * @is_write: the type of operation (read/write) |
022cdc9f MP |
216 | * @ret: the next ThrottleGroupMember with pending requests, or tgm if |
217 | * there is none. | |
76f4afb4 | 218 | */ |
022cdc9f MP |
219 | static ThrottleGroupMember *next_throttle_token(ThrottleGroupMember *tgm, |
220 | bool is_write) | |
76f4afb4 | 221 | { |
022cdc9f MP |
222 | ThrottleState *ts = tgm->throttle_state; |
223 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | |
224 | ThrottleGroupMember *token, *start; | |
76f4afb4 | 225 | |
5d8e4ca0 AG |
226 | /* If this member has its I/O limits disabled then it means that |
227 | * it's being drained. Skip the round-robin search and return tgm | |
228 | * immediately if it has pending requests. Otherwise we could be | |
229 | * forcing it to wait for other member's throttled requests. */ | |
230 | if (tgm_has_pending_reqs(tgm, is_write) && | |
d73415a3 | 231 | qatomic_read(&tgm->io_limits_disabled)) { |
5d8e4ca0 AG |
232 | return tgm; |
233 | } | |
234 | ||
76f4afb4 AG |
235 | start = token = tg->tokens[is_write]; |
236 | ||
237 | /* get next bs round in round robin style */ | |
022cdc9f MP |
238 | token = throttle_group_next_tgm(token); |
239 | while (token != start && !tgm_has_pending_reqs(token, is_write)) { | |
240 | token = throttle_group_next_tgm(token); | |
76f4afb4 AG |
241 | } |
242 | ||
243 | /* If no IO are queued for scheduling on the next round robin token | |
022cdc9f MP |
244 | * then decide the token is the current tgm because chances are |
245 | * the current tgm got the current request queued. | |
76f4afb4 | 246 | */ |
022cdc9f MP |
247 | if (token == start && !tgm_has_pending_reqs(token, is_write)) { |
248 | token = tgm; | |
76f4afb4 AG |
249 | } |
250 | ||
022cdc9f MP |
251 | /* Either we return the original TGM, or one with pending requests */ |
252 | assert(token == tgm || tgm_has_pending_reqs(token, is_write)); | |
6bf77e1c | 253 | |
76f4afb4 AG |
254 | return token; |
255 | } | |
256 | ||
022cdc9f MP |
257 | /* Check if the next I/O request for a ThrottleGroupMember needs to be |
258 | * throttled or not. If there's no timer set in this group, set one and update | |
259 | * the token accordingly. | |
76f4afb4 AG |
260 | * |
261 | * This assumes that tg->lock is held. | |
262 | * | |
022cdc9f | 263 | * @tgm: the current ThrottleGroupMember |
76f4afb4 AG |
264 | * @is_write: the type of operation (read/write) |
265 | * @ret: whether the I/O request needs to be throttled or not | |
266 | */ | |
022cdc9f MP |
267 | static bool throttle_group_schedule_timer(ThrottleGroupMember *tgm, |
268 | bool is_write) | |
76f4afb4 | 269 | { |
022cdc9f | 270 | ThrottleState *ts = tgm->throttle_state; |
76f4afb4 | 271 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); |
022cdc9f | 272 | ThrottleTimers *tt = &tgm->throttle_timers; |
e76f201f | 273 | ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ; |
76f4afb4 AG |
274 | bool must_wait; |
275 | ||
d73415a3 | 276 | if (qatomic_read(&tgm->io_limits_disabled)) { |
ce0f1412 PB |
277 | return false; |
278 | } | |
279 | ||
76f4afb4 AG |
280 | /* Check if any of the timers in this group is already armed */ |
281 | if (tg->any_timer_armed[is_write]) { | |
282 | return true; | |
283 | } | |
284 | ||
e76f201f | 285 | must_wait = throttle_schedule_timer(ts, tt, direction); |
76f4afb4 | 286 | |
022cdc9f | 287 | /* If a timer just got armed, set tgm as the current token */ |
76f4afb4 | 288 | if (must_wait) { |
022cdc9f | 289 | tg->tokens[is_write] = tgm; |
76f4afb4 AG |
290 | tg->any_timer_armed[is_write] = true; |
291 | } | |
292 | ||
293 | return must_wait; | |
294 | } | |
295 | ||
022cdc9f | 296 | /* Start the next pending I/O request for a ThrottleGroupMember. Return whether |
3b170dc8 PB |
297 | * any request was actually pending. |
298 | * | |
022cdc9f | 299 | * @tgm: the current ThrottleGroupMember |
3b170dc8 PB |
300 | * @is_write: the type of operation (read/write) |
301 | */ | |
022cdc9f | 302 | static bool coroutine_fn throttle_group_co_restart_queue(ThrottleGroupMember *tgm, |
3b170dc8 PB |
303 | bool is_write) |
304 | { | |
93001e9d | 305 | bool ret; |
3b170dc8 | 306 | |
022cdc9f MP |
307 | qemu_co_mutex_lock(&tgm->throttled_reqs_lock); |
308 | ret = qemu_co_queue_next(&tgm->throttled_reqs[is_write]); | |
309 | qemu_co_mutex_unlock(&tgm->throttled_reqs_lock); | |
93001e9d PB |
310 | |
311 | return ret; | |
3b170dc8 PB |
312 | } |
313 | ||
76f4afb4 AG |
314 | /* Look for the next pending I/O request and schedule it. |
315 | * | |
316 | * This assumes that tg->lock is held. | |
317 | * | |
022cdc9f | 318 | * @tgm: the current ThrottleGroupMember |
76f4afb4 AG |
319 | * @is_write: the type of operation (read/write) |
320 | */ | |
022cdc9f | 321 | static void schedule_next_request(ThrottleGroupMember *tgm, bool is_write) |
76f4afb4 | 322 | { |
022cdc9f MP |
323 | ThrottleState *ts = tgm->throttle_state; |
324 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | |
76f4afb4 | 325 | bool must_wait; |
022cdc9f | 326 | ThrottleGroupMember *token; |
76f4afb4 AG |
327 | |
328 | /* Check if there's any pending request to schedule next */ | |
022cdc9f MP |
329 | token = next_throttle_token(tgm, is_write); |
330 | if (!tgm_has_pending_reqs(token, is_write)) { | |
76f4afb4 AG |
331 | return; |
332 | } | |
333 | ||
334 | /* Set a timer for the request if it needs to be throttled */ | |
335 | must_wait = throttle_group_schedule_timer(token, is_write); | |
336 | ||
337 | /* If it doesn't have to wait, queue it for immediate execution */ | |
338 | if (!must_wait) { | |
022cdc9f | 339 | /* Give preference to requests from the current tgm */ |
76f4afb4 | 340 | if (qemu_in_coroutine() && |
022cdc9f MP |
341 | throttle_group_co_restart_queue(tgm, is_write)) { |
342 | token = tgm; | |
76f4afb4 | 343 | } else { |
022cdc9f | 344 | ThrottleTimers *tt = &token->throttle_timers; |
dbe824cc | 345 | int64_t now = qemu_clock_get_ns(tg->clock_type); |
7258ed93 | 346 | timer_mod(tt->timers[is_write], now); |
76f4afb4 AG |
347 | tg->any_timer_armed[is_write] = true; |
348 | } | |
349 | tg->tokens[is_write] = token; | |
350 | } | |
351 | } | |
352 | ||
353 | /* Check if an I/O request needs to be throttled, wait and set a timer | |
354 | * if necessary, and schedule the next request using a round robin | |
355 | * algorithm. | |
356 | * | |
022cdc9f | 357 | * @tgm: the current ThrottleGroupMember |
76f4afb4 AG |
358 | * @bytes: the number of bytes for this I/O |
359 | * @is_write: the type of operation (read/write) | |
360 | */ | |
022cdc9f | 361 | void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm, |
801625e6 | 362 | int64_t bytes, |
76f4afb4 AG |
363 | bool is_write) |
364 | { | |
365 | bool must_wait; | |
022cdc9f MP |
366 | ThrottleGroupMember *token; |
367 | ThrottleGroup *tg = container_of(tgm->throttle_state, ThrottleGroup, ts); | |
e76f201f | 368 | ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ; |
801625e6 VSO |
369 | |
370 | assert(bytes >= 0); | |
371 | ||
76f4afb4 AG |
372 | qemu_mutex_lock(&tg->lock); |
373 | ||
374 | /* First we check if this I/O has to be throttled. */ | |
022cdc9f | 375 | token = next_throttle_token(tgm, is_write); |
76f4afb4 AG |
376 | must_wait = throttle_group_schedule_timer(token, is_write); |
377 | ||
378 | /* Wait if there's a timer set or queued requests of this type */ | |
022cdc9f MP |
379 | if (must_wait || tgm->pending_reqs[is_write]) { |
380 | tgm->pending_reqs[is_write]++; | |
76f4afb4 | 381 | qemu_mutex_unlock(&tg->lock); |
022cdc9f MP |
382 | qemu_co_mutex_lock(&tgm->throttled_reqs_lock); |
383 | qemu_co_queue_wait(&tgm->throttled_reqs[is_write], | |
384 | &tgm->throttled_reqs_lock); | |
385 | qemu_co_mutex_unlock(&tgm->throttled_reqs_lock); | |
76f4afb4 | 386 | qemu_mutex_lock(&tg->lock); |
022cdc9f | 387 | tgm->pending_reqs[is_write]--; |
76f4afb4 AG |
388 | } |
389 | ||
390 | /* The I/O will be executed, so do the accounting */ | |
e76f201f | 391 | throttle_account(tgm->throttle_state, direction, bytes); |
76f4afb4 AG |
392 | |
393 | /* Schedule the next request */ | |
022cdc9f | 394 | schedule_next_request(tgm, is_write); |
76f4afb4 AG |
395 | |
396 | qemu_mutex_unlock(&tg->lock); | |
397 | } | |
398 | ||
3b170dc8 | 399 | typedef struct { |
022cdc9f | 400 | ThrottleGroupMember *tgm; |
3b170dc8 PB |
401 | bool is_write; |
402 | } RestartData; | |
403 | ||
404 | static void coroutine_fn throttle_group_restart_queue_entry(void *opaque) | |
7258ed93 | 405 | { |
3b170dc8 | 406 | RestartData *data = opaque; |
022cdc9f MP |
407 | ThrottleGroupMember *tgm = data->tgm; |
408 | ThrottleState *ts = tgm->throttle_state; | |
409 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | |
3b170dc8 | 410 | bool is_write = data->is_write; |
7258ed93 PB |
411 | bool empty_queue; |
412 | ||
022cdc9f | 413 | empty_queue = !throttle_group_co_restart_queue(tgm, is_write); |
7258ed93 PB |
414 | |
415 | /* If the request queue was empty then we have to take care of | |
416 | * scheduling the next one */ | |
417 | if (empty_queue) { | |
418 | qemu_mutex_lock(&tg->lock); | |
022cdc9f | 419 | schedule_next_request(tgm, is_write); |
7258ed93 PB |
420 | qemu_mutex_unlock(&tg->lock); |
421 | } | |
43a5dc02 MP |
422 | |
423 | g_free(data); | |
bc19a0a6 | 424 | |
d73415a3 | 425 | qatomic_dec(&tgm->restart_pending); |
bc19a0a6 | 426 | aio_wait_kick(); |
7258ed93 PB |
427 | } |
428 | ||
022cdc9f | 429 | static void throttle_group_restart_queue(ThrottleGroupMember *tgm, bool is_write) |
3b170dc8 PB |
430 | { |
431 | Coroutine *co; | |
43a5dc02 MP |
432 | RestartData *rd = g_new0(RestartData, 1); |
433 | ||
434 | rd->tgm = tgm; | |
435 | rd->is_write = is_write; | |
3b170dc8 | 436 | |
25b8e4db AG |
437 | /* This function is called when a timer is fired or when |
438 | * throttle_group_restart_tgm() is called. Either way, there can | |
439 | * be no timer pending on this tgm at this point */ | |
440 | assert(!timer_pending(tgm->throttle_timers.timers[is_write])); | |
441 | ||
d73415a3 | 442 | qatomic_inc(&tgm->restart_pending); |
bc19a0a6 | 443 | |
43a5dc02 | 444 | co = qemu_coroutine_create(throttle_group_restart_queue_entry, rd); |
c61791fc | 445 | aio_co_enter(tgm->aio_context, co); |
3b170dc8 PB |
446 | } |
447 | ||
022cdc9f | 448 | void throttle_group_restart_tgm(ThrottleGroupMember *tgm) |
a72f6414 | 449 | { |
25b8e4db AG |
450 | int i; |
451 | ||
022cdc9f | 452 | if (tgm->throttle_state) { |
25b8e4db AG |
453 | for (i = 0; i < 2; i++) { |
454 | QEMUTimer *t = tgm->throttle_timers.timers[i]; | |
455 | if (timer_pending(t)) { | |
456 | /* If there's a pending timer on this tgm, fire it now */ | |
457 | timer_del(t); | |
458 | timer_cb(tgm, i); | |
459 | } else { | |
460 | /* Else run the next request from the queue manually */ | |
461 | throttle_group_restart_queue(tgm, i); | |
462 | } | |
463 | } | |
a72f6414 PB |
464 | } |
465 | } | |
466 | ||
2ff1f2e3 AG |
467 | /* Update the throttle configuration for a particular group. Similar |
468 | * to throttle_config(), but guarantees atomicity within the | |
469 | * throttling group. | |
470 | * | |
022cdc9f | 471 | * @tgm: a ThrottleGroupMember that is a member of the group |
2ff1f2e3 AG |
472 | * @cfg: the configuration to set |
473 | */ | |
022cdc9f | 474 | void throttle_group_config(ThrottleGroupMember *tgm, ThrottleConfig *cfg) |
2ff1f2e3 | 475 | { |
022cdc9f | 476 | ThrottleState *ts = tgm->throttle_state; |
2ff1f2e3 AG |
477 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); |
478 | qemu_mutex_lock(&tg->lock); | |
27e4cf13 | 479 | throttle_config(ts, tg->clock_type, cfg); |
2ff1f2e3 | 480 | qemu_mutex_unlock(&tg->lock); |
a72f6414 | 481 | |
022cdc9f | 482 | throttle_group_restart_tgm(tgm); |
2ff1f2e3 AG |
483 | } |
484 | ||
485 | /* Get the throttle configuration from a particular group. Similar to | |
486 | * throttle_get_config(), but guarantees atomicity within the | |
487 | * throttling group. | |
488 | * | |
022cdc9f | 489 | * @tgm: a ThrottleGroupMember that is a member of the group |
2ff1f2e3 AG |
490 | * @cfg: the configuration will be written here |
491 | */ | |
022cdc9f | 492 | void throttle_group_get_config(ThrottleGroupMember *tgm, ThrottleConfig *cfg) |
2ff1f2e3 | 493 | { |
022cdc9f | 494 | ThrottleState *ts = tgm->throttle_state; |
2ff1f2e3 AG |
495 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); |
496 | qemu_mutex_lock(&tg->lock); | |
497 | throttle_get_config(ts, cfg); | |
498 | qemu_mutex_unlock(&tg->lock); | |
499 | } | |
500 | ||
76f4afb4 AG |
501 | /* ThrottleTimers callback. This wakes up a request that was waiting |
502 | * because it had been throttled. | |
503 | * | |
c61791fc | 504 | * @tgm: the ThrottleGroupMember whose request had been throttled |
76f4afb4 AG |
505 | * @is_write: the type of operation (read/write) |
506 | */ | |
c61791fc | 507 | static void timer_cb(ThrottleGroupMember *tgm, bool is_write) |
76f4afb4 | 508 | { |
022cdc9f | 509 | ThrottleState *ts = tgm->throttle_state; |
76f4afb4 | 510 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); |
76f4afb4 AG |
511 | |
512 | /* The timer has just been fired, so we can update the flag */ | |
513 | qemu_mutex_lock(&tg->lock); | |
514 | tg->any_timer_armed[is_write] = false; | |
515 | qemu_mutex_unlock(&tg->lock); | |
516 | ||
517 | /* Run the request that was waiting for this timer */ | |
022cdc9f | 518 | throttle_group_restart_queue(tgm, is_write); |
76f4afb4 AG |
519 | } |
520 | ||
521 | static void read_timer_cb(void *opaque) | |
522 | { | |
523 | timer_cb(opaque, false); | |
524 | } | |
525 | ||
526 | static void write_timer_cb(void *opaque) | |
527 | { | |
528 | timer_cb(opaque, true); | |
529 | } | |
530 | ||
022cdc9f MP |
531 | /* Register a ThrottleGroupMember from the throttling group, also initializing |
532 | * its timers and updating its throttle_state pointer to point to it. If a | |
31dce3cc | 533 | * throttling group with that name does not exist yet, it will be created. |
2ff1f2e3 | 534 | * |
432d889e MP |
535 | * This function edits throttle_groups and must be called under the global |
536 | * mutex. | |
537 | * | |
022cdc9f | 538 | * @tgm: the ThrottleGroupMember to insert |
2ff1f2e3 | 539 | * @groupname: the name of the group |
c61791fc | 540 | * @ctx: the AioContext to use |
2ff1f2e3 | 541 | */ |
022cdc9f | 542 | void throttle_group_register_tgm(ThrottleGroupMember *tgm, |
c61791fc MP |
543 | const char *groupname, |
544 | AioContext *ctx) | |
2ff1f2e3 AG |
545 | { |
546 | int i; | |
973f2ddf HR |
547 | ThrottleState *ts = throttle_group_incref(groupname); |
548 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | |
022cdc9f MP |
549 | |
550 | tgm->throttle_state = ts; | |
c61791fc | 551 | tgm->aio_context = ctx; |
d73415a3 | 552 | qatomic_set(&tgm->restart_pending, 0); |
2ff1f2e3 | 553 | |
3af613eb | 554 | QEMU_LOCK_GUARD(&tg->lock); |
022cdc9f | 555 | /* If the ThrottleGroup is new set this ThrottleGroupMember as the token */ |
2ff1f2e3 AG |
556 | for (i = 0; i < 2; i++) { |
557 | if (!tg->tokens[i]) { | |
022cdc9f | 558 | tg->tokens[i] = tgm; |
2ff1f2e3 AG |
559 | } |
560 | } | |
561 | ||
022cdc9f | 562 | QLIST_INSERT_HEAD(&tg->head, tgm, round_robin); |
76f4afb4 | 563 | |
022cdc9f | 564 | throttle_timers_init(&tgm->throttle_timers, |
c61791fc | 565 | tgm->aio_context, |
dbe824cc | 566 | tg->clock_type, |
76f4afb4 AG |
567 | read_timer_cb, |
568 | write_timer_cb, | |
c61791fc | 569 | tgm); |
f738cfc8 MP |
570 | qemu_co_mutex_init(&tgm->throttled_reqs_lock); |
571 | qemu_co_queue_init(&tgm->throttled_reqs[0]); | |
572 | qemu_co_queue_init(&tgm->throttled_reqs[1]); | |
2ff1f2e3 AG |
573 | } |
574 | ||
022cdc9f | 575 | /* Unregister a ThrottleGroupMember from its group, removing it from the list, |
31dce3cc | 576 | * destroying the timers and setting the throttle_state pointer to NULL. |
2ff1f2e3 | 577 | * |
022cdc9f MP |
578 | * The ThrottleGroupMember must not have pending throttled requests, so the |
579 | * caller has to drain them first. | |
5ac72418 | 580 | * |
2ff1f2e3 AG |
581 | * The group will be destroyed if it's empty after this operation. |
582 | * | |
022cdc9f | 583 | * @tgm the ThrottleGroupMember to remove |
2ff1f2e3 | 584 | */ |
022cdc9f | 585 | void throttle_group_unregister_tgm(ThrottleGroupMember *tgm) |
2ff1f2e3 | 586 | { |
022cdc9f MP |
587 | ThrottleState *ts = tgm->throttle_state; |
588 | ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); | |
589 | ThrottleGroupMember *token; | |
2ff1f2e3 AG |
590 | int i; |
591 | ||
d8e7d87e MP |
592 | if (!ts) { |
593 | /* Discard already unregistered tgm */ | |
594 | return; | |
595 | } | |
596 | ||
bc19a0a6 | 597 | /* Wait for throttle_group_restart_queue_entry() coroutines to finish */ |
d73415a3 | 598 | AIO_WAIT_WHILE(tgm->aio_context, qatomic_read(&tgm->restart_pending) > 0); |
bc19a0a6 | 599 | |
3af613eb GQ |
600 | WITH_QEMU_LOCK_GUARD(&tg->lock) { |
601 | for (i = 0; i < 2; i++) { | |
602 | assert(tgm->pending_reqs[i] == 0); | |
603 | assert(qemu_co_queue_empty(&tgm->throttled_reqs[i])); | |
604 | assert(!timer_pending(tgm->throttle_timers.timers[i])); | |
605 | if (tg->tokens[i] == tgm) { | |
606 | token = throttle_group_next_tgm(tgm); | |
607 | /* Take care of the case where this is the last tgm in the group */ | |
608 | if (token == tgm) { | |
609 | token = NULL; | |
610 | } | |
611 | tg->tokens[i] = token; | |
2ff1f2e3 | 612 | } |
2ff1f2e3 | 613 | } |
2ff1f2e3 | 614 | |
3af613eb GQ |
615 | /* remove the current tgm from the list */ |
616 | QLIST_REMOVE(tgm, round_robin); | |
617 | throttle_timers_destroy(&tgm->throttle_timers); | |
618 | } | |
2ff1f2e3 | 619 | |
973f2ddf | 620 | throttle_group_unref(&tg->ts); |
022cdc9f | 621 | tgm->throttle_state = NULL; |
2ff1f2e3 AG |
622 | } |
623 | ||
c61791fc MP |
624 | void throttle_group_attach_aio_context(ThrottleGroupMember *tgm, |
625 | AioContext *new_context) | |
626 | { | |
627 | ThrottleTimers *tt = &tgm->throttle_timers; | |
628 | throttle_timers_attach_aio_context(tt, new_context); | |
629 | tgm->aio_context = new_context; | |
630 | } | |
631 | ||
632 | void throttle_group_detach_aio_context(ThrottleGroupMember *tgm) | |
633 | { | |
341e0b56 | 634 | ThrottleGroup *tg = container_of(tgm->throttle_state, ThrottleGroup, ts); |
c61791fc | 635 | ThrottleTimers *tt = &tgm->throttle_timers; |
341e0b56 | 636 | int i; |
dc868fb0 SH |
637 | |
638 | /* Requests must have been drained */ | |
639 | assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0); | |
640 | assert(qemu_co_queue_empty(&tgm->throttled_reqs[0])); | |
641 | assert(qemu_co_queue_empty(&tgm->throttled_reqs[1])); | |
642 | ||
341e0b56 | 643 | /* Kick off next ThrottleGroupMember, if necessary */ |
3af613eb GQ |
644 | WITH_QEMU_LOCK_GUARD(&tg->lock) { |
645 | for (i = 0; i < 2; i++) { | |
646 | if (timer_pending(tt->timers[i])) { | |
647 | tg->any_timer_armed[i] = false; | |
648 | schedule_next_request(tgm, i); | |
649 | } | |
341e0b56 SH |
650 | } |
651 | } | |
341e0b56 | 652 | |
c61791fc MP |
653 | throttle_timers_detach_aio_context(tt); |
654 | tgm->aio_context = NULL; | |
655 | } | |
656 | ||
432d889e MP |
657 | #undef THROTTLE_OPT_PREFIX |
658 | #define THROTTLE_OPT_PREFIX "x-" | |
659 | ||
660 | /* Helper struct and array for QOM property setter/getter */ | |
661 | typedef struct { | |
662 | const char *name; | |
663 | BucketType type; | |
664 | enum { | |
665 | AVG, | |
666 | MAX, | |
667 | BURST_LENGTH, | |
668 | IOPS_SIZE, | |
669 | } category; | |
670 | } ThrottleParamInfo; | |
671 | ||
672 | static ThrottleParamInfo properties[] = { | |
673 | { | |
674 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL, | |
675 | THROTTLE_OPS_TOTAL, AVG, | |
676 | }, | |
677 | { | |
678 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL_MAX, | |
679 | THROTTLE_OPS_TOTAL, MAX, | |
680 | }, | |
681 | { | |
682 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL_MAX_LENGTH, | |
683 | THROTTLE_OPS_TOTAL, BURST_LENGTH, | |
684 | }, | |
685 | { | |
686 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_READ, | |
687 | THROTTLE_OPS_READ, AVG, | |
688 | }, | |
689 | { | |
690 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_READ_MAX, | |
691 | THROTTLE_OPS_READ, MAX, | |
692 | }, | |
693 | { | |
694 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_READ_MAX_LENGTH, | |
695 | THROTTLE_OPS_READ, BURST_LENGTH, | |
696 | }, | |
697 | { | |
698 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE, | |
699 | THROTTLE_OPS_WRITE, AVG, | |
700 | }, | |
701 | { | |
702 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE_MAX, | |
703 | THROTTLE_OPS_WRITE, MAX, | |
704 | }, | |
705 | { | |
706 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE_MAX_LENGTH, | |
707 | THROTTLE_OPS_WRITE, BURST_LENGTH, | |
708 | }, | |
709 | { | |
710 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_TOTAL, | |
711 | THROTTLE_BPS_TOTAL, AVG, | |
712 | }, | |
713 | { | |
714 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_TOTAL_MAX, | |
715 | THROTTLE_BPS_TOTAL, MAX, | |
716 | }, | |
717 | { | |
718 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_TOTAL_MAX_LENGTH, | |
719 | THROTTLE_BPS_TOTAL, BURST_LENGTH, | |
720 | }, | |
721 | { | |
722 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_READ, | |
723 | THROTTLE_BPS_READ, AVG, | |
724 | }, | |
725 | { | |
726 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_READ_MAX, | |
727 | THROTTLE_BPS_READ, MAX, | |
728 | }, | |
729 | { | |
730 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_READ_MAX_LENGTH, | |
731 | THROTTLE_BPS_READ, BURST_LENGTH, | |
732 | }, | |
733 | { | |
734 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_WRITE, | |
735 | THROTTLE_BPS_WRITE, AVG, | |
736 | }, | |
737 | { | |
738 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_WRITE_MAX, | |
739 | THROTTLE_BPS_WRITE, MAX, | |
740 | }, | |
741 | { | |
742 | THROTTLE_OPT_PREFIX QEMU_OPT_BPS_WRITE_MAX_LENGTH, | |
743 | THROTTLE_BPS_WRITE, BURST_LENGTH, | |
744 | }, | |
745 | { | |
746 | THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_SIZE, | |
747 | 0, IOPS_SIZE, | |
748 | } | |
749 | }; | |
750 | ||
751 | /* This function edits throttle_groups and must be called under the global | |
752 | * mutex */ | |
753 | static void throttle_group_obj_init(Object *obj) | |
754 | { | |
755 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
756 | ||
757 | tg->clock_type = QEMU_CLOCK_REALTIME; | |
758 | if (qtest_enabled()) { | |
759 | /* For testing block IO throttling only */ | |
760 | tg->clock_type = QEMU_CLOCK_VIRTUAL; | |
761 | } | |
762 | tg->is_initialized = false; | |
763 | qemu_mutex_init(&tg->lock); | |
764 | throttle_init(&tg->ts); | |
765 | QLIST_INIT(&tg->head); | |
766 | } | |
767 | ||
768 | /* This function edits throttle_groups and must be called under the global | |
769 | * mutex */ | |
770 | static void throttle_group_obj_complete(UserCreatable *obj, Error **errp) | |
771 | { | |
772 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
773 | ThrottleConfig cfg; | |
774 | ||
775 | /* set group name to object id if it exists */ | |
776 | if (!tg->name && tg->parent_obj.parent) { | |
7a309cc9 | 777 | tg->name = g_strdup(object_get_canonical_path_component(OBJECT(obj))); |
432d889e MP |
778 | } |
779 | /* We must have a group name at this point */ | |
780 | assert(tg->name); | |
781 | ||
782 | /* error if name is duplicate */ | |
d8e7d87e | 783 | if (throttle_group_exists(tg->name)) { |
432d889e MP |
784 | error_setg(errp, "A group with this name already exists"); |
785 | return; | |
786 | } | |
787 | ||
788 | /* check validity */ | |
789 | throttle_get_config(&tg->ts, &cfg); | |
790 | if (!throttle_is_valid(&cfg, errp)) { | |
791 | return; | |
792 | } | |
793 | throttle_config(&tg->ts, tg->clock_type, &cfg); | |
794 | QTAILQ_INSERT_TAIL(&throttle_groups, tg, list); | |
795 | tg->is_initialized = true; | |
796 | } | |
797 | ||
798 | /* This function edits throttle_groups and must be called under the global | |
799 | * mutex */ | |
800 | static void throttle_group_obj_finalize(Object *obj) | |
801 | { | |
802 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
803 | if (tg->is_initialized) { | |
804 | QTAILQ_REMOVE(&throttle_groups, tg, list); | |
805 | } | |
806 | qemu_mutex_destroy(&tg->lock); | |
807 | g_free(tg->name); | |
808 | } | |
809 | ||
810 | static void throttle_group_set(Object *obj, Visitor *v, const char * name, | |
811 | void *opaque, Error **errp) | |
812 | ||
813 | { | |
814 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
815 | ThrottleConfig *cfg; | |
816 | ThrottleParamInfo *info = opaque; | |
432d889e MP |
817 | int64_t value; |
818 | ||
819 | /* If we have finished initialization, don't accept individual property | |
820 | * changes through QOM. Throttle configuration limits must be set in one | |
821 | * transaction, as certain combinations are invalid. | |
822 | */ | |
823 | if (tg->is_initialized) { | |
dcfe4805 MA |
824 | error_setg(errp, "Property cannot be set after initialization"); |
825 | return; | |
432d889e MP |
826 | } |
827 | ||
668f62ec | 828 | if (!visit_type_int64(v, name, &value, errp)) { |
dcfe4805 | 829 | return; |
432d889e MP |
830 | } |
831 | if (value < 0) { | |
dcfe4805 MA |
832 | error_setg(errp, "Property values cannot be negative"); |
833 | return; | |
432d889e MP |
834 | } |
835 | ||
836 | cfg = &tg->ts.cfg; | |
837 | switch (info->category) { | |
838 | case AVG: | |
839 | cfg->buckets[info->type].avg = value; | |
840 | break; | |
841 | case MAX: | |
842 | cfg->buckets[info->type].max = value; | |
843 | break; | |
844 | case BURST_LENGTH: | |
845 | if (value > UINT_MAX) { | |
dcfe4805 MA |
846 | error_setg(errp, "%s value must be in the" "range [0, %u]", |
847 | info->name, UINT_MAX); | |
848 | return; | |
432d889e MP |
849 | } |
850 | cfg->buckets[info->type].burst_length = value; | |
851 | break; | |
852 | case IOPS_SIZE: | |
853 | cfg->op_size = value; | |
854 | break; | |
855 | } | |
432d889e MP |
856 | } |
857 | ||
858 | static void throttle_group_get(Object *obj, Visitor *v, const char *name, | |
859 | void *opaque, Error **errp) | |
860 | { | |
861 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
862 | ThrottleConfig cfg; | |
863 | ThrottleParamInfo *info = opaque; | |
864 | int64_t value; | |
865 | ||
866 | throttle_get_config(&tg->ts, &cfg); | |
867 | switch (info->category) { | |
868 | case AVG: | |
869 | value = cfg.buckets[info->type].avg; | |
870 | break; | |
871 | case MAX: | |
872 | value = cfg.buckets[info->type].max; | |
873 | break; | |
874 | case BURST_LENGTH: | |
875 | value = cfg.buckets[info->type].burst_length; | |
876 | break; | |
877 | case IOPS_SIZE: | |
878 | value = cfg.op_size; | |
879 | break; | |
880 | } | |
881 | ||
882 | visit_type_int64(v, name, &value, errp); | |
883 | } | |
884 | ||
885 | static void throttle_group_set_limits(Object *obj, Visitor *v, | |
886 | const char *name, void *opaque, | |
887 | Error **errp) | |
888 | ||
889 | { | |
890 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
891 | ThrottleConfig cfg; | |
88be15a9 | 892 | ThrottleLimits *argp; |
432d889e MP |
893 | Error *local_err = NULL; |
894 | ||
14217038 MA |
895 | if (!visit_type_ThrottleLimits(v, name, &argp, errp)) { |
896 | return; | |
432d889e MP |
897 | } |
898 | qemu_mutex_lock(&tg->lock); | |
899 | throttle_get_config(&tg->ts, &cfg); | |
900 | throttle_limits_to_config(argp, &cfg, &local_err); | |
901 | if (local_err) { | |
902 | goto unlock; | |
903 | } | |
904 | throttle_config(&tg->ts, tg->clock_type, &cfg); | |
905 | ||
906 | unlock: | |
907 | qemu_mutex_unlock(&tg->lock); | |
88be15a9 | 908 | qapi_free_ThrottleLimits(argp); |
432d889e MP |
909 | error_propagate(errp, local_err); |
910 | return; | |
911 | } | |
912 | ||
913 | static void throttle_group_get_limits(Object *obj, Visitor *v, | |
914 | const char *name, void *opaque, | |
915 | Error **errp) | |
916 | { | |
917 | ThrottleGroup *tg = THROTTLE_GROUP(obj); | |
918 | ThrottleConfig cfg; | |
919 | ThrottleLimits arg = { 0 }; | |
920 | ThrottleLimits *argp = &arg; | |
921 | ||
922 | qemu_mutex_lock(&tg->lock); | |
923 | throttle_get_config(&tg->ts, &cfg); | |
924 | qemu_mutex_unlock(&tg->lock); | |
925 | ||
926 | throttle_config_to_limits(&cfg, argp); | |
927 | ||
928 | visit_type_ThrottleLimits(v, name, &argp, errp); | |
929 | } | |
930 | ||
931 | static bool throttle_group_can_be_deleted(UserCreatable *uc) | |
932 | { | |
933 | return OBJECT(uc)->ref == 1; | |
934 | } | |
935 | ||
936 | static void throttle_group_obj_class_init(ObjectClass *klass, void *class_data) | |
937 | { | |
938 | size_t i = 0; | |
939 | UserCreatableClass *ucc = USER_CREATABLE_CLASS(klass); | |
940 | ||
941 | ucc->complete = throttle_group_obj_complete; | |
942 | ucc->can_be_deleted = throttle_group_can_be_deleted; | |
943 | ||
944 | /* individual properties */ | |
945 | for (i = 0; i < sizeof(properties) / sizeof(ThrottleParamInfo); i++) { | |
946 | object_class_property_add(klass, | |
947 | properties[i].name, | |
948 | "int", | |
949 | throttle_group_get, | |
950 | throttle_group_set, | |
d2623129 | 951 | NULL, &properties[i]); |
432d889e MP |
952 | } |
953 | ||
954 | /* ThrottleLimits */ | |
955 | object_class_property_add(klass, | |
956 | "limits", "ThrottleLimits", | |
957 | throttle_group_get_limits, | |
958 | throttle_group_set_limits, | |
d2623129 | 959 | NULL, NULL); |
432d889e MP |
960 | } |
961 | ||
962 | static const TypeInfo throttle_group_info = { | |
963 | .name = TYPE_THROTTLE_GROUP, | |
964 | .parent = TYPE_OBJECT, | |
965 | .class_init = throttle_group_obj_class_init, | |
966 | .instance_size = sizeof(ThrottleGroup), | |
967 | .instance_init = throttle_group_obj_init, | |
968 | .instance_finalize = throttle_group_obj_finalize, | |
969 | .interfaces = (InterfaceInfo[]) { | |
970 | { TYPE_USER_CREATABLE }, | |
971 | { } | |
972 | }, | |
973 | }; | |
974 | ||
2ff1f2e3 AG |
975 | static void throttle_groups_init(void) |
976 | { | |
432d889e | 977 | type_register_static(&throttle_group_info); |
2ff1f2e3 AG |
978 | } |
979 | ||
432d889e | 980 | type_init(throttle_groups_init); |