Skip to content

Commit

Permalink
block: Provide blk_mq_sched_get_icq()
Browse files Browse the repository at this point in the history
Currently we lookup ICQ only after the request is allocated. However BFQ
will want to decide how many scheduler tags it allows a given bfq queue
(effectively a process) to consume based on cgroup weight. So provide a
function blk_mq_sched_get_icq() so that BFQ can lookup ICQ earlier.

Acked-by: Paolo Valente <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
jankara authored and axboe committed Nov 29, 2021
1 parent 639d353 commit 790cf9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
26 changes: 15 additions & 11 deletions block/blk-mq-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,36 @@
#include "blk-mq-tag.h"
#include "blk-wbt.h"

void blk_mq_sched_assign_ioc(struct request *rq)
struct io_cq *blk_mq_sched_get_icq(struct request_queue *q)
{
struct request_queue *q = rq->q;
struct io_context *ioc;
struct io_cq *icq;

/* create task io_context, if we don't have one already */
if (unlikely(!current->io_context))
create_task_io_context(current, GFP_ATOMIC, q->node);

/*
* May not have an IO context if it's a passthrough request
*/
/* May not have an IO context if context creation failed */
ioc = current->io_context;
if (!ioc)
return;
return NULL;

spin_lock_irq(&q->queue_lock);
icq = ioc_lookup_icq(ioc, q);
spin_unlock_irq(&q->queue_lock);
if (icq)
return icq;
return ioc_create_icq(ioc, q, GFP_ATOMIC);
}
EXPORT_SYMBOL(blk_mq_sched_get_icq);

if (!icq) {
icq = ioc_create_icq(ioc, q, GFP_ATOMIC);
if (!icq)
return;
}
void blk_mq_sched_assign_ioc(struct request *rq)
{
struct io_cq *icq;

icq = blk_mq_sched_get_icq(rq->q);
if (!icq)
return;
get_io_context(icq->ioc);
rq->elv.icq = icq;
}
Expand Down
1 change: 1 addition & 0 deletions block/blk-mq-sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#define MAX_SCHED_RQ (16 * BLKDEV_DEFAULT_RQ)

struct io_cq *blk_mq_sched_get_icq(struct request_queue *q);
void blk_mq_sched_assign_ioc(struct request *rq);

bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
Expand Down

0 comments on commit 790cf9c

Please sign in to comment.