[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1cbbcfbc-9e28-a792-a5aa-b7a8e09ae51f@oracle.com>
Date: Wed, 13 Dec 2017 11:10:19 +0800
From: "jianchao.wang" <jianchao.w.wang@...cle.com>
To: Tejun Heo <tj@...nel.org>, axboe@...nel.dk
Cc: linux-kernel@...r.kernel.org, oleg@...hat.com,
peterz@...radead.org, kernel-team@...com, osandov@...com
Subject: Re: [PATCH 1/6] blk-mq: protect completion path with RCU
Hi tejun
On 12/10/2017 03:25 AM, Tejun Heo wrote:
> Currently, blk-mq protects only the issue path with RCU. This patch
> puts the completion path under the same RCU protection. This will be
> used to synchronize issue/completion against timeout by later patches,
> which will also add the comments.
>
> Signed-off-by: Tejun Heo <tj@...nel.org>
> ---
> block/blk-mq.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 1109747..acf4fbb 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -568,11 +568,23 @@ static void __blk_mq_complete_request(struct request *rq)
> void blk_mq_complete_request(struct request *rq)
> {
> struct request_queue *q = rq->q;
> + struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, rq->mq_ctx->cpu);
> + int srcu_idx;
>
> if (unlikely(blk_should_fake_timeout(q)))
> return;
> - if (!blk_mark_rq_complete(rq))
> - __blk_mq_complete_request(rq);
> +
> + if (!(hctx->flags & BLK_MQ_F_BLOCKING)) {
> + rcu_read_lock();
> + if (!blk_mark_rq_complete(rq))
> + __blk_mq_complete_request(rq);
> + rcu_read_unlock();
> + } else {
> + srcu_idx = srcu_read_lock(hctx->queue_rq_srcu);
> + if (!blk_mark_rq_complete(rq))
> + __blk_mq_complete_request(rq);
> + srcu_read_unlock(hctx->queue_rq_srcu, srcu_idx);
> + }
The __blk_mq_complete_request() could be executed in irq context. There should not be any
sleeping operations in it. So the srcu case here is not necessary here.
Thanks
Jianchao
> }
> EXPORT_SYMBOL(blk_mq_complete_request);
>
>
Powered by blists - more mailing lists