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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14087C43461 for ; Tue, 8 Sep 2020 08:16:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 BA8BB21D20 for ; Tue, 8 Sep 2020 08:16:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WZSYoKci"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JEmGixtz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA8BB21D20 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FJHjASpnLtV7np589WrD453Zzki6VrTwIWk1Yv1nBbw=; b=WZSYoKciO9TwM3UaCrUkh04Oc NyJ/JsbmGyWxFjjAC6smw3qE2FLOfEvMhCiMaRDfzoK7lTUZrLSJbBj+9AJAJuFXSQYCet2QwVl4E JUd6mgKEqqantDfaxDfN2CYo+DuXKNfeQOIq8/2UhyeKAITDC9Kz4vrU8PW0Gi46AT8aQ29tUImC3 /qRExSkkmjClKuuLU1uMrKfll2gw8tdHZCoJLXi9hrQ8VzK/Ai7JZSGscv13Zw68Dp7LVQ6luJ+wX 5e1GZVYRITrcrnl29cX5Fe5H/dfMUrCWHc5zYVP5fv+ImqgxrEx03v3gcEhTaO8CSyyofGQxtwHu2 ZyX6ccVKQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFYnh-0002kL-8R; Tue, 08 Sep 2020 08:16:25 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFYnf-0002jR-4I for linux-nvme@lists.infradead.org; Tue, 08 Sep 2020 08:16:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599552982; 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=5CiY4me6KcqTauM52mAmONnBxxbOnACd/4JWb/pzELQ=; b=JEmGixtz1xJsnb6V7+ms3f38sFdpFD3MUyEDC14ZwxEqpxz+2FIZXjogyx3kaizstWklXx eJMgWEaOBhzMBOeuhFTyJKXhlzMT0MJAti0bc/Uw/BheGUtijDjp7wl5EIPkXKlotwiQmK MZFxPj64OoL1PCebvP34yBh4v9VB7zU= 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-263-QJGLgv0uOqe4B7LjcZZ-0Q-1; Tue, 08 Sep 2020 04:16:18 -0400 X-MC-Unique: QJGLgv0uOqe4B7LjcZZ-0Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2817C8018AB; Tue, 8 Sep 2020 08:16:17 +0000 (UTC) Received: from localhost (ovpn-12-217.pek2.redhat.com [10.72.12.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8889F702E7; Tue, 8 Sep 2020 08:16:13 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Christoph Hellwig , Keith Busch Subject: [PATCH V3 3/4] blk-mq: add tagset quiesce interface Date: Tue, 8 Sep 2020 16:15:37 +0800 Message-Id: <20200908081538.1434936-4-ming.lei@redhat.com> In-Reply-To: <20200908081538.1434936-1-ming.lei@redhat.com> References: <20200908081538.1434936-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_041623_203959_71A3664B X-CRM114-Status: GOOD ( 19.99 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Thumshirn , Chao Leng , Sagi Grimberg , Bart Van Assche , Ming Lei 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 drivers that have shared tagsets may need to quiesce potentially a lot of request queues that all share a single tagset (e.g. nvme). Add an interface to quiesce all the queues on a given tagset. This interface is useful because it can speedup the quiesce by doing it in parallel. For tagsets that have BLK_MQ_F_BLOCKING set, we kill request queue's dispatch percpu-refcount such that all of them wait for the counter becoming zero. For tagsets that don't have BLK_MQ_F_BLOCKING set, we simply call a single synchronize_rcu as this is sufficient. This patch is against Sagi's original post. Signed-off-by: Ming Lei Signed-off-by: Sagi Cc: Sagi Grimberg Cc: Bart Van Assche Cc: Johannes Thumshirn Cc: Chao Leng --- block/blk-mq.c | 68 ++++++++++++++++++++++++++++++++---------- include/linux/blk-mq.h | 2 ++ 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 60630a720449..49933d7dceba 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -209,16 +209,7 @@ void blk_mq_quiesce_queue_nowait(struct request_queue *q) } EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue_nowait); -/** - * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished - * @q: request queue. - * - * Note: this function does not prevent that the struct request end_io() - * callback function is invoked. Once this function is returned, we make - * sure no dispatch can happen until the queue is unquiesced via - * blk_mq_unquiesce_queue(). - */ -void blk_mq_quiesce_queue(struct request_queue *q) +static void __blk_mq_quiesce_queue(struct request_queue *q, bool wait) { bool blocking = !!(q->tag_set->flags & BLK_MQ_F_BLOCKING); @@ -230,14 +221,30 @@ void blk_mq_quiesce_queue(struct request_queue *q) percpu_ref_kill(&q->dispatch_counter); } - if (blocking) - wait_event(q->mq_quiesce_wq, - percpu_ref_is_zero(&q->dispatch_counter)); - else - synchronize_rcu(); + if (wait) { + if (blocking) + wait_event(q->mq_quiesce_wq, + percpu_ref_is_zero(&q->dispatch_counter)); + else + synchronize_rcu(); + } mutex_unlock(&q->mq_quiesce_lock); } + +/** + * blk_mq_quiesce_queue() - wait until all ongoing dispatches have finished + * @q: request queue. + * + * Note: this function does not prevent that the struct request end_io() + * callback function is invoked. Once this function is returned, we make + * sure no dispatch can happen until the queue is unquiesced via + * blk_mq_unquiesce_queue(). + */ +void blk_mq_quiesce_queue(struct request_queue *q) +{ + __blk_mq_quiesce_queue(q, true); +} EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue); /* @@ -265,6 +272,37 @@ void blk_mq_unquiesce_queue(struct request_queue *q) } EXPORT_SYMBOL_GPL(blk_mq_unquiesce_queue); +void blk_mq_quiesce_tagset(struct blk_mq_tag_set *set) +{ + struct request_queue *q; + + mutex_lock(&set->tag_list_lock); + list_for_each_entry(q, &set->tag_list, tag_set_list) + __blk_mq_quiesce_queue(q, false); + + /* wait until all queues' quiesce is done */ + if (set->flags & BLK_MQ_F_BLOCKING) { + list_for_each_entry(q, &set->tag_list, tag_set_list) + wait_event(q->mq_quiesce_wq, + percpu_ref_is_zero(&q->dispatch_counter)); + } else { + synchronize_rcu(); + } + mutex_unlock(&set->tag_list_lock); +} +EXPORT_SYMBOL_GPL(blk_mq_quiesce_tagset); + +void blk_mq_unquiesce_tagset(struct blk_mq_tag_set *set) +{ + struct request_queue *q; + + mutex_lock(&set->tag_list_lock); + list_for_each_entry(q, &set->tag_list, tag_set_list) + blk_mq_unquiesce_queue(q); + mutex_unlock(&set->tag_list_lock); +} +EXPORT_SYMBOL_GPL(blk_mq_unquiesce_tagset); + void blk_mq_wake_waiters(struct request_queue *q) { struct blk_mq_hw_ctx *hctx; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index df642055f02c..90da3582b91d 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -519,6 +519,8 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues); void blk_mq_quiesce_queue_nowait(struct request_queue *q); +void blk_mq_quiesce_tagset(struct blk_mq_tag_set *set); +void blk_mq_unquiesce_tagset(struct blk_mq_tag_set *set); unsigned int blk_mq_rq_cpu(struct request *rq); -- 2.25.2 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme