/* * row_get_next_queue() - selects the next queue to dispatch from * @q: requests queue * @rd: pointer to struct row_data * @start_idx/end_idx: indexes in the row_queues array to select a queue * from. * * Return index of the queues to dispatch from. Error code if fails. * */ static int row_get_next_queue(struct request_queue *q, struct row_data *rd, int start_idx, int end_idx) { int i = start_idx; bool restart = true; int ret = -EIO; do { if (list_empty(&rd->row_queues[i].fifo) || rd->row_queues[i].nr_dispatched >= rd->row_queues[i].disp_quantum) { i++; if (i == end_idx && restart) { /* Restart cycle for this priority class */ row_restart_cycle(rd, start_idx, end_idx); i = start_idx; restart = false; } } else { ret = i; break; } } while (i < end_idx); return ret; }
static int row_get_next_queue(struct request_queue *q, struct row_data *rd, int start_idx, int end_idx) { int i = start_idx; bool restart = true; int ret = -EIO; bool print_debug_log = false; do { if (list_empty(&rd->row_queues[i].fifo) || rd->row_queues[i].nr_dispatched >= rd->row_queues[i].disp_quantum) { if ((i == ROWQ_PRIO_HIGH_READ || i == ROWQ_PRIO_REG_READ) && rd->row_queues[i].nr_dispatched >= rd->row_queues[i].disp_quantum) print_debug_log = true; i++; if (i == end_idx && restart) { row_restart_cycle(rd, start_idx, end_idx); i = start_idx; restart = false; } } else { ret = i; break; } } while (i < end_idx); if (print_debug_log) row_dump_reg_and_low_stat(rd); #define EXPIRE_REQUEST_THRESHOLD 20 if (ret == ROWQ_PRIO_REG_READ) { struct request *check_req; bool reset_quantum = false; for (i = ret + 1; i < end_idx; i++) { if (!row_queues_def[i].expire) continue; if (list_empty(&rd->row_queues[i].fifo)) { reset_quantum = true; continue; } check_req = list_entry_rq(rd->row_queues[i].fifo.next); if (time_after(jiffies, ((unsigned long) (check_req)->csd.list.next) + row_queues_def[i].expire) && rd->row_queues[i].nr_req > EXPIRE_REQUEST_THRESHOLD) { rd->row_queues[ret].disp_quantum = row_queues_def[ret].quantum / 2; reset_quantum = false; break; } else reset_quantum = true; } if (reset_quantum) rd->row_queues[ret].disp_quantum = row_queues_def[ret].quantum; } return ret; }