Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2748136pxb; Tue, 9 Mar 2021 09:50:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4JU0ORPdZhdlTGX7hs/m9gVIzOmMOOUGwdOz6nK+PCQAGGb2+N5n+n2/nbWgsIdNRywX1 X-Received: by 2002:a17:906:c414:: with SMTP id u20mr21314703ejz.215.1615312259115; Tue, 09 Mar 2021 09:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615312259; cv=none; d=google.com; s=arc-20160816; b=pDvp/vx9AdUMk4AeJMwFaTizoamIMFGp7WmRsMlTHOhl2dfHB15FPJGpGcmm5QZm/w ghAulbarMv04NGrQYME9bDuI4gZxAP2IBmve5pmNo34YobRCb/T1Ib3DTYLPVCy9paZn DYw/Q8GQh7yokaZyICH1OxCdkcX09GcKXX1uz/S1YRDVmiW1SgO2RP5BeZ5tRGp1ucGb GbcIC0hszQxMuncRmnaz8c90/EznwMuvLqhV2nrPrlKllmZP38qHeHW3wSyPKsGN+Cv/ cDp1KEm3/yphEMWqkLA31ayeNVcnWpkaG7b1bTb4WU6xwtCh0mva9zI6Arl9qq4m7qO6 HZuw== 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=8jMHgVqy4ZL6kxXlp4lmlDM5Lst+PWZ9Lwy8PhTimJg=; b=ZqCCUCHN7nkDRnqBgzU1ewc+/oUD6sr2yS9jyoLtfxHXx3a+AThwsel1W/N/U/L79q 1w9LMJP8Uyg7imTmTo1u0OXepmXsS5a12yhmp1pp0RFWHifEgaANlEAzCR8XCxWVWJrj zq3xpmHfXT1EIboHGuHcYe2+eDmTMb2VRfSkF0fWLXaiNyB6AXPach+4QxDunR/EHmYT 9ApOT2KejLyZZpSqjKbdwfeEgxyO+J24dIYmOh5/HMlOqe0C70XSXNdwfmjLmNPiKLvE QQf06bseWf2DuTxbYXVW48i0GknYvuoS8hMfw9vMSvlspfXa3r1H0G/iqcyNT1zutAaQ EgEw== 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 s28si10327267edw.110.2021.03.09.09.50.35; Tue, 09 Mar 2021 09:50:59 -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 S230173AbhCIRt2 (ORCPT + 99 others); Tue, 9 Mar 2021 12:49:28 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2673 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbhCIRtU (ORCPT ); Tue, 9 Mar 2021 12:49:20 -0500 Received: from fraeml744-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Dw2fH35Pdz67x39; Wed, 10 Mar 2021 01:44:55 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml744-chm.china.huawei.com (10.206.15.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 9 Mar 2021 18:49:18 +0100 Received: from [10.210.172.22] (10.210.172.22) 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; Tue, 9 Mar 2021 17:49:16 +0000 Subject: Re: [RFC PATCH v3 3/3] blk-mq: Lockout tagset iterator when exiting elevator To: Bart Van Assche , , , , CC: , , , , References: <1614957294-188540-1-git-send-email-john.garry@huawei.com> <1614957294-188540-4-git-send-email-john.garry@huawei.com> <48a3cf78-3f6d-c13c-bca2-1f8277817b45@acm.org> <9c9360bf-7ca9-5c8f-c61d-441044f9c78f@huawei.com> <784a3686-cb54-561d-740c-30e0b3f46df8@acm.org> From: John Garry Message-ID: Date: Tue, 9 Mar 2021 17:47:15 +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: <784a3686-cb54-561d-740c-30e0b3f46df8@acm.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.210.172.22] X-ClientProxiedBy: lhreml748-chm.china.huawei.com (10.201.108.198) 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 08/03/2021 19:59, Bart Van Assche wrote: >>> This changes the behavior of blk_mq_tagset_busy_iter(). What will e.g. >>> happen if the mtip driver calls blk_mq_tagset_busy_iter(&dd->tags, >>> mtip_abort_cmd, dd) concurrently with another blk_mq_tagset_busy_iter() >>> call and if that causes all mtip_abort_cmd() calls to be skipped? >> >> I'm not sure that I understand this problem you describe. So if >> blk_mq_tagset_busy_iter(&dd->tags, mtip_abort_cmd, dd) is called, >> either can happen: >> a. normal operation, iter_usage_counter initially holds >= 1, and then >> iter_usage_counter is incremented in blk_mq_tagset_busy_iter() and we >> iter the busy tags. Any parallel call to blk_mq_tagset_busy_iter() >> will also increase iter_usage_counter. >> b. we're switching IO scheduler. In this scenario, first we quiesce >> all queues. After that, there should be no active requests. At that >> point, we ensure any calls to blk_mq_tagset_busy_iter() are finished >> and block (or discard may be a better term) any more calls. Blocking >> any more calls should be safe as there are no requests to iter. >> atomic_cmpxchg() is used to set iter_usage_counter to 0, blocking any >> more calls. > Hi Bart, > My concern is about the insertion of the early return statement in > blk_mq_tagset_busy_iter(). So I take this approach as I don't see any way to use a mutual exclusion waiting mechanism to block calls to blk_mq_tagset_busy_iter() while the IO scheduler is being switched. The reason is that blk_mq_tagset_busy_iter() can be called from any context, including hardirq. > Although most blk_mq_tagset_busy_iter() > callers can handle skipping certain blk_mq_tagset_busy_iter() calls > (e.g. when gathering statistics), I'm not sure this is safe for all > blk_mq_tagset_busy_iter() callers. The example I cited is an example of > a blk_mq_tagset_busy_iter() call with side effects. I don't like to think that we're skipping it, which may imply that there are some active requests to iter and we're just ignoring them. It's more like: we know that there are no requests active, so don't bother trying to iterate. > > The mtip driver allocates one tag set per request queue so quiescing > queues should be sufficient to address my concern for the mtip driver. > > The NVMe core and SCSI core however share a single tag set across > multiple namespaces / LUNs. In the error path of nvme_rdma_setup_ctrl() > I found a call to nvme_cancel_tagset(). nvme_cancel_tagset() calls > blk_mq_tagset_busy_iter(ctrl->tagset, nvme_cancel_request, ctrl). I'm > not sure it is safe to skip the nvme_cancel_request() calls if the I/O > scheduler for another NVMe namespace is being modified. Again, I would be relying on all request_queues associated with that tagset to be queisced when switching IO scheduler at the point blk_mq_tagset_busy_iter() is called and returns early. Now if there were active requests, I am relying on the request queue quiescing to flush them. So blk_mq_tagset_busy_iter() could be called during that quiescing period, and would continue to iter the requests. This does fall over if some tags are allocated without associated request queue, which I do not know exists. Thanks, John