From patchwork Tue Dec 12 19:01:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10108189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0B89602C2 for ; Tue, 12 Dec 2017 19:03:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E539723B24 for ; Tue, 12 Dec 2017 19:03:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9CA1284E4; Tue, 12 Dec 2017 19:03:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AAD123B24 for ; Tue, 12 Dec 2017 19:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752431AbdLLTBt (ORCPT ); Tue, 12 Dec 2017 14:01:49 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:35021 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbdLLTBo (ORCPT ); Tue, 12 Dec 2017 14:01:44 -0500 Received: by mail-qt0-f195.google.com with SMTP id u10so50012466qtg.2; Tue, 12 Dec 2017 11:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=mOCmIt3C98K7aA2L5EoC9lvpbNY++t7ehANdC7fz2+E=; b=HDn84QJiFqO/zQigdN2CVlDc8pa7otwNXRt6LxK6LKY3ohFjPvVNvc7JAISGD25VQA NGHTlKUb27YU2OJMPDvL5G+C5BGRmOFnKvB9lWr/v4y8CtoFgfubBi36El3pAQp2Apwd Al3d4+hDJkedBORGJTMq6jK0nS4EonBAmmHqzxDz7601JCFVYLu4SUhYsMdtVZfIcE9N ehNqzURBU/Lszee54ySOepwdDEC9OYIFdpSC1lJpCD+cz+JPiGnAbbzOAEWewn8jl2bO k2yy+oNSF13ck8qOuUqf3UsC+dr6Kg6XmkvIIaAFNHFFG1DoCWYZPC+8FNVTxDSP0Yj0 Ke3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=mOCmIt3C98K7aA2L5EoC9lvpbNY++t7ehANdC7fz2+E=; b=oVR0K8jT/Y8KN86Sd5Wl/FSsqa4kiqnA3BnQb+ZkwCYtmep+3Prihtm5Je3EvPCKq/ ZQMGjNUyy3z/cZ9tsYbpO4utlmBF+vJWgyWIiyEXvvUzj0BEO+GY55AhPZlo9Pg+B9TA zMX/et4L5uf6GR+mqpdUB+kbp9BnwBJDfg2UEqRUnfT+a4M0+xUpxt/N4ULflfX1JT7n qmER1Rce6pl9EBh6FUnRzie14PuIy/EudvCLAWkLf6SMZ76XUYnhJP2nR89nT+ijUC30 5ILNK2pEyaMA9LTnG0DnogMCi9f3Mq/lv0BAMOKQdSU45pSwvcaDJiKfjDlXwuLEbWJR 8DZA== X-Gm-Message-State: AKGB3mLgfBox3krwdk+vGG+MGHPrWguZlRZTE4drLPdTB6ML7KKeRHOS Mw5us+EB8CxW4Gl6dqMtPLI= X-Google-Smtp-Source: ACJfBot8gsJtjXyjQSKLWUJH+jqqWcSpwKCySpS/+uIQetv2flLtDsxyFpW6tRt/09O7SWO/TJsgUQ== X-Received: by 10.55.51.73 with SMTP id z70mr6487298qkz.338.1513105301416; Tue, 12 Dec 2017 11:01:41 -0800 (PST) Received: from localhost (dhcp-ec-8-6b-ed-7a-cf.cpe.echoes.net. [72.28.5.223]) by smtp.gmail.com with ESMTPSA id p85sm6905284qkp.94.2017.12.12.11.01.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:01:40 -0800 (PST) From: Tejun Heo To: 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, Tejun Heo Subject: [PATCH 1/6] blk-mq: protect completion path with RCU Date: Tue, 12 Dec 2017 11:01:29 -0800 Message-Id: <20171212190134.535941-2-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171212190134.535941-1-tj@kernel.org> References: <20171212190134.535941-1-tj@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); + } } EXPORT_SYMBOL(blk_mq_complete_request);