[1/3] blk-mq: remove redundant call to blk_freeze_queue_start in blk_mq_destroy_queue
Message ID | ebd3a47a1ebf4ab518c985cdbaa1ac3afd6dfb9f.1667035519.git.nickyc975@zju.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1273747wru; Sat, 29 Oct 2022 03:04:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kZI6Ts5gqlYc5tn7sGb95XUq+gwIZlnDp78HmXNyK9vtP4zsspTrddFVbZozrhHiKdoej X-Received: by 2002:a05:6402:2685:b0:462:73aa:c23d with SMTP id w5-20020a056402268500b0046273aac23dmr3575816edd.390.1667037879561; Sat, 29 Oct 2022 03:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667037879; cv=none; d=google.com; s=arc-20160816; b=VKatXMCULQqgx86VMddSc/8J8+/pTU76gIM6Ca6Nw143xQYoxuSuQgZmOuzYBUwbHy w6D2Oqprpv/UqG0dYAcHpacDKVs0+gFyJZ+7kiH6etE1JsEq0WPhA//73r3u6x8HUdJo ZEvwL/S3DZZi4rm3GcxSVF2cwNhDrv6xcTMPwWkr2DfIudUxFPM9aa2M2yo+Xfd5BVag 8jAPvAv8ZgCqbD5X54q5FfMt406SJvti/skZOZKbANeybTj3Lr2Ztc8+PE7Uj8VpX3W4 tQyBiB5Wi5Wuw8nCDUETUqc6njBCAG4wvh1y+IAGjHprhZ+LGmVucHwAy+0nn8dccSji 7DtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qGe4w43M2a0oq4Ikf/Ib05MiFqBwbHwvAGC5iWZ9OrQ=; b=083W4gLV76Zwxuw2aMFqACa/kl5KyMm9z8kcLnDAmMZOzS4bHcI9hVg03PJONeIJ79 AoMJcrai/xaPrZsPRdFB91x7312CAtAHQpllrBgjiorpPxjji7CV8zZRcXGGJ1EVapr+ e4lMw0tuHi0fqcnn/d8txz+A7/0/OuyuRtMRisPHFYM/cYzJkCRDVqEnRHdTg4zNAI9X E1nIaw/r4iR8J3ia0X4HsnV71OeTB1GDWVlmVs48fGTCHwehUgmioiy/5/WioG9jEHSy aMaxEVwjQ69QZ8K043+OpeG+G2wv+Ck8J7oCEpf2LbyPV19zhBPDaw/oVW9UpQBnhV43 ebng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b0078223ff2756si1412876ejc.244.2022.10.29.03.04.15; Sat, 29 Oct 2022 03:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbiJ2KCn (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Sat, 29 Oct 2022 06:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiJ2KCl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 29 Oct 2022 06:02:41 -0400 Received: from zju.edu.cn (spam.zju.edu.cn [61.164.42.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A2E9E69BCD; Sat, 29 Oct 2022 03:02:39 -0700 (PDT) Received: from localhost.localdomain (unknown [10.14.30.251]) by mail-app3 (Coremail) with SMTP id cC_KCgCHjQwl+lxjdEpxCA--.43876S3; Sat, 29 Oct 2022 18:02:29 +0800 (CST) From: Jinlong Chen <nickyc975@zju.edu.cn> To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, nickyc975@zju.edu.cn Subject: [PATCH 1/3] blk-mq: remove redundant call to blk_freeze_queue_start in blk_mq_destroy_queue Date: Sat, 29 Oct 2022 18:02:09 +0800 Message-Id: <ebd3a47a1ebf4ab518c985cdbaa1ac3afd6dfb9f.1667035519.git.nickyc975@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <cover.1667035519.git.nickyc975@zju.edu.cn> References: <cover.1667035519.git.nickyc975@zju.edu.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cC_KCgCHjQwl+lxjdEpxCA--.43876S3 X-Coremail-Antispam: 1UD129KBjvdXoW7Xw1xtw4xGw1xAF4Dtr43Jrb_yoWfWFc_Wa 4UCFy2yFZ8GF15ur1jkF15ZFn2kw1kJFy7GFWDW3srJwn5AanIyw47Cr1rCr4DW3y2kasr Wr1DG397Jr40gjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbs8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E 87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1lnxkEFVAIw20F6c xK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij 64vIr41l42xK82IY6x8ErcxFaVAv8VW8uw4UJr1UMxC20s026xCaFVCjc4AY6r1j6r4UMI 8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AK xVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI 8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280 aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43 ZEXa7VUbHa0DUUUUU== X-CM-SenderInfo: qssqjiaqqzq6lmxovvfxof0/1tbiAgwSB1ZdtcJ3NwABsm X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748015911570343535?= X-GMAIL-MSGID: =?utf-8?q?1748015911570343535?= |
Series |
cleanups for queue freezing functions
|
|
Commit Message
Jinlong Chen
Oct. 29, 2022, 10:02 a.m. UTC
Calling blk_freeze_queue results in a redundant call to
blk_freeze_queue_start as it has been called in blk_queue_start_drain.
Replace blk_freeze_queue with blk_mq_freeze_queue_wait to avoid the
redundant call.
Signed-off-by: Jinlong Chen <nickyc975@zju.edu.cn>
---
block/blk-mq.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
On 10/29/22 03:02, Jinlong Chen wrote: > Calling blk_freeze_queue results in a redundant call to > blk_freeze_queue_start as it has been called in blk_queue_start_drain. > > Replace blk_freeze_queue with blk_mq_freeze_queue_wait to avoid the > redundant call. blk_mq_destroy_queue() has more callers than blk_queue_start_drain() so the above description is at least misleading. Additionally, the word "cleanup" from the patch series title indicates that no patch in this series changes the behavior of the code. This patch involves a behavior change. I think this patch introduces a hang for every caller of blk_mq_destroy_queue() other than blk_queue_start_drain(). Bart.
Hi, Bart. > > Calling blk_freeze_queue results in a redundant call to > > blk_freeze_queue_start as it has been called in blk_queue_start_drain. > > > > Replace blk_freeze_queue with blk_mq_freeze_queue_wait to avoid the > > redundant call. > > blk_mq_destroy_queue() has more callers than blk_queue_start_drain() so > the above description is at least misleading. > > Additionally, the word "cleanup" from the patch series title indicates > that no patch in this series changes the behavior of the code. This > patch involves a behavior change. Sorry for my poor description. I'll send a new series with these description problems resolved. > I think this patch introduces a hang for every caller of > blk_mq_destroy_queue() other than blk_queue_start_drain(). > > Bart. I don't see why the patch introduces a hang. The calling relationship in blk_mq_destroy_queue is as follows: blk_mq_destroy_queue() ... -> blk_queue_start_drain() -> blk_freeze_queue_start() <- called ... -> blk_freeze_queue() -> blk_freeze_queue_start() <- called again -> blk_mq_freeze_queue_wait() ... So I think there is a redundant call to blk_freeze_queue_start(), we just need to call blk_mq_freeze_queue_wait() after calling blk_queue_start_drain(). Thanks! Jinlong Chen
On 10/29/22 19:27, Jinlong Chen wrote: >> I think this patch introduces a hang for every caller of >> blk_mq_destroy_queue() other than blk_queue_start_drain(). >> I don't see why the patch introduces a hang. The calling relationship in > blk_mq_destroy_queue is as follows: [ ... ] Agreed - what I wrote is wrong. > So I think there is a redundant call to blk_freeze_queue_start(), we > just need to call blk_mq_freeze_queue_wait() after calling > blk_queue_start_drain(). I think it is on purpose that blk_queue_start_drain() freezes the request queue and never unfreezes it. So if you want to change this behavior it's up to you to motivate why you want to change this behavior and also why it is safe to make that change. See also commit d3cfb2a0ac0b ("block: block new I/O just after queue is set as dying"). Bart.
> > So I think there is a redundant call to blk_freeze_queue_start(), we > > just need to call blk_mq_freeze_queue_wait() after calling > > blk_queue_start_drain(). > > I think it is on purpose that blk_queue_start_drain() freezes the > request queue and never unfreezes it. So if you want to change this > behavior it's up to you to motivate why you want to change this behavior > and also why it is safe to make that change. See also commit > d3cfb2a0ac0b ("block: block new I/O just after queue is set as dying"). > > Bart. I think there might be some misunderstanding. I didn't touch blk_queue_start_drain(), so its behavior is not changed. What I have done is just replacing blk_freeze_queue() with blk_mq_freeze_queue_wait() in blk_mq_destroy_queue(). See: - https://lore.kernel.org/linux-block/20221030084011.GA5262@lst.de/T/#t Thanks! Jinlong Chen
On 10/30/22 07:55, Jinlong Chen wrote: >>> So I think there is a redundant call to blk_freeze_queue_start(), we >>> just need to call blk_mq_freeze_queue_wait() after calling >>> blk_queue_start_drain(). >> >> I think it is on purpose that blk_queue_start_drain() freezes the >> request queue and never unfreezes it. So if you want to change this >> behavior it's up to you to motivate why you want to change this behavior >> and also why it is safe to make that change. See also commit >> d3cfb2a0ac0b ("block: block new I/O just after queue is set as dying"). > > I think there might be some misunderstanding. I didn't touch > blk_queue_start_drain(), so its behavior is not changed. What I have done > is just replacing blk_freeze_queue() with blk_mq_freeze_queue_wait() in > blk_mq_destroy_queue(). Hi Jinlong, Does this mean that you want me to provide more information about what I wrote? Without this patch, blk_mq_destroy_queue() uses two mechanisms to block future I/O requests: 1. Set the flag QUEUE_FLAG_DYING. 2. Freeze the request queue and leave it frozen. Your patch modifies blk_mq_destroy_queue() such that it unfreezes the request queue after I/O has been quiesced instead of leaving it frozen. I would appreciate it if Ming Lei (Cc-ed) could comment on this change since I think that Ming introduced (2) in blk_mq_destroy_queue() (formerly called blk_cleanup_queue()). Thanks, Bart.
> On 10/30/22 07:55, Jinlong Chen wrote: > >>> So I think there is a redundant call to blk_freeze_queue_start(), we > >>> just need to call blk_mq_freeze_queue_wait() after calling > >>> blk_queue_start_drain(). > >> > >> I think it is on purpose that blk_queue_start_drain() freezes the > >> request queue and never unfreezes it. So if you want to change this > >> behavior it's up to you to motivate why you want to change this behavior > >> and also why it is safe to make that change. See also commit > >> d3cfb2a0ac0b ("block: block new I/O just after queue is set as dying"). > > > > I think there might be some misunderstanding. I didn't touch > > blk_queue_start_drain(), so its behavior is not changed. What I have done > > is just replacing blk_freeze_queue() with blk_mq_freeze_queue_wait() in > > blk_mq_destroy_queue(). > > Hi Jinlong, > > Does this mean that you want me to provide more information about what I > wrote? Without this patch, blk_mq_destroy_queue() uses two mechanisms to > block future I/O requests: > 1. Set the flag QUEUE_FLAG_DYING. > 2. Freeze the request queue and leave it frozen. I agreed. > Your patch modifies blk_mq_destroy_queue() such that it unfreezes the > request queue after I/O has been quiesced instead of leaving it frozen. This is what blk_mq_destroy_queue() looks like with the patch (removed the stupid comment as suggested by Christoph Hellwig): void blk_mq_destroy_queue(struct request_queue *q) { WARN_ON_ONCE(!queue_is_mq(q)); WARN_ON_ONCE(blk_queue_registered(q)); might_sleep(); blk_queue_flag_set(QUEUE_FLAG_DYING, q); blk_queue_start_drain(q); blk_mq_freeze_queue_wait(q); blk_sync_queue(q); blk_mq_cancel_work_sync(q); blk_mq_exit_queue(q); } I can't see where the unfreezing happens. Did I miss something? > I would appreciate it if Ming Lei (Cc-ed) could comment on this change > since I think that Ming introduced (2) in blk_mq_destroy_queue() > (formerly called blk_cleanup_queue()). I would appreciate it too. Thanks! Jinlong Chen
diff --git a/block/blk-mq.c b/block/blk-mq.c index 4cecf281123f..14c4165511b9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4005,7 +4005,12 @@ void blk_mq_destroy_queue(struct request_queue *q) blk_queue_flag_set(QUEUE_FLAG_DYING, q); blk_queue_start_drain(q); - blk_freeze_queue(q); + + /* + * blk_freeze_queue_start has been called in blk_queue_start_drain, we just + * need to wait. + */ + blk_mq_freeze_queue_wait(q); blk_sync_queue(q); blk_mq_cancel_work_sync(q);