Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1646748pxb; Mon, 8 Mar 2021 02:56:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaX9/iBY3ot7jvbgd74W9bYbqun6BzYdJUxAT0eLdsSkg1wWeP+twWIvfc4k3Y2JTtemrL X-Received: by 2002:a17:907:37a:: with SMTP id rs26mr14382606ejb.336.1615200988625; Mon, 08 Mar 2021 02:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615200988; cv=none; d=google.com; s=arc-20160816; b=QfbEgUxFj6XdC6glHpcCDWI+qBONWhAhTOKaVdW5Td3x+F4V7xFzrO4WKjCG3dg1kJ Q5KBBxrytoXv+IH0n2WfahEIGX1Tc1HhnhJuc8WwJWEtHYXOYbUcT+p/2/XQ0el3YYVU YpwuK7OEY8UQfnu0UwtFm7gmPEBR9q/Es6IZZ8qr/mPykzaWFwVSuVdQ+ekUeSfurNy6 d0110c0xrf5cD4ZIaEajA/uKwLcgVO6+nMdHAR6KwXtxrEKrUHN15Tjm7RlOx6PYzoYf mrfWJEBuP1UjY9HphOdwSL6VGaQvbZioy7kp2yOoqFW8zQWd46oBMHWSbQGY1rmjXN0Q TznA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=y3n9ZRX7EwH5bQQbp7LFhS9pNAUJFxWXkbd63uSNZ0A=; b=KNYu0yD2oUb1FU0zXFCkKVJ1i7dp0JftUT5Ibl3Pz38NjoIzZrVICEGGdiwYOsaLoV qhJVsZJ6yh8zy+UB+NvZJfkRik8hXpB5e3OscA6o5sOQLr866KXmiLVs1HsrFtBDzWic s9v5UxmD4dRk3k0Xvtm/8msTMyXlDKSgi8m1JDXkUoSfjyeB5Anmceb6kARYHMbgnIXX 73vc42C5mYhldWy2zS7VjakB42uqer/p1mSrNd/LsqDaWkoZ5DIOJdu+0y8pwVJ9Lntk axq6VvjRJwD9rOqc7RipellJMIpEmgKfy+HF6ZWfHwLLZ247OYB800DjwjfAQYogA534 vovA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p31si7542301edb.298.2021.03.08.02.56.06; Mon, 08 Mar 2021 02:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231430AbhCHKxI (ORCPT + 99 others); Mon, 8 Mar 2021 05:53:08 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2650 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhCHKw5 (ORCPT ); Mon, 8 Mar 2021 05:52:57 -0500 Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DvFSM0Fy1z67wYf; Mon, 8 Mar 2021 18:48:35 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml742-chm.china.huawei.com (10.206.15.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 8 Mar 2021 11:52:55 +0100 Received: from [10.210.165.214] (10.210.165.214) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 8 Mar 2021 10:52:54 +0000 Subject: Re: [RFC PATCH v3 2/3] blk-mq: Freeze and quiesce all queues for tagset in elevator_exit() To: Bart Van Assche , , , , CC: , , , , References: <1614957294-188540-1-git-send-email-john.garry@huawei.com> <1614957294-188540-3-git-send-email-john.garry@huawei.com> <52618092-07ca-ecb5-320f-957af26ab146@acm.org> From: John Garry Message-ID: <3c6cbe11-ac31-9a47-0096-17fbd584b83e@huawei.com> Date: Mon, 8 Mar 2021 10:50:55 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <52618092-07ca-ecb5-320f-957af26ab146@acm.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.210.165.214] X-ClientProxiedBy: lhreml739-chm.china.huawei.com (10.201.108.189) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/03/2021 04:32, Bart Van Assche wrote: > On 3/5/21 7:14 AM, John Garry wrote: >> diff --git a/block/blk.h b/block/blk.h >> index 3b53e44b967e..1a948bfd91e4 100644 >> --- a/block/blk.h >> +++ b/block/blk.h >> @@ -201,10 +201,29 @@ void elv_unregister_queue(struct request_queue *q); >> static inline void elevator_exit(struct request_queue *q, >> struct elevator_queue *e) >> { >> + struct blk_mq_tag_set *set = q->tag_set; >> + struct request_queue *tmp; >> + >> lockdep_assert_held(&q->sysfs_lock); >> >> + mutex_lock(&set->tag_list_lock); >> + list_for_each_entry(tmp, &set->tag_list, tag_set_list) { >> + if (tmp == q) >> + continue; >> + blk_mq_freeze_queue(tmp); >> + blk_mq_quiesce_queue(tmp); >> + } >> + >> blk_mq_sched_free_requests(q); >> __elevator_exit(q, e); >> + >> + list_for_each_entry(tmp, &set->tag_list, tag_set_list) { >> + if (tmp == q) >> + continue; >> + blk_mq_unquiesce_queue(tmp); >> + blk_mq_unfreeze_queue(tmp); >> + } >> + mutex_unlock(&set->tag_list_lock); >> } Hi Bart, > This patch introduces nesting of tag_list_lock inside sysfs_lock. The > latter is per request queue while the former can be shared across > multiple request queues. Has it been analyzed whether this is safe? Firstly - ignoring implementation details for a moment - this patch is to ensure that the concept is consistent with your suggestion and whether it is sound. As for nested locking, I can analyze more, but I did assume that we don't care about locking-out sysfs intervention during this time. And it seems pretty difficult to avoid nesting the locks. And further to this, I see that https://lore.kernel.org/linux-block/3aa5407c-0800-2482-597b-4264781a7eac@grimberg.me/T/#mc3e3175642660578c0ae2a6c32185b1e34ec4b8a has a new interface for tagset quiesce, which could make this process more efficient. Please let me know further thoughts. Thanks, John