blk-cgroup.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _BLK_CGROUP_H
  2. #define _BLK_CGROUP_H
  3. /*
  4. * Common Block IO controller cgroup interface
  5. *
  6. * Based on ideas and code from CFQ, CFS and BFQ:
  7. * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
  8. *
  9. * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
  10. * Paolo Valente <paolo.valente@unimore.it>
  11. *
  12. * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
  13. * Nauman Rafique <nauman@google.com>
  14. */
  15. #include <linux/cgroup.h>
  16. #ifdef CONFIG_BLK_CGROUP
  17. struct blkio_cgroup {
  18. struct cgroup_subsys_state css;
  19. unsigned int weight;
  20. spinlock_t lock;
  21. struct hlist_head blkg_list;
  22. };
  23. struct blkio_group {
  24. /* An rcu protected unique identifier for the group */
  25. void *key;
  26. struct hlist_node blkcg_node;
  27. unsigned short blkcg_id;
  28. #ifdef CONFIG_DEBUG_BLK_CGROUP
  29. /* Store cgroup path */
  30. char path[128];
  31. /* How many times this group has been removed from service tree */
  32. unsigned long dequeue;
  33. #endif
  34. /* The device MKDEV(major, minor), this group has been created for */
  35. dev_t dev;
  36. /* total disk time and nr sectors dispatched by this group */
  37. unsigned long time;
  38. unsigned long sectors;
  39. };
  40. #else
  41. struct blkio_group {
  42. };
  43. #endif
  44. #define BLKIO_WEIGHT_MIN 100
  45. #define BLKIO_WEIGHT_MAX 1000
  46. #define BLKIO_WEIGHT_DEFAULT 500
  47. #ifdef CONFIG_DEBUG_BLK_CGROUP
  48. static inline char *blkg_path(struct blkio_group *blkg)
  49. {
  50. return blkg->path;
  51. }
  52. void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg,
  53. unsigned long dequeue);
  54. #else
  55. static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
  56. static inline void blkiocg_update_blkio_group_dequeue_stats(
  57. struct blkio_group *blkg, unsigned long dequeue) {}
  58. #endif
  59. #ifdef CONFIG_BLK_CGROUP
  60. extern struct blkio_cgroup blkio_root_cgroup;
  61. extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
  62. extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
  63. struct blkio_group *blkg, void *key, dev_t dev);
  64. extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
  65. extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
  66. void *key);
  67. void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
  68. unsigned long time, unsigned long sectors);
  69. #else
  70. struct cgroup;
  71. static inline struct blkio_cgroup *
  72. cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
  73. static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
  74. struct blkio_group *blkg, void *key, dev_t dev)
  75. {
  76. }
  77. static inline int
  78. blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
  79. static inline struct blkio_group *
  80. blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; }
  81. static inline void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
  82. unsigned long time, unsigned long sectors)
  83. {
  84. }
  85. #endif
  86. #endif /* _BLK_CGROUP_H */