Advertisement
Guest User

0001-bfq-for-3.0-no-oficial

a guest
Aug 23rd, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. diff -aru linux-3.0-orig/block/blk-ioc.c linux-3.0/block/blk-ioc.c
  2. --- linux-3.0-orig/block/blk-ioc.c 2011-07-21 23:17:23.000000000 -0300
  3. +++ linux-3.0/block/blk-ioc.c 2011-08-23 17:28:32.202013966 -0300
  4. @@ -5,6 +5,7 @@
  5. #include <linux/module.h>
  6. #include <linux/init.h>
  7. #include <linux/bio.h>
  8. +#include <linux/bitmap.h>
  9. #include <linux/blkdev.h>
  10. #include <linux/bootmem.h> /* for max_pfn/max_low_pfn */
  11. #include <linux/slab.h>
  12. @@ -16,13 +17,12 @@
  13. */
  14. static struct kmem_cache *iocontext_cachep;
  15.  
  16. -static void cfq_dtor(struct io_context *ioc)
  17. +static void hlist_sched_dtor(struct io_context *ioc, struct hlist_head *list)
  18. {
  19. - if (!hlist_empty(&ioc->cic_list)) {
  20. + if (!hlist_empty(list)) {
  21. struct cfq_io_context *cic;
  22.  
  23. - cic = hlist_entry(ioc->cic_list.first, struct cfq_io_context,
  24. - cic_list);
  25. + cic = list_entry(list->first, struct cfq_io_context, cic_list);
  26. cic->dtor(ioc);
  27. }
  28. }
  29. @@ -40,7 +40,9 @@
  30.  
  31. if (atomic_long_dec_and_test(&ioc->refcount)) {
  32. rcu_read_lock();
  33. - cfq_dtor(ioc);
  34. +
  35. + hlist_sched_dtor(ioc, &ioc->cic_list);
  36. + hlist_sched_dtor(ioc, &ioc->bfq_cic_list);
  37. rcu_read_unlock();
  38.  
  39. kmem_cache_free(iocontext_cachep, ioc);
  40. @@ -50,15 +52,14 @@
  41. }
  42. EXPORT_SYMBOL(put_io_context);
  43.  
  44. -static void cfq_exit(struct io_context *ioc)
  45. +static void hlist_sched_exit(struct io_context *ioc, struct hlist_head *list)
  46. {
  47. rcu_read_lock();
  48.  
  49. - if (!hlist_empty(&ioc->cic_list)) {
  50. + if (!hlist_empty(list)) {
  51. struct cfq_io_context *cic;
  52.  
  53. - cic = hlist_entry(ioc->cic_list.first, struct cfq_io_context,
  54. - cic_list);
  55. + cic = list_entry(list->first, struct cfq_io_context, cic_list);
  56. cic->exit(ioc);
  57. }
  58. rcu_read_unlock();
  59. @@ -74,9 +75,10 @@
  60. task->io_context = NULL;
  61. task_unlock(task);
  62.  
  63. - if (atomic_dec_and_test(&ioc->nr_tasks))
  64. - cfq_exit(ioc);
  65. -
  66. + if (atomic_dec_and_test(&ioc->nr_tasks)) {
  67. + hlist_sched_exit(ioc, &ioc->cic_list);
  68. + hlist_sched_exit(ioc, &ioc->bfq_cic_list);
  69. + }
  70. put_io_context(ioc);
  71. }
  72.  
  73. @@ -89,12 +91,14 @@
  74. atomic_long_set(&ret->refcount, 1);
  75. atomic_set(&ret->nr_tasks, 1);
  76. spin_lock_init(&ret->lock);
  77. - ret->ioprio_changed = 0;
  78. + bitmap_zero(ret->ioprio_changed, IOC_IOPRIO_CHANGED_BITS);
  79. ret->ioprio = 0;
  80. ret->last_waited = 0; /* doesn't matter... */
  81. ret->nr_batch_requests = 0; /* because this is 0 */
  82. INIT_RADIX_TREE(&ret->radix_root, GFP_ATOMIC | __GFP_HIGH);
  83. INIT_HLIST_HEAD(&ret->cic_list);
  84. + INIT_RADIX_TREE(&ret->bfq_radix_root, GFP_ATOMIC | __GFP_HIGH);
  85. + INIT_HLIST_HEAD(&ret->bfq_cic_list);
  86. ret->ioc_data = NULL;
  87. #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
  88. ret->cgroup_changed = 0;
  89. diff -aru linux-3.0-orig/block/cfq-iosched.c linux-3.0/block/cfq-iosched.c
  90. --- linux-3.0-orig/block/cfq-iosched.c 2011-07-21 23:17:23.000000000 -0300
  91. +++ linux-3.0/block/cfq-iosched.c 2011-08-23 17:27:13.670247768 -0300
  92. @@ -2919,7 +2919,6 @@
  93. static void cfq_ioc_set_ioprio(struct io_context *ioc)
  94. {
  95. call_for_each_cic(ioc, changed_ioprio);
  96. - ioc->ioprio_changed = 0;
  97. }
  98.  
  99. static void cfq_init_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
  100. @@ -3204,8 +3203,13 @@
  101. goto err_free;
  102.  
  103. out:
  104. - smp_read_barrier_depends();
  105. - if (unlikely(ioc->ioprio_changed))
  106. + /*
  107. + * test_and_clear_bit() implies a memory barrier, paired with
  108. + * the wmb() in fs/ioprio.c, so the value seen for ioprio is the
  109. + * new one.
  110. + */
  111. + if (unlikely(test_and_clear_bit(IOC_CFQ_IOPRIO_CHANGED,
  112. + ioc->ioprio_changed)))
  113. cfq_ioc_set_ioprio(ioc);
  114.  
  115. #ifdef CONFIG_CFQ_GROUP_IOSCHED
  116. diff -aru linux-3.0-orig/block/Kconfig.iosched linux-3.0/block/Kconfig.iosched
  117. --- linux-3.0-orig/block/Kconfig.iosched 2011-07-21 23:17:23.000000000 -0300
  118. +++ linux-3.0/block/Kconfig.iosched 2011-08-23 17:27:13.670247768 -0300
  119. @@ -43,6 +43,28 @@
  120. ---help---
  121. Enable group IO scheduling in CFQ.
  122.  
  123. +config IOSCHED_BFQ
  124. + tristate "BFQ I/O scheduler"
  125. + depends on EXPERIMENTAL
  126. + default n
  127. + ---help---
  128. + The BFQ I/O scheduler tries to distribute bandwidth among
  129. + all processes according to their weights.
  130. + It aims at distributing the bandwidth as desired, independently of
  131. + the disk parameters and with any workload. It also tries to
  132. + guarantee low latency to interactive and soft real-time
  133. + applications. If compiled built-in (saying Y here), BFQ can
  134. + be configured to support hierarchical scheduling.
  135. +
  136. +config CGROUP_BFQIO
  137. + bool "BFQ hierarchical scheduling support"
  138. + depends on CGROUPS && IOSCHED_BFQ=y
  139. + default n
  140. + ---help---
  141. + Enable hierarchical scheduling in BFQ, using the cgroups
  142. + filesystem interface. The name of the subsystem will be
  143. + bfqio.
  144. +
  145. choice
  146. prompt "Default I/O scheduler"
  147. default DEFAULT_CFQ
  148. @@ -56,6 +78,9 @@
  149. config DEFAULT_CFQ
  150. bool "CFQ" if IOSCHED_CFQ=y
  151.  
  152. + config DEFAULT_BFQ
  153. + bool "BFQ" if IOSCHED_BFQ=y
  154. +
  155. config DEFAULT_NOOP
  156. bool "No-op"
  157.  
  158. @@ -65,6 +90,7 @@
  159. string
  160. default "deadline" if DEFAULT_DEADLINE
  161. default "cfq" if DEFAULT_CFQ
  162. + default "bfq" if DEFAULT_BFQ
  163. default "noop" if DEFAULT_NOOP
  164.  
  165. endmenu
  166. diff -aru linux-3.0-orig/fs/ioprio.c linux-3.0/fs/ioprio.c
  167. --- linux-3.0-orig/fs/ioprio.c 2011-07-21 23:17:23.000000000 -0300
  168. +++ linux-3.0/fs/ioprio.c 2011-08-23 17:27:13.670247768 -0300
  169. @@ -30,7 +30,7 @@
  170.  
  171. int set_task_ioprio(struct task_struct *task, int ioprio)
  172. {
  173. - int err;
  174. + int err, i;
  175. struct io_context *ioc;
  176. const struct cred *cred = current_cred(), *tcred;
  177.  
  178. @@ -60,12 +60,17 @@
  179. err = -ENOMEM;
  180. break;
  181. }
  182. + /* let other ioc users see the new values */
  183. + smp_wmb();
  184. task->io_context = ioc;
  185. } while (1);
  186.  
  187. if (!err) {
  188. ioc->ioprio = ioprio;
  189. - ioc->ioprio_changed = 1;
  190. + /* make sure schedulers see the new ioprio value */
  191. + wmb();
  192. + for (i = 0; i < IOC_IOPRIO_CHANGED_BITS; i++)
  193. + set_bit(i, ioc->ioprio_changed);
  194. }
  195.  
  196. task_unlock(task);
  197. diff -aru linux-3.0-orig/include/linux/iocontext.h linux-3.0/include/linux/iocontext.h
  198. --- linux-3.0-orig/include/linux/iocontext.h 2011-07-21 23:17:23.000000000 -0300
  199. +++ linux-3.0/include/linux/iocontext.h 2011-08-23 17:27:13.670247768 -0300
  200. @@ -1,14 +1,14 @@
  201. #ifndef IOCONTEXT_H
  202. #define IOCONTEXT_H
  203.  
  204. +#include <linux/bitmap.h>
  205. #include <linux/radix-tree.h>
  206. #include <linux/rcupdate.h>
  207.  
  208. -struct cfq_queue;
  209. struct cfq_io_context {
  210. void *key;
  211.  
  212. - struct cfq_queue *cfqq[2];
  213. + void *cfqq[2];
  214.  
  215. struct io_context *ioc;
  216.  
  217. @@ -28,6 +28,16 @@
  218. };
  219.  
  220. /*
  221. + * Indexes into the ioprio_changed bitmap. A bit set indicates that
  222. + * the corresponding I/O scheduler needs to see a ioprio update.
  223. + */
  224. +enum {
  225. + IOC_CFQ_IOPRIO_CHANGED,
  226. + IOC_BFQ_IOPRIO_CHANGED,
  227. + IOC_IOPRIO_CHANGED_BITS
  228. +};
  229. +
  230. +/*
  231. * I/O subsystem state of the associated processes. It is refcounted
  232. * and kmalloc'ed. These could be shared between processes.
  233. */
  234. @@ -39,7 +49,7 @@
  235. spinlock_t lock;
  236.  
  237. unsigned short ioprio;
  238. - unsigned short ioprio_changed;
  239. + DECLARE_BITMAP(ioprio_changed, IOC_IOPRIO_CHANGED_BITS);
  240.  
  241. #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
  242. unsigned short cgroup_changed;
  243. @@ -53,6 +63,8 @@
  244.  
  245. struct radix_tree_root radix_root;
  246. struct hlist_head cic_list;
  247. + struct radix_tree_root bfq_radix_root;
  248. + struct hlist_head bfq_cic_list;
  249. void __rcu *ioc_data;
  250. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement