Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 1 | /* |
| 2 | * ROW (Read Over Write) I/O scheduler. |
| 3 | * |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 4 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 and |
| 8 | * only version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | /* See Documentation/block/row-iosched.txt */ |
| 17 | |
| 18 | #include <linux/kernel.h> |
| 19 | #include <linux/fs.h> |
| 20 | #include <linux/blkdev.h> |
| 21 | #include <linux/elevator.h> |
| 22 | #include <linux/bio.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/compiler.h> |
| 27 | #include <linux/blktrace_api.h> |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 28 | #include <linux/hrtimer.h> |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * enum row_queue_prio - Priorities of the ROW queues |
| 32 | * |
| 33 | * This enum defines the priorities (and the number of queues) |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 34 | * the requests will be distributed to. The higher priority - |
| 35 | * the bigger is the "bus time" (or the dispatch quantum) given |
| 36 | * to that queue. |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 37 | * ROWQ_PRIO_HIGH_READ - is the higher priority queue. |
| 38 | * |
| 39 | */ |
| 40 | enum row_queue_prio { |
| 41 | ROWQ_PRIO_HIGH_READ = 0, |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 42 | ROWQ_PRIO_HIGH_SWRITE, |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 43 | ROWQ_PRIO_REG_READ, |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 44 | ROWQ_PRIO_REG_SWRITE, |
| 45 | ROWQ_PRIO_REG_WRITE, |
| 46 | ROWQ_PRIO_LOW_READ, |
| 47 | ROWQ_PRIO_LOW_SWRITE, |
| 48 | ROWQ_MAX_PRIO, |
| 49 | }; |
| 50 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 51 | /* |
| 52 | * The following indexes define the distribution of ROW queues according to |
| 53 | * priorities. Each index defines the first queue in that priority group. |
| 54 | */ |
| 55 | #define ROWQ_HIGH_PRIO_IDX ROWQ_PRIO_HIGH_READ |
| 56 | #define ROWQ_REG_PRIO_IDX ROWQ_PRIO_REG_READ |
| 57 | #define ROWQ_LOW_PRIO_IDX ROWQ_PRIO_LOW_READ |
| 58 | |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 59 | /** |
| 60 | * struct row_queue_params - ROW queue parameters |
| 61 | * @idling_enabled: Flag indicating whether idling is enable on |
| 62 | * the queue |
| 63 | * @quantum: Number of requests to be dispatched from this queue |
| 64 | * in a dispatch cycle |
| 65 | * @is_urgent: Flags indicating whether the queue can notify on |
| 66 | * urgent requests |
| 67 | * |
| 68 | */ |
| 69 | struct row_queue_params { |
| 70 | bool idling_enabled; |
| 71 | int quantum; |
| 72 | bool is_urgent; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 73 | }; |
| 74 | |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 75 | /* |
| 76 | * This array holds the default values of the different configurables |
| 77 | * for each ROW queue. Each row of the array holds the following values: |
| 78 | * {idling_enabled, quantum, is_urgent} |
| 79 | * Each row corresponds to a queue with the same index (according to |
| 80 | * enum row_queue_prio) |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 81 | * Note: The quantums are valid inside their priority type. For example: |
| 82 | * For every 10 high priority read requests, 1 high priority sync |
| 83 | * write will be dispatched. |
| 84 | * For every 100 regular read requests 1 regular write request will |
| 85 | * be dispatched. |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 86 | */ |
| 87 | static const struct row_queue_params row_queues_def[] = { |
| 88 | /* idling_enabled, quantum, is_urgent */ |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 89 | {true, 10, true}, /* ROWQ_PRIO_HIGH_READ */ |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 90 | {false, 1, false}, /* ROWQ_PRIO_HIGH_SWRITE */ |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 91 | {true, 100, true}, /* ROWQ_PRIO_REG_READ */ |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 92 | {false, 1, false}, /* ROWQ_PRIO_REG_SWRITE */ |
| 93 | {false, 1, false}, /* ROWQ_PRIO_REG_WRITE */ |
| 94 | {false, 1, false}, /* ROWQ_PRIO_LOW_READ */ |
| 95 | {false, 1, false} /* ROWQ_PRIO_LOW_SWRITE */ |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 96 | }; |
| 97 | |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 98 | /* Default values for idling on read queues (in msec) */ |
| 99 | #define ROW_IDLE_TIME_MSEC 5 |
| 100 | #define ROW_READ_FREQ_MSEC 20 |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * struct rowq_idling_data - parameters for idling on the queue |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 104 | * @last_insert_time: time the last request was inserted |
| 105 | * to the queue |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 106 | * @begin_idling: flag indicating wether we should idle |
| 107 | * |
| 108 | */ |
| 109 | struct rowq_idling_data { |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 110 | ktime_t last_insert_time; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 111 | bool begin_idling; |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * struct row_queue - requests grouping structure |
| 116 | * @rdata: parent row_data structure |
| 117 | * @fifo: fifo of requests |
| 118 | * @prio: queue priority (enum row_queue_prio) |
| 119 | * @nr_dispatched: number of requests already dispatched in |
| 120 | * the current dispatch cycle |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 121 | * @nr_req: number of requests in queue |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 122 | * @dispatch quantum: number of requests this queue may |
| 123 | * dispatch in a dispatch cycle |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 124 | * @idle_data: data for idling on queues |
| 125 | * |
| 126 | */ |
| 127 | struct row_queue { |
| 128 | struct row_data *rdata; |
| 129 | struct list_head fifo; |
| 130 | enum row_queue_prio prio; |
| 131 | |
| 132 | unsigned int nr_dispatched; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 133 | |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 134 | unsigned int nr_req; |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 135 | int disp_quantum; |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 136 | |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 137 | /* used only for READ queues */ |
| 138 | struct rowq_idling_data idle_data; |
| 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * struct idling_data - data for idling on empty rqueue |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 143 | * @idle_time_ms: idling duration (msec) |
| 144 | * @freq_ms: min time between two requests that |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 145 | * triger idling (msec) |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 146 | * @hr_timer: idling timer |
| 147 | * @idle_work: the work to be scheduled when idling timer expires |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 148 | * @idling_queue_idx: index of the queues we're idling on |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 149 | * |
| 150 | */ |
| 151 | struct idling_data { |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 152 | s64 idle_time_ms; |
| 153 | s64 freq_ms; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 154 | |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 155 | struct hrtimer hr_timer; |
| 156 | struct work_struct idle_work; |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 157 | enum row_queue_prio idling_queue_idx; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | /** |
| 161 | * struct row_queue - Per block device rqueue structure |
| 162 | * @dispatch_queue: dispatch rqueue |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 163 | * @row_queues: array of priority request queues |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 164 | * @rd_idle_data: data for idling after READ request |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 165 | * @nr_reqs: nr_reqs[0] holds the number of all READ requests in |
| 166 | * scheduler, nr_reqs[1] holds the number of all WRITE |
| 167 | * requests in scheduler |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 168 | * @urgent_in_flight: flag indicating that there is an urgent |
| 169 | * request that was dispatched to driver and is yet to |
| 170 | * complete. |
| 171 | * @pending_urgent_rq: pointer to the pending urgent request |
| 172 | * @last_served_ioprio_class: I/O priority class that was last dispatched from |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 173 | * @cycle_flags: used for marking unserved queueus |
| 174 | * |
| 175 | */ |
| 176 | struct row_data { |
| 177 | struct request_queue *dispatch_queue; |
| 178 | |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 179 | struct row_queue row_queues[ROWQ_MAX_PRIO]; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 180 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 181 | struct idling_data rd_idle_data; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 182 | unsigned int nr_reqs[2]; |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 183 | bool urgent_in_flight; |
| 184 | struct request *pending_urgent_rq; |
| 185 | int last_served_ioprio_class; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 186 | unsigned int cycle_flags; |
| 187 | }; |
| 188 | |
| 189 | #define RQ_ROWQ(rq) ((struct row_queue *) ((rq)->elv.priv[0])) |
| 190 | |
| 191 | #define row_log(q, fmt, args...) \ |
| 192 | blk_add_trace_msg(q, "%s():" fmt , __func__, ##args) |
| 193 | #define row_log_rowq(rdata, rowq_id, fmt, args...) \ |
| 194 | blk_add_trace_msg(rdata->dispatch_queue, "rowq%d " fmt, \ |
| 195 | rowq_id, ##args) |
| 196 | |
| 197 | static inline void row_mark_rowq_unserved(struct row_data *rd, |
| 198 | enum row_queue_prio qnum) |
| 199 | { |
| 200 | rd->cycle_flags |= (1 << qnum); |
| 201 | } |
| 202 | |
| 203 | static inline void row_clear_rowq_unserved(struct row_data *rd, |
| 204 | enum row_queue_prio qnum) |
| 205 | { |
| 206 | rd->cycle_flags &= ~(1 << qnum); |
| 207 | } |
| 208 | |
| 209 | static inline int row_rowq_unserved(struct row_data *rd, |
| 210 | enum row_queue_prio qnum) |
| 211 | { |
| 212 | return rd->cycle_flags & (1 << qnum); |
| 213 | } |
| 214 | |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 215 | static inline void __maybe_unused row_dump_queues_stat(struct row_data *rd) |
| 216 | { |
| 217 | int i; |
| 218 | |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 219 | row_log(rd->dispatch_queue, " Queues status:"); |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 220 | for (i = 0; i < ROWQ_MAX_PRIO; i++) |
| 221 | row_log(rd->dispatch_queue, |
| 222 | "queue%d: dispatched= %d, nr_req=%d", i, |
| 223 | rd->row_queues[i].nr_dispatched, |
| 224 | rd->row_queues[i].nr_req); |
| 225 | } |
| 226 | |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 227 | /******************** Static helper functions ***********************/ |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 228 | static void kick_queue(struct work_struct *work) |
| 229 | { |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 230 | struct idling_data *read_data = |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 231 | container_of(work, struct idling_data, idle_work); |
| 232 | struct row_data *rd = |
| 233 | container_of(read_data, struct row_data, rd_idle_data); |
| 234 | |
| 235 | blk_run_queue(rd->dispatch_queue); |
| 236 | } |
| 237 | |
| 238 | |
| 239 | static enum hrtimer_restart row_idle_hrtimer_fn(struct hrtimer *hr_timer) |
| 240 | { |
| 241 | struct idling_data *read_data = |
| 242 | container_of(hr_timer, struct idling_data, hr_timer); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 243 | struct row_data *rd = |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 244 | container_of(read_data, struct row_data, rd_idle_data); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 245 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 246 | row_log_rowq(rd, rd->rd_idle_data.idling_queue_idx, |
| 247 | "Performing delayed work"); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 248 | /* Mark idling process as done */ |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 249 | rd->row_queues[rd->rd_idle_data.idling_queue_idx]. |
| 250 | idle_data.begin_idling = false; |
| 251 | rd->rd_idle_data.idling_queue_idx = ROWQ_MAX_PRIO; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 252 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 253 | if (!rd->nr_reqs[READ] && !rd->nr_reqs[WRITE]) |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 254 | row_log(rd->dispatch_queue, "No requests in scheduler"); |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 255 | else |
| 256 | kblockd_schedule_work(rd->dispatch_queue, |
| 257 | &read_data->idle_work); |
| 258 | return HRTIMER_NORESTART; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 259 | } |
| 260 | |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 261 | /******************* Elevator callback functions *********************/ |
| 262 | |
| 263 | /* |
| 264 | * row_add_request() - Add request to the scheduler |
| 265 | * @q: requests queue |
| 266 | * @rq: request to add |
| 267 | * |
| 268 | */ |
| 269 | static void row_add_request(struct request_queue *q, |
| 270 | struct request *rq) |
| 271 | { |
| 272 | struct row_data *rd = (struct row_data *)q->elevator->elevator_data; |
| 273 | struct row_queue *rqueue = RQ_ROWQ(rq); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 274 | s64 diff_ms; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 275 | |
| 276 | list_add_tail(&rq->queuelist, &rqueue->fifo); |
| 277 | rd->nr_reqs[rq_data_dir(rq)]++; |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 278 | rqueue->nr_req++; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 279 | rq_set_fifo_time(rq, jiffies); /* for statistics*/ |
| 280 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 281 | if (rq->cmd_flags & REQ_URGENT) { |
| 282 | WARN_ON(1); |
| 283 | blk_dump_rq_flags(rq, ""); |
| 284 | rq->cmd_flags &= ~REQ_URGENT; |
| 285 | } |
| 286 | |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 287 | if (row_queues_def[rqueue->prio].idling_enabled) { |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 288 | if (rd->rd_idle_data.idling_queue_idx == rqueue->prio && |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 289 | hrtimer_active(&rd->rd_idle_data.hr_timer)) { |
| 290 | (void)hrtimer_cancel(&rd->rd_idle_data.hr_timer); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 291 | row_log_rowq(rd, rqueue->prio, |
| 292 | "Canceled delayed work on %d", |
| 293 | rd->rd_idle_data.idling_queue_idx); |
| 294 | rd->rd_idle_data.idling_queue_idx = ROWQ_MAX_PRIO; |
| 295 | } |
| 296 | diff_ms = ktime_to_ms(ktime_sub(ktime_get(), |
| 297 | rqueue->idle_data.last_insert_time)); |
| 298 | if (unlikely(diff_ms < 0)) { |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 299 | pr_err("%s(): time delta error: diff_ms < 0", |
| 300 | __func__); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 301 | rqueue->idle_data.begin_idling = false; |
| 302 | return; |
| 303 | } |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 304 | if (diff_ms < rd->rd_idle_data.freq_ms) { |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 305 | rqueue->idle_data.begin_idling = true; |
| 306 | row_log_rowq(rd, rqueue->prio, "Enable idling"); |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 307 | } else { |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 308 | rqueue->idle_data.begin_idling = false; |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 309 | row_log_rowq(rd, rqueue->prio, "Disable idling (%ldms)", |
| 310 | (long)diff_ms); |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 311 | } |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 312 | |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 313 | rqueue->idle_data.last_insert_time = ktime_get(); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 314 | } |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 315 | if (row_queues_def[rqueue->prio].is_urgent && |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 316 | !rd->pending_urgent_rq && !rd->urgent_in_flight) { |
| 317 | /* Handle High Priority queues */ |
| 318 | if (rqueue->prio < ROWQ_REG_PRIO_IDX && |
| 319 | rd->last_served_ioprio_class != IOPRIO_CLASS_RT) { |
| 320 | row_log_rowq(rd, rqueue->prio, |
| 321 | "added (high prio) urgent request"); |
| 322 | rq->cmd_flags |= REQ_URGENT; |
| 323 | rd->pending_urgent_rq = rq; |
| 324 | } else if (row_rowq_unserved(rd, rqueue->prio)) { |
| 325 | /* Handle Regular priotity queues */ |
| 326 | row_log_rowq(rd, rqueue->prio, |
| 327 | "added urgent request (total on queue=%d)", |
| 328 | rqueue->nr_req); |
| 329 | rq->cmd_flags |= REQ_URGENT; |
| 330 | WARN_ON(rqueue->nr_req > 1); |
| 331 | rd->pending_urgent_rq = rq; |
| 332 | } |
Tatyana Brokhman | 0ef8143 | 2012-12-20 19:23:58 +0200 | [diff] [blame] | 333 | } else |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 334 | row_log_rowq(rd, rqueue->prio, |
| 335 | "added request (total on queue=%d)", rqueue->nr_req); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 336 | } |
| 337 | |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 338 | /** |
| 339 | * row_reinsert_req() - Reinsert request back to the scheduler |
| 340 | * @q: requests queue |
| 341 | * @rq: request to add |
| 342 | * |
| 343 | * Reinsert the given request back to the queue it was |
| 344 | * dispatched from as if it was never dispatched. |
| 345 | * |
| 346 | * Returns 0 on success, error code otherwise |
| 347 | */ |
| 348 | static int row_reinsert_req(struct request_queue *q, |
| 349 | struct request *rq) |
| 350 | { |
| 351 | struct row_data *rd = q->elevator->elevator_data; |
| 352 | struct row_queue *rqueue = RQ_ROWQ(rq); |
| 353 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 354 | if (!rqueue || rqueue->prio >= ROWQ_MAX_PRIO) |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 355 | return -EIO; |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 356 | |
| 357 | list_add(&rq->queuelist, &rqueue->fifo); |
| 358 | rd->nr_reqs[rq_data_dir(rq)]++; |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 359 | rqueue->nr_req++; |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 360 | |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 361 | row_log_rowq(rd, rqueue->prio, |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 362 | "%s request reinserted (total on queue=%d)", |
| 363 | (rq_data_dir(rq) == READ ? "READ" : "write"), rqueue->nr_req); |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 364 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 365 | if (rq->cmd_flags & REQ_URGENT) { |
| 366 | /* |
| 367 | * It's not compliant with the design to re-insert |
| 368 | * urgent requests. We want to be able to track this |
| 369 | * down. |
| 370 | */ |
| 371 | WARN_ON(1); |
| 372 | if (!rd->urgent_in_flight) { |
| 373 | pr_err("%s(): no urgent in flight", __func__); |
| 374 | } else { |
| 375 | rd->urgent_in_flight = false; |
| 376 | pr_err("%s(): reinserting URGENT %s req", |
| 377 | __func__, |
| 378 | (rq_data_dir(rq) == READ ? "READ" : "WRITE")); |
| 379 | if (rd->pending_urgent_rq) { |
| 380 | pr_err("%s(): urgent rq is pending", |
| 381 | __func__); |
| 382 | rd->pending_urgent_rq->cmd_flags &= ~REQ_URGENT; |
| 383 | } |
| 384 | rd->pending_urgent_rq = rq; |
| 385 | } |
| 386 | } |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 387 | return 0; |
| 388 | } |
| 389 | |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 390 | static void row_completed_req(struct request_queue *q, struct request *rq) |
| 391 | { |
| 392 | struct row_data *rd = q->elevator->elevator_data; |
| 393 | |
| 394 | if (rq->cmd_flags & REQ_URGENT) { |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 395 | if (!rd->urgent_in_flight) { |
| 396 | WARN_ON(1); |
| 397 | pr_err("%s(): URGENT req but urgent_in_flight = F", |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 398 | __func__); |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 399 | } |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 400 | rd->urgent_in_flight = false; |
| 401 | rq->cmd_flags &= ~REQ_URGENT; |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 402 | } |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 403 | row_log(q, "completed %s %s req.", |
| 404 | (rq->cmd_flags & REQ_URGENT ? "URGENT" : "regular"), |
| 405 | (rq_data_dir(rq) == READ ? "READ" : "WRITE")); |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 406 | } |
| 407 | |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 408 | /** |
Tatyana Brokhman | 0ef8143 | 2012-12-20 19:23:58 +0200 | [diff] [blame] | 409 | * row_urgent_pending() - Return TRUE if there is an urgent |
| 410 | * request on scheduler |
| 411 | * @q: requests queue |
| 412 | */ |
| 413 | static bool row_urgent_pending(struct request_queue *q) |
| 414 | { |
| 415 | struct row_data *rd = q->elevator->elevator_data; |
Tatyana Brokhman | 0ef8143 | 2012-12-20 19:23:58 +0200 | [diff] [blame] | 416 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 417 | if (rd->urgent_in_flight) { |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 418 | row_log(rd->dispatch_queue, "%d urgent requests in flight", |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 419 | rd->urgent_in_flight); |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 420 | return false; |
| 421 | } |
| 422 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 423 | if (rd->pending_urgent_rq) { |
| 424 | row_log(rd->dispatch_queue, "Urgent request pending"); |
| 425 | return true; |
| 426 | } |
Shashank Babu Chinta Venkata | 3df69bf | 2013-02-26 17:33:55 -0800 | [diff] [blame] | 427 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 428 | row_log(rd->dispatch_queue, "no urgent request pending/in flight"); |
Tatyana Brokhman | 0ef8143 | 2012-12-20 19:23:58 +0200 | [diff] [blame] | 429 | return false; |
| 430 | } |
| 431 | |
| 432 | /** |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 433 | * row_remove_request() - Remove given request from scheduler |
| 434 | * @q: requests queue |
| 435 | * @rq: request to remove |
| 436 | * |
| 437 | */ |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 438 | static void row_remove_request(struct row_data *rd, |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 439 | struct request *rq) |
| 440 | { |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 441 | struct row_queue *rqueue = RQ_ROWQ(rq); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 442 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 443 | list_del_init(&(rq)->queuelist); |
| 444 | if (rd->pending_urgent_rq == rq) |
| 445 | rd->pending_urgent_rq = NULL; |
| 446 | else |
| 447 | BUG_ON(rq->cmd_flags & REQ_URGENT); |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 448 | rqueue->nr_req--; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 449 | rd->nr_reqs[rq_data_dir(rq)]--; |
| 450 | } |
| 451 | |
| 452 | /* |
| 453 | * row_dispatch_insert() - move request to dispatch queue |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 454 | * @rd: pointer to struct row_data |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 455 | * @rq: the request to dispatch |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 456 | * |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 457 | * This function moves the given request to the dispatch queue |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 458 | * |
| 459 | */ |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 460 | static void row_dispatch_insert(struct row_data *rd, struct request *rq) |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 461 | { |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 462 | struct row_queue *rqueue = RQ_ROWQ(rq); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 463 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 464 | row_remove_request(rd, rq); |
| 465 | elv_dispatch_sort(rd->dispatch_queue, rq); |
| 466 | if (rq->cmd_flags & REQ_URGENT) { |
| 467 | WARN_ON(rd->urgent_in_flight); |
| 468 | rd->urgent_in_flight = true; |
| 469 | } |
| 470 | rqueue->nr_dispatched++; |
| 471 | row_clear_rowq_unserved(rd, rqueue->prio); |
| 472 | row_log_rowq(rd, rqueue->prio, |
| 473 | " Dispatched request %p nr_disp = %d", rq, |
| 474 | rqueue->nr_dispatched); |
| 475 | if (rqueue->prio < ROWQ_REG_PRIO_IDX) |
| 476 | rd->last_served_ioprio_class = IOPRIO_CLASS_RT; |
| 477 | else if (rqueue->prio < ROWQ_LOW_PRIO_IDX) |
| 478 | rd->last_served_ioprio_class = IOPRIO_CLASS_BE; |
| 479 | else |
| 480 | rd->last_served_ioprio_class = IOPRIO_CLASS_IDLE; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | /* |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 484 | * row_get_ioprio_class_to_serve() - Return the next I/O priority |
| 485 | * class to dispatch requests from |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 486 | * @rd: pointer to struct row_data |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 487 | * @force: flag indicating if forced dispatch |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 488 | * |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 489 | * This function returns the next I/O priority class to serve |
| 490 | * {IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE}. |
| 491 | * If there are no more requests in scheduler or if we're idling on some queue |
| 492 | * IOPRIO_CLASS_NONE will be returned. |
| 493 | * If idling is scheduled on a lower priority queue than the one that needs |
| 494 | * to be served, it will be canceled. |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 495 | * |
| 496 | */ |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 497 | static int row_get_ioprio_class_to_serve(struct row_data *rd, int force) |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 498 | { |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 499 | int i; |
| 500 | int ret = IOPRIO_CLASS_NONE; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 501 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 502 | if (!rd->nr_reqs[READ] && !rd->nr_reqs[WRITE]) { |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 503 | row_log(rd->dispatch_queue, "No more requests in scheduler"); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 504 | goto check_idling; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 505 | } |
| 506 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 507 | /* First, go over the high priority queues */ |
| 508 | for (i = 0; i < ROWQ_REG_PRIO_IDX; i++) { |
| 509 | if (!list_empty(&rd->row_queues[i].fifo)) { |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 510 | if (hrtimer_active(&rd->rd_idle_data.hr_timer)) { |
| 511 | (void)hrtimer_cancel( |
| 512 | &rd->rd_idle_data.hr_timer); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 513 | row_log_rowq(rd, |
| 514 | rd->rd_idle_data.idling_queue_idx, |
| 515 | "Canceling delayed work on %d. RT pending", |
| 516 | rd->rd_idle_data.idling_queue_idx); |
| 517 | rd->rd_idle_data.idling_queue_idx = |
| 518 | ROWQ_MAX_PRIO; |
| 519 | } |
| 520 | ret = IOPRIO_CLASS_RT; |
| 521 | goto done; |
| 522 | } |
| 523 | } |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 524 | |
| 525 | /* |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 526 | * At the moment idling is implemented only for READ queues. |
| 527 | * If enabled on WRITE, this needs updating |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 528 | */ |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 529 | if (hrtimer_active(&rd->rd_idle_data.hr_timer)) { |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 530 | row_log(rd->dispatch_queue, "Delayed work pending. Exiting"); |
| 531 | goto done; |
| 532 | } |
| 533 | check_idling: |
| 534 | /* Check for (high priority) idling and enable if needed */ |
| 535 | for (i = 0; i < ROWQ_REG_PRIO_IDX && !force; i++) { |
| 536 | if (rd->row_queues[i].idle_data.begin_idling && |
| 537 | row_queues_def[i].idling_enabled) |
| 538 | goto initiate_idling; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 539 | } |
| 540 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 541 | /* Regular priority queues */ |
| 542 | for (i = ROWQ_REG_PRIO_IDX; i < ROWQ_LOW_PRIO_IDX; i++) { |
| 543 | if (list_empty(&rd->row_queues[i].fifo)) { |
| 544 | /* We can idle only if this is not a forced dispatch */ |
| 545 | if (rd->row_queues[i].idle_data.begin_idling && |
| 546 | !force && row_queues_def[i].idling_enabled) |
| 547 | goto initiate_idling; |
| 548 | } else { |
| 549 | ret = IOPRIO_CLASS_BE; |
| 550 | goto done; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | if (rd->nr_reqs[READ] || rd->nr_reqs[WRITE]) |
| 555 | ret = IOPRIO_CLASS_IDLE; |
| 556 | goto done; |
| 557 | |
| 558 | initiate_idling: |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 559 | hrtimer_start(&rd->rd_idle_data.hr_timer, |
| 560 | ktime_set(0, rd->rd_idle_data.idle_time_ms * NSEC_PER_MSEC), |
| 561 | HRTIMER_MODE_REL); |
| 562 | |
| 563 | rd->rd_idle_data.idling_queue_idx = i; |
| 564 | row_log_rowq(rd, i, "Scheduled delayed work on %d. exiting", i); |
| 565 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 566 | done: |
| 567 | return ret; |
| 568 | } |
| 569 | |
| 570 | static void row_restart_cycle(struct row_data *rd, |
| 571 | int start_idx, int end_idx) |
| 572 | { |
| 573 | int i; |
| 574 | |
| 575 | row_dump_queues_stat(rd); |
| 576 | for (i = start_idx; i < end_idx; i++) { |
| 577 | if (rd->row_queues[i].nr_dispatched < |
| 578 | rd->row_queues[i].disp_quantum) |
| 579 | row_mark_rowq_unserved(rd, i); |
| 580 | rd->row_queues[i].nr_dispatched = 0; |
| 581 | } |
| 582 | row_log(rd->dispatch_queue, "Restarting cycle for class @ %d-%d", |
| 583 | start_idx, end_idx); |
| 584 | } |
| 585 | |
| 586 | /* |
| 587 | * row_get_next_queue() - selects the next queue to dispatch from |
| 588 | * @q: requests queue |
| 589 | * @rd: pointer to struct row_data |
| 590 | * @start_idx/end_idx: indexes in the row_queues array to select a queue |
| 591 | * from. |
| 592 | * |
| 593 | * Return index of the queues to dispatch from. Error code if fails. |
| 594 | * |
| 595 | */ |
| 596 | static int row_get_next_queue(struct request_queue *q, struct row_data *rd, |
| 597 | int start_idx, int end_idx) |
| 598 | { |
| 599 | int i = start_idx; |
| 600 | bool restart = true; |
| 601 | int ret = -EIO; |
| 602 | |
| 603 | do { |
| 604 | if (list_empty(&rd->row_queues[i].fifo) || |
| 605 | rd->row_queues[i].nr_dispatched >= |
| 606 | rd->row_queues[i].disp_quantum) { |
| 607 | i++; |
| 608 | if (i == end_idx && restart) { |
| 609 | /* Restart cycle for this priority class */ |
| 610 | row_restart_cycle(rd, start_idx, end_idx); |
| 611 | i = start_idx; |
| 612 | restart = false; |
| 613 | } |
| 614 | } else { |
| 615 | ret = i; |
| 616 | break; |
| 617 | } |
| 618 | } while (i < end_idx); |
| 619 | |
| 620 | return ret; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | /* |
| 624 | * row_dispatch_requests() - selects the next request to dispatch |
| 625 | * @q: requests queue |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 626 | * @force: flag indicating if forced dispatch |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 627 | * |
| 628 | * Return 0 if no requests were moved to the dispatch queue. |
| 629 | * 1 otherwise |
| 630 | * |
| 631 | */ |
| 632 | static int row_dispatch_requests(struct request_queue *q, int force) |
| 633 | { |
| 634 | struct row_data *rd = (struct row_data *)q->elevator->elevator_data; |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 635 | int ret = 0, currq, ioprio_class_to_serve, start_idx, end_idx; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 636 | |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 637 | if (force && hrtimer_active(&rd->rd_idle_data.hr_timer)) { |
| 638 | (void)hrtimer_cancel(&rd->rd_idle_data.hr_timer); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 639 | row_log_rowq(rd, rd->rd_idle_data.idling_queue_idx, |
| 640 | "Canceled delayed work on %d - forced dispatch", |
| 641 | rd->rd_idle_data.idling_queue_idx); |
| 642 | rd->rd_idle_data.idling_queue_idx = ROWQ_MAX_PRIO; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 643 | } |
| 644 | |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 645 | if (rd->pending_urgent_rq) { |
| 646 | row_log(rd->dispatch_queue, "dispatching urgent request"); |
| 647 | row_dispatch_insert(rd, rd->pending_urgent_rq); |
| 648 | ret = 1; |
| 649 | goto done; |
| 650 | } |
| 651 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 652 | ioprio_class_to_serve = row_get_ioprio_class_to_serve(rd, force); |
| 653 | row_log(rd->dispatch_queue, "Dispatching from %d priority class", |
| 654 | ioprio_class_to_serve); |
| 655 | |
| 656 | switch (ioprio_class_to_serve) { |
| 657 | case IOPRIO_CLASS_NONE: |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 658 | rd->last_served_ioprio_class = IOPRIO_CLASS_NONE; |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 659 | goto done; |
| 660 | case IOPRIO_CLASS_RT: |
| 661 | start_idx = ROWQ_HIGH_PRIO_IDX; |
| 662 | end_idx = ROWQ_REG_PRIO_IDX; |
| 663 | break; |
| 664 | case IOPRIO_CLASS_BE: |
| 665 | start_idx = ROWQ_REG_PRIO_IDX; |
| 666 | end_idx = ROWQ_LOW_PRIO_IDX; |
| 667 | break; |
| 668 | case IOPRIO_CLASS_IDLE: |
| 669 | start_idx = ROWQ_LOW_PRIO_IDX; |
| 670 | end_idx = ROWQ_MAX_PRIO; |
| 671 | break; |
| 672 | default: |
| 673 | pr_err("%s(): Invalid I/O priority class", __func__); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 674 | goto done; |
| 675 | } |
| 676 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 677 | currq = row_get_next_queue(q, rd, start_idx, end_idx); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 678 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 679 | /* Dispatch */ |
| 680 | if (currq >= 0) { |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 681 | row_dispatch_insert(rd, |
| 682 | rq_entry_fifo(rd->row_queues[currq].fifo.next)); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 683 | ret = 1; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 684 | } |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 685 | done: |
| 686 | return ret; |
| 687 | } |
| 688 | |
| 689 | /* |
| 690 | * row_init_queue() - Init scheduler data structures |
| 691 | * @q: requests queue |
| 692 | * |
| 693 | * Return pointer to struct row_data to be saved in elevator for |
| 694 | * this dispatch queue |
| 695 | * |
| 696 | */ |
| 697 | static void *row_init_queue(struct request_queue *q) |
| 698 | { |
| 699 | |
| 700 | struct row_data *rdata; |
| 701 | int i; |
| 702 | |
| 703 | rdata = kmalloc_node(sizeof(*rdata), |
| 704 | GFP_KERNEL | __GFP_ZERO, q->node); |
| 705 | if (!rdata) |
| 706 | return NULL; |
| 707 | |
Tatyana Brokhman | 522778f | 2013-01-24 16:17:27 +0200 | [diff] [blame] | 708 | memset(rdata, 0, sizeof(*rdata)); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 709 | for (i = 0; i < ROWQ_MAX_PRIO; i++) { |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 710 | INIT_LIST_HEAD(&rdata->row_queues[i].fifo); |
Tatyana Brokhman | 9375bcc | 2013-01-12 16:23:18 +0200 | [diff] [blame] | 711 | rdata->row_queues[i].disp_quantum = row_queues_def[i].quantum; |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 712 | rdata->row_queues[i].rdata = rdata; |
| 713 | rdata->row_queues[i].prio = i; |
| 714 | rdata->row_queues[i].idle_data.begin_idling = false; |
| 715 | rdata->row_queues[i].idle_data.last_insert_time = |
Tatyana Brokhman | bfb04f6 | 2012-12-06 13:17:19 +0200 | [diff] [blame] | 716 | ktime_set(0, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | /* |
| 720 | * Currently idling is enabled only for READ queues. If we want to |
| 721 | * enable it for write queues also, note that idling frequency will |
| 722 | * be the same in both cases |
| 723 | */ |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 724 | rdata->rd_idle_data.idle_time_ms = ROW_IDLE_TIME_MSEC; |
| 725 | rdata->rd_idle_data.freq_ms = ROW_READ_FREQ_MSEC; |
| 726 | hrtimer_init(&rdata->rd_idle_data.hr_timer, |
| 727 | CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
| 728 | rdata->rd_idle_data.hr_timer.function = &row_idle_hrtimer_fn; |
| 729 | |
| 730 | INIT_WORK(&rdata->rd_idle_data.idle_work, kick_queue); |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 731 | rdata->last_served_ioprio_class = IOPRIO_CLASS_NONE; |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 732 | rdata->rd_idle_data.idling_queue_idx = ROWQ_MAX_PRIO; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 733 | rdata->dispatch_queue = q; |
| 734 | |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 735 | return rdata; |
| 736 | } |
| 737 | |
| 738 | /* |
| 739 | * row_exit_queue() - called on unloading the RAW scheduler |
| 740 | * @e: poiner to struct elevator_queue |
| 741 | * |
| 742 | */ |
| 743 | static void row_exit_queue(struct elevator_queue *e) |
| 744 | { |
| 745 | struct row_data *rd = (struct row_data *)e->elevator_data; |
| 746 | int i; |
| 747 | |
| 748 | for (i = 0; i < ROWQ_MAX_PRIO; i++) |
Tatyana Brokhman | 8a970bc | 2013-01-12 16:21:12 +0200 | [diff] [blame] | 749 | BUG_ON(!list_empty(&rd->row_queues[i].fifo)); |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 750 | if (hrtimer_cancel(&rd->rd_idle_data.hr_timer)) |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 751 | pr_err("%s(): idle timer was active!", __func__); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 752 | rd->rd_idle_data.idling_queue_idx = ROWQ_MAX_PRIO; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 753 | kfree(rd); |
| 754 | } |
| 755 | |
| 756 | /* |
| 757 | * row_merged_requests() - Called when 2 requests are merged |
| 758 | * @q: requests queue |
| 759 | * @rq: request the two requests were merged into |
| 760 | * @next: request that was merged |
| 761 | */ |
| 762 | static void row_merged_requests(struct request_queue *q, struct request *rq, |
| 763 | struct request *next) |
| 764 | { |
| 765 | struct row_queue *rqueue = RQ_ROWQ(next); |
| 766 | |
| 767 | list_del_init(&next->queuelist); |
Tatyana Brokhman | bd56be3 | 2013-01-13 22:04:59 +0200 | [diff] [blame] | 768 | rqueue->nr_req--; |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 769 | if (rqueue->rdata->pending_urgent_rq == next) { |
| 770 | pr_err("\n\nROW_WARNING: merging pending urgent!"); |
| 771 | rqueue->rdata->pending_urgent_rq = rq; |
| 772 | rq->cmd_flags |= REQ_URGENT; |
| 773 | WARN_ON(!(next->cmd_flags & REQ_URGENT)); |
| 774 | next->cmd_flags &= ~REQ_URGENT; |
| 775 | } |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 776 | rqueue->rdata->nr_reqs[rq_data_dir(rq)]--; |
| 777 | } |
| 778 | |
| 779 | /* |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 780 | * row_get_queue_prio() - Get queue priority for a given request |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 781 | * |
| 782 | * This is a helping function which purpose is to determine what |
| 783 | * ROW queue the given request should be added to (and |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 784 | * dispatched from later on) |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 785 | * |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 786 | */ |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 787 | static enum row_queue_prio row_get_queue_prio(struct request *rq, |
| 788 | struct row_data *rd) |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 789 | { |
| 790 | const int data_dir = rq_data_dir(rq); |
| 791 | const bool is_sync = rq_is_sync(rq); |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 792 | enum row_queue_prio q_type = ROWQ_MAX_PRIO; |
| 793 | int ioprio_class = IOPRIO_PRIO_CLASS(rq->elv.icq->ioc->ioprio); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 794 | |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 795 | switch (ioprio_class) { |
| 796 | case IOPRIO_CLASS_RT: |
| 797 | if (data_dir == READ) |
| 798 | q_type = ROWQ_PRIO_HIGH_READ; |
| 799 | else if (is_sync) |
| 800 | q_type = ROWQ_PRIO_HIGH_SWRITE; |
| 801 | else { |
| 802 | pr_err("%s:%s(): got a simple write from RT_CLASS. How???", |
| 803 | rq->rq_disk->disk_name, __func__); |
| 804 | q_type = ROWQ_PRIO_REG_WRITE; |
| 805 | } |
| 806 | break; |
| 807 | case IOPRIO_CLASS_IDLE: |
| 808 | if (data_dir == READ) |
| 809 | q_type = ROWQ_PRIO_LOW_READ; |
| 810 | else if (is_sync) |
| 811 | q_type = ROWQ_PRIO_LOW_SWRITE; |
| 812 | else { |
| 813 | pr_err("%s:%s(): got a simple write from IDLE_CLASS. How???", |
| 814 | rq->rq_disk->disk_name, __func__); |
| 815 | q_type = ROWQ_PRIO_REG_WRITE; |
| 816 | } |
| 817 | break; |
| 818 | case IOPRIO_CLASS_NONE: |
| 819 | case IOPRIO_CLASS_BE: |
| 820 | default: |
| 821 | if (data_dir == READ) |
| 822 | q_type = ROWQ_PRIO_REG_READ; |
| 823 | else if (is_sync) |
| 824 | q_type = ROWQ_PRIO_REG_SWRITE; |
| 825 | else |
| 826 | q_type = ROWQ_PRIO_REG_WRITE; |
| 827 | break; |
| 828 | } |
| 829 | |
| 830 | return q_type; |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | /* |
| 834 | * row_set_request() - Set ROW data structures associated with this request. |
| 835 | * @q: requests queue |
| 836 | * @rq: pointer to the request |
| 837 | * @gfp_mask: ignored |
| 838 | * |
| 839 | */ |
| 840 | static int |
| 841 | row_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) |
| 842 | { |
| 843 | struct row_data *rd = (struct row_data *)q->elevator->elevator_data; |
| 844 | unsigned long flags; |
| 845 | |
| 846 | spin_lock_irqsave(q->queue_lock, flags); |
| 847 | rq->elv.priv[0] = |
Tatyana Brokhman | fe6fd2f | 2013-03-12 21:17:18 +0200 | [diff] [blame] | 848 | (void *)(&rd->row_queues[row_get_queue_prio(rq, rd)]); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 849 | spin_unlock_irqrestore(q->queue_lock, flags); |
| 850 | |
| 851 | return 0; |
| 852 | } |
| 853 | |
| 854 | /********** Helping sysfs functions/defenitions for ROW attributes ******/ |
| 855 | static ssize_t row_var_show(int var, char *page) |
| 856 | { |
| 857 | return snprintf(page, 100, "%d\n", var); |
| 858 | } |
| 859 | |
| 860 | static ssize_t row_var_store(int *var, const char *page, size_t count) |
| 861 | { |
| 862 | int err; |
| 863 | err = kstrtoul(page, 10, (unsigned long *)var); |
| 864 | |
| 865 | return count; |
| 866 | } |
| 867 | |
| 868 | #define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \ |
| 869 | static ssize_t __FUNC(struct elevator_queue *e, char *page) \ |
| 870 | { \ |
| 871 | struct row_data *rowd = e->elevator_data; \ |
| 872 | int __data = __VAR; \ |
| 873 | if (__CONV) \ |
| 874 | __data = jiffies_to_msecs(__data); \ |
| 875 | return row_var_show(__data, (page)); \ |
| 876 | } |
| 877 | SHOW_FUNCTION(row_hp_read_quantum_show, |
| 878 | rowd->row_queues[ROWQ_PRIO_HIGH_READ].disp_quantum, 0); |
| 879 | SHOW_FUNCTION(row_rp_read_quantum_show, |
| 880 | rowd->row_queues[ROWQ_PRIO_REG_READ].disp_quantum, 0); |
| 881 | SHOW_FUNCTION(row_hp_swrite_quantum_show, |
| 882 | rowd->row_queues[ROWQ_PRIO_HIGH_SWRITE].disp_quantum, 0); |
| 883 | SHOW_FUNCTION(row_rp_swrite_quantum_show, |
| 884 | rowd->row_queues[ROWQ_PRIO_REG_SWRITE].disp_quantum, 0); |
| 885 | SHOW_FUNCTION(row_rp_write_quantum_show, |
| 886 | rowd->row_queues[ROWQ_PRIO_REG_WRITE].disp_quantum, 0); |
| 887 | SHOW_FUNCTION(row_lp_read_quantum_show, |
| 888 | rowd->row_queues[ROWQ_PRIO_LOW_READ].disp_quantum, 0); |
| 889 | SHOW_FUNCTION(row_lp_swrite_quantum_show, |
| 890 | rowd->row_queues[ROWQ_PRIO_LOW_SWRITE].disp_quantum, 0); |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 891 | SHOW_FUNCTION(row_rd_idle_data_show, rowd->rd_idle_data.idle_time_ms, 0); |
| 892 | SHOW_FUNCTION(row_rd_idle_data_freq_show, rowd->rd_idle_data.freq_ms, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 893 | #undef SHOW_FUNCTION |
| 894 | |
| 895 | #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ |
| 896 | static ssize_t __FUNC(struct elevator_queue *e, \ |
| 897 | const char *page, size_t count) \ |
| 898 | { \ |
| 899 | struct row_data *rowd = e->elevator_data; \ |
| 900 | int __data; \ |
| 901 | int ret = row_var_store(&__data, (page), count); \ |
| 902 | if (__CONV) \ |
| 903 | __data = (int)msecs_to_jiffies(__data); \ |
| 904 | if (__data < (MIN)) \ |
| 905 | __data = (MIN); \ |
| 906 | else if (__data > (MAX)) \ |
| 907 | __data = (MAX); \ |
| 908 | *(__PTR) = __data; \ |
| 909 | return ret; \ |
| 910 | } |
| 911 | STORE_FUNCTION(row_hp_read_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 912 | &rowd->row_queues[ROWQ_PRIO_HIGH_READ].disp_quantum, 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 913 | STORE_FUNCTION(row_rp_read_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 914 | &rowd->row_queues[ROWQ_PRIO_REG_READ].disp_quantum, |
| 915 | 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 916 | STORE_FUNCTION(row_hp_swrite_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 917 | &rowd->row_queues[ROWQ_PRIO_HIGH_SWRITE].disp_quantum, |
| 918 | 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 919 | STORE_FUNCTION(row_rp_swrite_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 920 | &rowd->row_queues[ROWQ_PRIO_REG_SWRITE].disp_quantum, |
| 921 | 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 922 | STORE_FUNCTION(row_rp_write_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 923 | &rowd->row_queues[ROWQ_PRIO_REG_WRITE].disp_quantum, |
| 924 | 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 925 | STORE_FUNCTION(row_lp_read_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 926 | &rowd->row_queues[ROWQ_PRIO_LOW_READ].disp_quantum, |
| 927 | 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 928 | STORE_FUNCTION(row_lp_swrite_quantum_store, |
Tatyana Brokhman | 0a0345a | 2012-10-15 20:50:54 +0200 | [diff] [blame] | 929 | &rowd->row_queues[ROWQ_PRIO_LOW_SWRITE].disp_quantum, |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 930 | 1, INT_MAX, 0); |
Tatyana Brokhman | ce1a8ed | 2013-01-17 20:56:07 +0200 | [diff] [blame] | 931 | STORE_FUNCTION(row_rd_idle_data_store, &rowd->rd_idle_data.idle_time_ms, |
| 932 | 1, INT_MAX, 0); |
| 933 | STORE_FUNCTION(row_rd_idle_data_freq_store, &rowd->rd_idle_data.freq_ms, |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 934 | 1, INT_MAX, 0); |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 935 | |
| 936 | #undef STORE_FUNCTION |
| 937 | |
| 938 | #define ROW_ATTR(name) \ |
| 939 | __ATTR(name, S_IRUGO|S_IWUSR, row_##name##_show, \ |
| 940 | row_##name##_store) |
| 941 | |
| 942 | static struct elv_fs_entry row_attrs[] = { |
| 943 | ROW_ATTR(hp_read_quantum), |
| 944 | ROW_ATTR(rp_read_quantum), |
| 945 | ROW_ATTR(hp_swrite_quantum), |
| 946 | ROW_ATTR(rp_swrite_quantum), |
| 947 | ROW_ATTR(rp_write_quantum), |
| 948 | ROW_ATTR(lp_read_quantum), |
| 949 | ROW_ATTR(lp_swrite_quantum), |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 950 | ROW_ATTR(rd_idle_data), |
| 951 | ROW_ATTR(rd_idle_data_freq), |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 952 | __ATTR_NULL |
| 953 | }; |
| 954 | |
| 955 | static struct elevator_type iosched_row = { |
| 956 | .ops = { |
| 957 | .elevator_merge_req_fn = row_merged_requests, |
| 958 | .elevator_dispatch_fn = row_dispatch_requests, |
| 959 | .elevator_add_req_fn = row_add_request, |
Tatyana Brokhman | b7bf9ac | 2012-10-30 08:33:06 +0200 | [diff] [blame] | 960 | .elevator_reinsert_req_fn = row_reinsert_req, |
Tatyana Brokhman | 0ef8143 | 2012-12-20 19:23:58 +0200 | [diff] [blame] | 961 | .elevator_is_urgent_fn = row_urgent_pending, |
Tatyana Brokhman | 4c3c3cc | 2013-01-24 15:08:40 +0200 | [diff] [blame] | 962 | .elevator_completed_req_fn = row_completed_req, |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 963 | .elevator_former_req_fn = elv_rb_former_request, |
| 964 | .elevator_latter_req_fn = elv_rb_latter_request, |
| 965 | .elevator_set_req_fn = row_set_request, |
| 966 | .elevator_init_fn = row_init_queue, |
| 967 | .elevator_exit_fn = row_exit_queue, |
| 968 | }, |
Tatyana Brokhman | db7c153 | 2013-01-23 17:15:49 +0200 | [diff] [blame] | 969 | .icq_size = sizeof(struct io_cq), |
| 970 | .icq_align = __alignof__(struct io_cq), |
Tatyana Brokhman | 1634906 | 2012-09-20 10:46:10 +0300 | [diff] [blame] | 971 | .elevator_attrs = row_attrs, |
| 972 | .elevator_name = "row", |
| 973 | .elevator_owner = THIS_MODULE, |
| 974 | }; |
| 975 | |
| 976 | static int __init row_init(void) |
| 977 | { |
| 978 | elv_register(&iosched_row); |
| 979 | return 0; |
| 980 | } |
| 981 | |
| 982 | static void __exit row_exit(void) |
| 983 | { |
| 984 | elv_unregister(&iosched_row); |
| 985 | } |
| 986 | |
| 987 | module_init(row_init); |
| 988 | module_exit(row_exit); |
| 989 | |
| 990 | MODULE_LICENSE("GPLv2"); |
| 991 | MODULE_DESCRIPTION("Read Over Write IO scheduler"); |