From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50996C433F5 for ; Thu, 30 Sep 2021 12:59:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A21C61452 for ; Thu, 30 Sep 2021 12:59:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1A21C61452 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tnxoKtzQsL1nVLuR/UfbprAiRfNoS+RwIvn2NOauPzs=; b=MxucoDlqktrgVE ilpJQWnWBdgZL7mTwFn2FvhpOmi4ShNIUzdzxRdd/R/6w1BMEpTJpReELWL/DvRv9CVfZCoQmIXTx iBZOuJO8+Sh3TfDzk2QeVmCvfJcSiEOXwI35g6qj0pW3FssTZ0csB0sqJEYowVds0rS95gwF4L8V3 VyBUwl3Zgu2KcliBqvhzzkouBe02G+dIzXL/wwWZuF28285f+Q6HOC3GeBiAlK3KrGBsvcCfZV1L2 Ap+Xd2SxNkJJC46bTgRZwomNjMm0kx9osmyt2pSSNPc1A8xrD9ZUPBOuLaknJxsl8rtDydpdtpgK2 hbUi8+LfJRwQUjiGgUIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVvdT-00EK7d-7x; Thu, 30 Sep 2021 12:58:03 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVvcz-00EJyB-DX for linux-nvme@lists.infradead.org; Thu, 30 Sep 2021 12:57:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633006652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jN4b3GyfHa+amFzmyGSuIhBG2KY0aTYefQa+d6RG6DE=; b=a0IoCJ4NaidwnFaMwe37QXKBDvth89f14WFdX3tMzo4j0ZtOoljA4plPh5u8/9DMmC4+Jy 69sTgwOfUkswahmtGCt8d7oyNbLOZOxC0M5S6VXBdIIni0zdZiEYlUuf9ZS3BId72izIru 1lXSajzRpVrXw34KI0MJIw5PBK3FwE0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-k1bzz9uhOOW80irEMUyeKQ-1; Thu, 30 Sep 2021 08:57:28 -0400 X-MC-Unique: k1bzz9uhOOW80irEMUyeKQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0753B1060D71; Thu, 30 Sep 2021 12:57:06 +0000 (UTC) Received: from localhost (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B58AA88EF8; Thu, 30 Sep 2021 12:57:04 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Sagi Grimberg , Keith Busch , Ming Lei Subject: [PATCH V2 5/5] blk-mq: support concurrent queue quiesce/unquiesce Date: Thu, 30 Sep 2021 20:56:21 +0800 Message-Id: <20210930125621.1161726-6-ming.lei@redhat.com> In-Reply-To: <20210930125621.1161726-1-ming.lei@redhat.com> References: <20210930125621.1161726-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210930_055733_575437_D2C564A1 X-CRM114-Status: GOOD ( 19.78 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org Turns out that blk_mq_freeze_queue() isn't stronger[1] than blk_mq_quiesce_queue() because dispatch may still be in-progress after queue is frozen, and in several cases, such as switching io scheduler, updating nr_requests & wbt latency, we still need to quiesce queue as a supplement of freezing queue. As we need to extend uses of blk_mq_quiesce_queue(), it is inevitable for us to need support nested quiesce, especially we can't let unquiesce happen when there is quiesce originated from other contexts. This patch introduces q->mq_quiesce_depth to deal concurrent quiesce, and we only unquiesce queue when it is the last/outer-most one of all contexts. One kernel panic issue has been reported[2] when running stress test on dm-mpath's updating nr_requests and suspending queue, and the similar issue should exist on almost all drivers which use quiesce/unquiesce. [1] https://marc.info/?l=linux-block&m=150993988115872&w=2 [2] https://listman.redhat.com/archives/dm-devel/2021-September/msg00189.html Signed-off-by: Ming Lei --- block/blk-mq.c | 20 +++++++++++++++++--- include/linux/blkdev.h | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 21bf4c3f0825..10f8a3d4e3a1 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -209,7 +209,12 @@ EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue); */ void blk_mq_quiesce_queue_nowait(struct request_queue *q) { - blk_queue_flag_set(QUEUE_FLAG_QUIESCED, q); + unsigned long flags; + + spin_lock_irqsave(&q->queue_lock, flags); + if (!q->quiesce_depth++) + blk_queue_flag_set(QUEUE_FLAG_QUIESCED, q); + spin_unlock_irqrestore(&q->queue_lock, flags); } EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait); @@ -250,10 +255,19 @@ EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue); */ void blk_mq_unquiesce_queue(struct request_queue *q) { - blk_queue_flag_clear(QUEUE_FLAG_QUIESCED, q); + unsigned long flags; + bool run_queue = false; + + spin_lock_irqsave(&q->queue_lock, flags); + if (q->quiesce_depth > 0 && !--q->quiesce_depth) { + blk_queue_flag_clear(QUEUE_FLAG_QUIESCED, q); + run_queue = true; + } + spin_unlock_irqrestore(&q->queue_lock, flags); /* dispatch requests which are inserted during quiescing */ - blk_mq_run_hw_queues(q, true); + if (run_queue) + blk_mq_run_hw_queues(q, true); } EXPORT_SYMBOL_GPL(blk_mq_unquiesce_queue); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 0e960d74615e..74c60e2d61f9 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -315,6 +315,8 @@ struct request_queue { */ struct mutex mq_freeze_lock; + int quiesce_depth; + struct blk_mq_tag_set *tag_set; struct list_head tag_set_list; struct bio_set bio_split; -- 2.31.1 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme