From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752523AbdLMDbV (ORCPT ); Tue, 12 Dec 2017 22:31:21 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:50972 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752160AbdLMDbO (ORCPT ); Tue, 12 Dec 2017 22:31:14 -0500 Subject: Re: [PATCH 1/6] blk-mq: protect completion path with RCU To: Tejun Heo , axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, oleg@redhat.com, peterz@infradead.org, kernel-team@fb.com, osandov@fb.com, linux-block@vger.kernel.org, hch@lst.de References: <20171212190134.535941-1-tj@kernel.org> <20171212190134.535941-2-tj@kernel.org> From: "jianchao.wang" Message-ID: <402aea05-8d04-99e2-5e31-803d2423283d@oracle.com> Date: Wed, 13 Dec 2017 11:30:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171212190134.535941-2-tj@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8743 signatures=668646 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712130046 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello tejun Sorry for missing the V2, same comment again. On 12/13/2017 03:01 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 > --- > 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. If just synchronize with the timeout path to ensure the aborted_gstate to be seen, only rcu is needed here ,as well as the blk_mq_timeout_work. > + } > } > EXPORT_SYMBOL(blk_mq_complete_request); > >