Skip to content

Commit

Permalink
cfq-iosched: Convert to use highres timers
Browse files Browse the repository at this point in the history
Reviewed-by: Jeff Moyer <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Jan Kara authored and axboe committed Jun 8, 2016
1 parent d2d481d commit 9114832
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ struct cfq_data {
/*
* idle window management
*/
struct timer_list idle_slice_timer;
struct hrtimer idle_slice_timer;
struct work_struct unplug_work;

struct cfq_queue *active_queue;
Expand Down Expand Up @@ -2627,7 +2627,7 @@ static int cfq_allow_merge(struct request_queue *q, struct request *rq,

static inline void cfq_del_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq)
{
del_timer(&cfqd->idle_slice_timer);
hrtimer_try_to_cancel(&cfqd->idle_slice_timer);
cfqg_stats_update_idle_time(cfqq->cfqg);
}

Expand Down Expand Up @@ -2989,7 +2989,8 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd)
else
sl = cfqd->cfq_slice_idle;

mod_timer(&cfqd->idle_slice_timer, now + sl);
hrtimer_start(&cfqd->idle_slice_timer, ns_to_ktime(sl),
HRTIMER_MODE_REL);
cfqg_stats_set_start_idle_time(cfqq->cfqg);
cfq_log_cfqq(cfqd, cfqq, "arm_idle: %llu group_idle: %d", sl,
group_idle ? 1 : 0);
Expand Down Expand Up @@ -3308,7 +3309,7 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
* flight or is idling for a new request, allow either of these
* conditions to happen (or time out) before selecting a new queue.
*/
if (timer_pending(&cfqd->idle_slice_timer)) {
if (hrtimer_active(&cfqd->idle_slice_timer)) {
cfqq = NULL;
goto keep_queue;
}
Expand Down Expand Up @@ -4454,9 +4455,10 @@ static void cfq_kick_queue(struct work_struct *work)
/*
* Timer running if the active_queue is currently idling inside its time slice
*/
static void cfq_idle_slice_timer(unsigned long data)
static enum hrtimer_restart cfq_idle_slice_timer(struct hrtimer *timer)
{
struct cfq_data *cfqd = (struct cfq_data *) data;
struct cfq_data *cfqd = container_of(timer, struct cfq_data,
idle_slice_timer);
struct cfq_queue *cfqq;
unsigned long flags;
int timed_out = 1;
Expand Down Expand Up @@ -4505,11 +4507,12 @@ static void cfq_idle_slice_timer(unsigned long data)
cfq_schedule_dispatch(cfqd);
out_cont:
spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
return HRTIMER_NORESTART;
}

static void cfq_shutdown_timer_wq(struct cfq_data *cfqd)
{
del_timer_sync(&cfqd->idle_slice_timer);
hrtimer_cancel(&cfqd->idle_slice_timer);
cancel_work_sync(&cfqd->unplug_work);
}

Expand Down Expand Up @@ -4605,9 +4608,9 @@ static int cfq_init_queue(struct request_queue *q, struct elevator_type *e)
cfqg_put(cfqd->root_group);
spin_unlock_irq(q->queue_lock);

init_timer(&cfqd->idle_slice_timer);
hrtimer_init(&cfqd->idle_slice_timer, CLOCK_MONOTONIC,
HRTIMER_MODE_REL);
cfqd->idle_slice_timer.function = cfq_idle_slice_timer;
cfqd->idle_slice_timer.data = (unsigned long) cfqd;

INIT_WORK(&cfqd->unplug_work, cfq_kick_queue);

Expand Down

0 comments on commit 9114832

Please sign in to comment.