blk-cgroup.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * Common Block IO controller cgroup interface
  3. *
  4. * Based on ideas and code from CFQ, CFS and BFQ:
  5. * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
  6. *
  7. * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
  8. * Paolo Valente <paolo.valente@unimore.it>
  9. *
  10. * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
  11. * Nauman Rafique <nauman@google.com>
  12. */
  13. #include <linux/ioprio.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/kdev_t.h>
  16. #include <linux/module.h>
  17. #include <linux/err.h>
  18. #include <linux/blkdev.h>
  19. #include "blk-cgroup.h"
  20. #define MAX_KEY_LEN 100
  21. static DEFINE_SPINLOCK(blkio_list_lock);
  22. static LIST_HEAD(blkio_list);
  23. struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT };
  24. EXPORT_SYMBOL_GPL(blkio_root_cgroup);
  25. static struct cgroup_subsys_state *blkiocg_create(struct cgroup_subsys *,
  26. struct cgroup *);
  27. static int blkiocg_can_attach(struct cgroup_subsys *, struct cgroup *,
  28. struct task_struct *, bool);
  29. static void blkiocg_attach(struct cgroup_subsys *, struct cgroup *,
  30. struct cgroup *, struct task_struct *, bool);
  31. static void blkiocg_destroy(struct cgroup_subsys *, struct cgroup *);
  32. static int blkiocg_populate(struct cgroup_subsys *, struct cgroup *);
  33. struct cgroup_subsys blkio_subsys = {
  34. .name = "blkio",
  35. .create = blkiocg_create,
  36. .can_attach = blkiocg_can_attach,
  37. .attach = blkiocg_attach,
  38. .destroy = blkiocg_destroy,
  39. .populate = blkiocg_populate,
  40. #ifdef CONFIG_BLK_CGROUP
  41. /* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */
  42. .subsys_id = blkio_subsys_id,
  43. #endif
  44. .use_id = 1,
  45. .module = THIS_MODULE,
  46. };
  47. EXPORT_SYMBOL_GPL(blkio_subsys);
  48. struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup)
  49. {
  50. return container_of(cgroup_subsys_state(cgroup, blkio_subsys_id),
  51. struct blkio_cgroup, css);
  52. }
  53. EXPORT_SYMBOL_GPL(cgroup_to_blkio_cgroup);
  54. void blkio_group_init(struct blkio_group *blkg)
  55. {
  56. spin_lock_init(&blkg->stats_lock);
  57. }
  58. EXPORT_SYMBOL_GPL(blkio_group_init);
  59. /*
  60. * Add to the appropriate stat variable depending on the request type.
  61. * This should be called with the blkg->stats_lock held.
  62. */
  63. static void blkio_add_stat(uint64_t *stat, uint64_t add, bool direction,
  64. bool sync)
  65. {
  66. if (direction)
  67. stat[BLKIO_STAT_WRITE] += add;
  68. else
  69. stat[BLKIO_STAT_READ] += add;
  70. if (sync)
  71. stat[BLKIO_STAT_SYNC] += add;
  72. else
  73. stat[BLKIO_STAT_ASYNC] += add;
  74. }
  75. void blkiocg_update_timeslice_used(struct blkio_group *blkg, unsigned long time)
  76. {
  77. unsigned long flags;
  78. spin_lock_irqsave(&blkg->stats_lock, flags);
  79. blkg->stats.time += time;
  80. spin_unlock_irqrestore(&blkg->stats_lock, flags);
  81. }
  82. EXPORT_SYMBOL_GPL(blkiocg_update_timeslice_used);
  83. void blkiocg_update_dispatch_stats(struct blkio_group *blkg,
  84. uint64_t bytes, bool direction, bool sync)
  85. {
  86. struct blkio_group_stats *stats;
  87. unsigned long flags;
  88. spin_lock_irqsave(&blkg->stats_lock, flags);
  89. stats = &blkg->stats;
  90. stats->sectors += bytes >> 9;
  91. blkio_add_stat(stats->stat_arr[BLKIO_STAT_SERVICED], 1, direction,
  92. sync);
  93. blkio_add_stat(stats->stat_arr[BLKIO_STAT_SERVICE_BYTES], bytes,
  94. direction, sync);
  95. spin_unlock_irqrestore(&blkg->stats_lock, flags);
  96. }
  97. EXPORT_SYMBOL_GPL(blkiocg_update_dispatch_stats);
  98. void blkiocg_update_completion_stats(struct blkio_group *blkg,
  99. uint64_t start_time, uint64_t io_start_time, bool direction, bool sync)
  100. {
  101. struct blkio_group_stats *stats;
  102. unsigned long flags;
  103. unsigned long long now = sched_clock();
  104. spin_lock_irqsave(&blkg->stats_lock, flags);
  105. stats = &blkg->stats;
  106. if (time_after64(now, io_start_time))
  107. blkio_add_stat(stats->stat_arr[BLKIO_STAT_SERVICE_TIME],
  108. now - io_start_time, direction, sync);
  109. if (time_after64(io_start_time, start_time))
  110. blkio_add_stat(stats->stat_arr[BLKIO_STAT_WAIT_TIME],
  111. io_start_time - start_time, direction, sync);
  112. spin_unlock_irqrestore(&blkg->stats_lock, flags);
  113. }
  114. EXPORT_SYMBOL_GPL(blkiocg_update_completion_stats);
  115. void blkiocg_update_io_merged_stats(struct blkio_group *blkg, bool direction,
  116. bool sync)
  117. {
  118. unsigned long flags;
  119. spin_lock_irqsave(&blkg->stats_lock, flags);
  120. blkio_add_stat(blkg->stats.stat_arr[BLKIO_STAT_MERGED], 1, direction,
  121. sync);
  122. spin_unlock_irqrestore(&blkg->stats_lock, flags);
  123. }
  124. EXPORT_SYMBOL_GPL(blkiocg_update_io_merged_stats);
  125. void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
  126. struct blkio_group *blkg, void *key, dev_t dev)
  127. {
  128. unsigned long flags;
  129. spin_lock_irqsave(&blkcg->lock, flags);
  130. rcu_assign_pointer(blkg->key, key);
  131. blkg->blkcg_id = css_id(&blkcg->css);
  132. hlist_add_head_rcu(&blkg->blkcg_node, &blkcg->blkg_list);
  133. spin_unlock_irqrestore(&blkcg->lock, flags);
  134. #ifdef CONFIG_DEBUG_BLK_CGROUP
  135. /* Need to take css reference ? */
  136. cgroup_path(blkcg->css.cgroup, blkg->path, sizeof(blkg->path));
  137. #endif
  138. blkg->dev = dev;
  139. }
  140. EXPORT_SYMBOL_GPL(blkiocg_add_blkio_group);
  141. static void __blkiocg_del_blkio_group(struct blkio_group *blkg)
  142. {
  143. hlist_del_init_rcu(&blkg->blkcg_node);
  144. blkg->blkcg_id = 0;
  145. }
  146. /*
  147. * returns 0 if blkio_group was still on cgroup list. Otherwise returns 1
  148. * indicating that blk_group was unhashed by the time we got to it.
  149. */
  150. int blkiocg_del_blkio_group(struct blkio_group *blkg)
  151. {
  152. struct blkio_cgroup *blkcg;
  153. unsigned long flags;
  154. struct cgroup_subsys_state *css;
  155. int ret = 1;
  156. rcu_read_lock();
  157. css = css_lookup(&blkio_subsys, blkg->blkcg_id);
  158. if (!css)
  159. goto out;
  160. blkcg = container_of(css, struct blkio_cgroup, css);
  161. spin_lock_irqsave(&blkcg->lock, flags);
  162. if (!hlist_unhashed(&blkg->blkcg_node)) {
  163. __blkiocg_del_blkio_group(blkg);
  164. ret = 0;
  165. }
  166. spin_unlock_irqrestore(&blkcg->lock, flags);
  167. out:
  168. rcu_read_unlock();
  169. return ret;
  170. }
  171. EXPORT_SYMBOL_GPL(blkiocg_del_blkio_group);
  172. /* called under rcu_read_lock(). */
  173. struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key)
  174. {
  175. struct blkio_group *blkg;
  176. struct hlist_node *n;
  177. void *__key;
  178. hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) {
  179. __key = blkg->key;
  180. if (__key == key)
  181. return blkg;
  182. }
  183. return NULL;
  184. }
  185. EXPORT_SYMBOL_GPL(blkiocg_lookup_group);
  186. #define SHOW_FUNCTION(__VAR) \
  187. static u64 blkiocg_##__VAR##_read(struct cgroup *cgroup, \
  188. struct cftype *cftype) \
  189. { \
  190. struct blkio_cgroup *blkcg; \
  191. \
  192. blkcg = cgroup_to_blkio_cgroup(cgroup); \
  193. return (u64)blkcg->__VAR; \
  194. }
  195. SHOW_FUNCTION(weight);
  196. #undef SHOW_FUNCTION
  197. static int
  198. blkiocg_weight_write(struct cgroup *cgroup, struct cftype *cftype, u64 val)
  199. {
  200. struct blkio_cgroup *blkcg;
  201. struct blkio_group *blkg;
  202. struct hlist_node *n;
  203. struct blkio_policy_type *blkiop;
  204. if (val < BLKIO_WEIGHT_MIN || val > BLKIO_WEIGHT_MAX)
  205. return -EINVAL;
  206. blkcg = cgroup_to_blkio_cgroup(cgroup);
  207. spin_lock(&blkio_list_lock);
  208. spin_lock_irq(&blkcg->lock);
  209. blkcg->weight = (unsigned int)val;
  210. hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) {
  211. list_for_each_entry(blkiop, &blkio_list, list)
  212. blkiop->ops.blkio_update_group_weight_fn(blkg,
  213. blkcg->weight);
  214. }
  215. spin_unlock_irq(&blkcg->lock);
  216. spin_unlock(&blkio_list_lock);
  217. return 0;
  218. }
  219. static int
  220. blkiocg_reset_stats(struct cgroup *cgroup, struct cftype *cftype, u64 val)
  221. {
  222. struct blkio_cgroup *blkcg;
  223. struct blkio_group *blkg;
  224. struct hlist_node *n;
  225. struct blkio_group_stats *stats;
  226. blkcg = cgroup_to_blkio_cgroup(cgroup);
  227. spin_lock_irq(&blkcg->lock);
  228. hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) {
  229. spin_lock(&blkg->stats_lock);
  230. stats = &blkg->stats;
  231. memset(stats, 0, sizeof(struct blkio_group_stats));
  232. spin_unlock(&blkg->stats_lock);
  233. }
  234. spin_unlock_irq(&blkcg->lock);
  235. return 0;
  236. }
  237. static void blkio_get_key_name(enum stat_sub_type type, dev_t dev, char *str,
  238. int chars_left, bool diskname_only)
  239. {
  240. snprintf(str, chars_left, "%d:%d", MAJOR(dev), MINOR(dev));
  241. chars_left -= strlen(str);
  242. if (chars_left <= 0) {
  243. printk(KERN_WARNING
  244. "Possibly incorrect cgroup stat display format");
  245. return;
  246. }
  247. if (diskname_only)
  248. return;
  249. switch (type) {
  250. case BLKIO_STAT_READ:
  251. strlcat(str, " Read", chars_left);
  252. break;
  253. case BLKIO_STAT_WRITE:
  254. strlcat(str, " Write", chars_left);
  255. break;
  256. case BLKIO_STAT_SYNC:
  257. strlcat(str, " Sync", chars_left);
  258. break;
  259. case BLKIO_STAT_ASYNC:
  260. strlcat(str, " Async", chars_left);
  261. break;
  262. case BLKIO_STAT_TOTAL:
  263. strlcat(str, " Total", chars_left);
  264. break;
  265. default:
  266. strlcat(str, " Invalid", chars_left);
  267. }
  268. }
  269. static uint64_t blkio_fill_stat(char *str, int chars_left, uint64_t val,
  270. struct cgroup_map_cb *cb, dev_t dev)
  271. {
  272. blkio_get_key_name(0, dev, str, chars_left, true);
  273. cb->fill(cb, str, val);
  274. return val;
  275. }
  276. /* This should be called with blkg->stats_lock held */
  277. static uint64_t blkio_get_stat(struct blkio_group *blkg,
  278. struct cgroup_map_cb *cb, dev_t dev, enum stat_type type)
  279. {
  280. uint64_t disk_total;
  281. char key_str[MAX_KEY_LEN];
  282. enum stat_sub_type sub_type;
  283. if (type == BLKIO_STAT_TIME)
  284. return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
  285. blkg->stats.time, cb, dev);
  286. if (type == BLKIO_STAT_SECTORS)
  287. return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
  288. blkg->stats.sectors, cb, dev);
  289. #ifdef CONFIG_DEBUG_BLK_CGROUP
  290. if (type == BLKIO_STAT_DEQUEUE)
  291. return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
  292. blkg->stats.dequeue, cb, dev);
  293. #endif
  294. for (sub_type = BLKIO_STAT_READ; sub_type < BLKIO_STAT_TOTAL;
  295. sub_type++) {
  296. blkio_get_key_name(sub_type, dev, key_str, MAX_KEY_LEN, false);
  297. cb->fill(cb, key_str, blkg->stats.stat_arr[type][sub_type]);
  298. }
  299. disk_total = blkg->stats.stat_arr[type][BLKIO_STAT_READ] +
  300. blkg->stats.stat_arr[type][BLKIO_STAT_WRITE];
  301. blkio_get_key_name(BLKIO_STAT_TOTAL, dev, key_str, MAX_KEY_LEN, false);
  302. cb->fill(cb, key_str, disk_total);
  303. return disk_total;
  304. }
  305. #define SHOW_FUNCTION_PER_GROUP(__VAR, type, show_total) \
  306. static int blkiocg_##__VAR##_read(struct cgroup *cgroup, \
  307. struct cftype *cftype, struct cgroup_map_cb *cb) \
  308. { \
  309. struct blkio_cgroup *blkcg; \
  310. struct blkio_group *blkg; \
  311. struct hlist_node *n; \
  312. uint64_t cgroup_total = 0; \
  313. \
  314. if (!cgroup_lock_live_group(cgroup)) \
  315. return -ENODEV; \
  316. \
  317. blkcg = cgroup_to_blkio_cgroup(cgroup); \
  318. rcu_read_lock(); \
  319. hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) {\
  320. if (blkg->dev) { \
  321. spin_lock_irq(&blkg->stats_lock); \
  322. cgroup_total += blkio_get_stat(blkg, cb, \
  323. blkg->dev, type); \
  324. spin_unlock_irq(&blkg->stats_lock); \
  325. } \
  326. } \
  327. if (show_total) \
  328. cb->fill(cb, "Total", cgroup_total); \
  329. rcu_read_unlock(); \
  330. cgroup_unlock(); \
  331. return 0; \
  332. }
  333. SHOW_FUNCTION_PER_GROUP(time, BLKIO_STAT_TIME, 0);
  334. SHOW_FUNCTION_PER_GROUP(sectors, BLKIO_STAT_SECTORS, 0);
  335. SHOW_FUNCTION_PER_GROUP(io_service_bytes, BLKIO_STAT_SERVICE_BYTES, 1);
  336. SHOW_FUNCTION_PER_GROUP(io_serviced, BLKIO_STAT_SERVICED, 1);
  337. SHOW_FUNCTION_PER_GROUP(io_service_time, BLKIO_STAT_SERVICE_TIME, 1);
  338. SHOW_FUNCTION_PER_GROUP(io_wait_time, BLKIO_STAT_WAIT_TIME, 1);
  339. SHOW_FUNCTION_PER_GROUP(io_merged, BLKIO_STAT_MERGED, 1);
  340. #ifdef CONFIG_DEBUG_BLK_CGROUP
  341. SHOW_FUNCTION_PER_GROUP(dequeue, BLKIO_STAT_DEQUEUE, 0);
  342. #endif
  343. #undef SHOW_FUNCTION_PER_GROUP
  344. #ifdef CONFIG_DEBUG_BLK_CGROUP
  345. void blkiocg_update_dequeue_stats(struct blkio_group *blkg,
  346. unsigned long dequeue)
  347. {
  348. blkg->stats.dequeue += dequeue;
  349. }
  350. EXPORT_SYMBOL_GPL(blkiocg_update_dequeue_stats);
  351. #endif
  352. struct cftype blkio_files[] = {
  353. {
  354. .name = "weight",
  355. .read_u64 = blkiocg_weight_read,
  356. .write_u64 = blkiocg_weight_write,
  357. },
  358. {
  359. .name = "time",
  360. .read_map = blkiocg_time_read,
  361. },
  362. {
  363. .name = "sectors",
  364. .read_map = blkiocg_sectors_read,
  365. },
  366. {
  367. .name = "io_service_bytes",
  368. .read_map = blkiocg_io_service_bytes_read,
  369. },
  370. {
  371. .name = "io_serviced",
  372. .read_map = blkiocg_io_serviced_read,
  373. },
  374. {
  375. .name = "io_service_time",
  376. .read_map = blkiocg_io_service_time_read,
  377. },
  378. {
  379. .name = "io_wait_time",
  380. .read_map = blkiocg_io_wait_time_read,
  381. },
  382. {
  383. .name = "io_merged",
  384. .read_map = blkiocg_io_merged_read,
  385. },
  386. {
  387. .name = "reset_stats",
  388. .write_u64 = blkiocg_reset_stats,
  389. },
  390. #ifdef CONFIG_DEBUG_BLK_CGROUP
  391. {
  392. .name = "dequeue",
  393. .read_map = blkiocg_dequeue_read,
  394. },
  395. #endif
  396. };
  397. static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup)
  398. {
  399. return cgroup_add_files(cgroup, subsys, blkio_files,
  400. ARRAY_SIZE(blkio_files));
  401. }
  402. static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup)
  403. {
  404. struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup);
  405. unsigned long flags;
  406. struct blkio_group *blkg;
  407. void *key;
  408. struct blkio_policy_type *blkiop;
  409. rcu_read_lock();
  410. remove_entry:
  411. spin_lock_irqsave(&blkcg->lock, flags);
  412. if (hlist_empty(&blkcg->blkg_list)) {
  413. spin_unlock_irqrestore(&blkcg->lock, flags);
  414. goto done;
  415. }
  416. blkg = hlist_entry(blkcg->blkg_list.first, struct blkio_group,
  417. blkcg_node);
  418. key = rcu_dereference(blkg->key);
  419. __blkiocg_del_blkio_group(blkg);
  420. spin_unlock_irqrestore(&blkcg->lock, flags);
  421. /*
  422. * This blkio_group is being unlinked as associated cgroup is going
  423. * away. Let all the IO controlling policies know about this event.
  424. *
  425. * Currently this is static call to one io controlling policy. Once
  426. * we have more policies in place, we need some dynamic registration
  427. * of callback function.
  428. */
  429. spin_lock(&blkio_list_lock);
  430. list_for_each_entry(blkiop, &blkio_list, list)
  431. blkiop->ops.blkio_unlink_group_fn(key, blkg);
  432. spin_unlock(&blkio_list_lock);
  433. goto remove_entry;
  434. done:
  435. free_css_id(&blkio_subsys, &blkcg->css);
  436. rcu_read_unlock();
  437. if (blkcg != &blkio_root_cgroup)
  438. kfree(blkcg);
  439. }
  440. static struct cgroup_subsys_state *
  441. blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup)
  442. {
  443. struct blkio_cgroup *blkcg, *parent_blkcg;
  444. if (!cgroup->parent) {
  445. blkcg = &blkio_root_cgroup;
  446. goto done;
  447. }
  448. /* Currently we do not support hierarchy deeper than two level (0,1) */
  449. parent_blkcg = cgroup_to_blkio_cgroup(cgroup->parent);
  450. if (css_depth(&parent_blkcg->css) > 0)
  451. return ERR_PTR(-EINVAL);
  452. blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
  453. if (!blkcg)
  454. return ERR_PTR(-ENOMEM);
  455. blkcg->weight = BLKIO_WEIGHT_DEFAULT;
  456. done:
  457. spin_lock_init(&blkcg->lock);
  458. INIT_HLIST_HEAD(&blkcg->blkg_list);
  459. return &blkcg->css;
  460. }
  461. /*
  462. * We cannot support shared io contexts, as we have no mean to support
  463. * two tasks with the same ioc in two different groups without major rework
  464. * of the main cic data structures. For now we allow a task to change
  465. * its cgroup only if it's the only owner of its ioc.
  466. */
  467. static int blkiocg_can_attach(struct cgroup_subsys *subsys,
  468. struct cgroup *cgroup, struct task_struct *tsk,
  469. bool threadgroup)
  470. {
  471. struct io_context *ioc;
  472. int ret = 0;
  473. /* task_lock() is needed to avoid races with exit_io_context() */
  474. task_lock(tsk);
  475. ioc = tsk->io_context;
  476. if (ioc && atomic_read(&ioc->nr_tasks) > 1)
  477. ret = -EINVAL;
  478. task_unlock(tsk);
  479. return ret;
  480. }
  481. static void blkiocg_attach(struct cgroup_subsys *subsys, struct cgroup *cgroup,
  482. struct cgroup *prev, struct task_struct *tsk,
  483. bool threadgroup)
  484. {
  485. struct io_context *ioc;
  486. task_lock(tsk);
  487. ioc = tsk->io_context;
  488. if (ioc)
  489. ioc->cgroup_changed = 1;
  490. task_unlock(tsk);
  491. }
  492. void blkio_policy_register(struct blkio_policy_type *blkiop)
  493. {
  494. spin_lock(&blkio_list_lock);
  495. list_add_tail(&blkiop->list, &blkio_list);
  496. spin_unlock(&blkio_list_lock);
  497. }
  498. EXPORT_SYMBOL_GPL(blkio_policy_register);
  499. void blkio_policy_unregister(struct blkio_policy_type *blkiop)
  500. {
  501. spin_lock(&blkio_list_lock);
  502. list_del_init(&blkiop->list);
  503. spin_unlock(&blkio_list_lock);
  504. }
  505. EXPORT_SYMBOL_GPL(blkio_policy_unregister);
  506. static int __init init_cgroup_blkio(void)
  507. {
  508. return cgroup_load_subsys(&blkio_subsys);
  509. }
  510. static void __exit exit_cgroup_blkio(void)
  511. {
  512. cgroup_unload_subsys(&blkio_subsys);
  513. }
  514. module_init(init_cgroup_blkio);
  515. module_exit(exit_cgroup_blkio);
  516. MODULE_LICENSE("GPL");