Skip to content

Commit

Permalink
block: Port ROW I/O scheduler from SM-J500H_SWA_MM_Opensource
Browse files Browse the repository at this point in the history
Again, replacing broken thing :)

Signed-off-by: Quyen <[email protected]>
  • Loading branch information
diepquynh authored and Ma3aXaTa committed Nov 13, 2018
1 parent 8bd3748 commit c03c8f9
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions block/row-iosched.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* ROW (Read Over Write) I/O scheduler.
*
* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -86,18 +86,18 @@ struct row_queue_params {
*/
static const struct row_queue_params row_queues_def[] = {
/* idling_enabled, quantum, is_urgent */
{true, 100, true}, /* ROWQ_PRIO_HIGH_READ */
{false, 5, false}, /* ROWQ_PRIO_HIGH_SWRITE */
{true, 75, true}, /* ROWQ_PRIO_REG_READ */
{false, 4, false}, /* ROWQ_PRIO_REG_SWRITE */
{false, 4, false}, /* ROWQ_PRIO_REG_WRITE */
{false, 3, false}, /* ROWQ_PRIO_LOW_READ */
{false, 2, false} /* ROWQ_PRIO_LOW_SWRITE */
{true, 10, true}, /* ROWQ_PRIO_HIGH_READ */
{false, 1, false}, /* ROWQ_PRIO_HIGH_SWRITE */
{true, 100, true}, /* ROWQ_PRIO_REG_READ */
{false, 1, false}, /* ROWQ_PRIO_REG_SWRITE */
{false, 1, false}, /* ROWQ_PRIO_REG_WRITE */
{false, 1, false}, /* ROWQ_PRIO_LOW_READ */
{false, 1, false} /* ROWQ_PRIO_LOW_SWRITE */
};

/* Default values for idling on read queues (in msec) */
#define ROW_IDLE_TIME_MSEC 10
#define ROW_READ_FREQ_MSEC 25
#define ROW_IDLE_TIME_MSEC 5
#define ROW_READ_FREQ_MSEC 5

/**
* struct rowq_idling_data - parameters for idling on the queue
Expand Down Expand Up @@ -331,10 +331,6 @@ static void row_add_request(struct request_queue *q,
struct row_queue *rqueue = RQ_ROWQ(rq);
s64 diff_ms;
bool queue_was_empty = list_empty(&rqueue->fifo);
unsigned long bv_page_flags = 0;

if (rq->bio && rq->bio->bi_io_vec && rq->bio->bi_io_vec->bv_page)
bv_page_flags = rq->bio->bi_io_vec->bv_page->flags;

list_add_tail(&rq->queuelist, &rqueue->fifo);
rd->nr_reqs[rq_data_dir(rq)]++;
Expand Down Expand Up @@ -367,9 +363,7 @@ static void row_add_request(struct request_queue *q,
rqueue->idle_data.begin_idling = false;
return;
}

if ((bv_page_flags & (1L << PG_readahead)) ||
(diff_ms < rd->rd_idle_data.freq_ms)) {
if (diff_ms < rd->rd_idle_data.freq_ms) {
rqueue->idle_data.begin_idling = true;
row_log_rowq(rd, rqueue->prio, "Enable idling");
} else {
Expand Down Expand Up @@ -788,16 +782,24 @@ static int row_dispatch_requests(struct request_queue *q, int force)
* this dispatch queue
*
*/
static int row_init_queue(struct request_queue *q)
static int row_init_queue(struct request_queue *q, struct elevator_type *e)
{

struct row_data *rdata;
struct elevator_queue *eq;
int i;

eq = elevator_alloc(q, e);
if (!eq)
return -ENOMEM;

rdata = kmalloc_node(sizeof(*rdata),
GFP_KERNEL | __GFP_ZERO, q->node);
if (!rdata)
if (!rdata) {
kobject_put(&eq->kobj);
return -ENOMEM;
}
eq->elevator_data = rdata;

memset(rdata, 0, sizeof(*rdata));
for (i = 0; i < ROWQ_MAX_PRIO; i++) {
Expand Down Expand Up @@ -829,7 +831,10 @@ static int row_init_queue(struct request_queue *q)
rdata->last_served_ioprio_class = IOPRIO_CLASS_NONE;
rdata->rd_idle_data.idling_queue_idx = ROWQ_MAX_PRIO;
rdata->dispatch_queue = q;
q->elevator->elevator_data = rdata;

spin_lock_irq(q->queue_lock);
q->elevator = eq;
spin_unlock_irq(q->queue_lock);

return 0;
}
Expand Down

0 comments on commit c03c8f9

Please sign in to comment.