Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4513050pxf; Tue, 16 Mar 2021 15:55:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFn06WCnu1t7sFKS+xxK/Ku+B2ZzE9Kmc1QT3oJanfyCwMz9/FXxE/KuXToYbQZUFV1lHZ X-Received: by 2002:a17:906:ecf3:: with SMTP id qt19mr31677539ejb.467.1615935312343; Tue, 16 Mar 2021 15:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615935312; cv=none; d=google.com; s=arc-20160816; b=dzeeOMWhmAKnjSfPy+UrSD2jxZY9IZzPpMX5cJdhrOrA9f0BqHEsOszrlqFzUFA1B1 o1CveUNaaFQ1g/xNoqF3vdXwdw1rrpp1tM+YF6iQWvnuH6wHG0Qc6L7vb0CQV2IAnqG2 lud+G4TcnflvF4XquhkWW4fgci1I5mQPZtlOTssmsIwDwb5wx9nElHM7vGVe89O+/juB UxttLeKx+i/sxmw9c7x4WbzmW2A+VrWBfTNdMkeUJ5RMh6h1VOk/BNDl3Eqvh/DwBog5 nDNea+mYWwWtSmWUDXVsjaRs/DdwevNkExCEw0YB5b8MSlfV07CdSQgospknJzZRizeI T/rw== 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=1/24ccYeQroML1XCTeit6sz8qKotGcfPrIbFhJAAO4Q=; b=lorqt5Hi3Xu2Y8B8iZxdUoHERrE6AjpkUyg0wK9WQ3JdMy7asNYpJ61ZRT5L2bGYKs GkEa9aN+NppJHWd2/7XsmV2/0fot5cuKkBctUaZIUfnc/yKBaAkNXKSFemMg14jRzDRQ H8+dfk7XwQPMyvHsN8lqaioeLkgZ+CoGuT/0Ly149x3574OPUFeNFAeox9v6yxEJAqN5 rEJ7A9dacgQxS9t6P4kHmBJe0e4QneaBBjULiSVF7Jl3Udzx6hTPl0Yw32LAlprqSVA9 KBp/oxBRlBtRF2tl5g6yN/JgACIyB6gHImDDAuVgHvvtRMPPWKwcgIOQA01g5AxUak53 N59g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si14457130eje.309.2021.03.16.15.54.49; Tue, 16 Mar 2021 15:55:12 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239042AbhCPRqS (ORCPT + 99 others); Tue, 16 Mar 2021 13:46:18 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2705 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239017AbhCPRpt (ORCPT ); Tue, 16 Mar 2021 13:45:49 -0400 Received: from fraeml736-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4F0LBt3QFQz67yt6; Wed, 17 Mar 2021 01:39:34 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml736-chm.china.huawei.com (10.206.15.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 16 Mar 2021 18:45:46 +0100 Received: from [10.210.172.72] (10.210.172.72) 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, 16 Mar 2021 17:45:45 +0000 Subject: Re: [RFC PATCH v3 2/3] blk-mq: Freeze and quiesce all queues for tagset in elevator_exit() To: Bart Van Assche , Ming Lei CC: "hare@suse.de" , "axboe@kernel.dk" , "hch@lst.de" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "pragalla@codeaurora.org" , "kashyap.desai@broadcom.com" , yuyufen References: <1614957294-188540-1-git-send-email-john.garry@huawei.com> <1614957294-188540-3-git-send-email-john.garry@huawei.com> <8c6c6783-6152-2332-2f50-14c409e40320@huawei.com> <2b0c66ba-03b3-844c-1684-f8e80d11cdbb@acm.org> <4ffaba53-100a-43a5-8746-b753d4153be5@huawei.com> From: John Garry Message-ID: <82526e78-66e5-fc3c-7acd-38f1813ebe1e@huawei.com> Date: Tue, 16 Mar 2021 17:43:37 +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: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.210.172.72] X-ClientProxiedBy: lhreml714-chm.china.huawei.com (10.201.108.65) 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 16/03/2021 17:00, Bart Van Assche wrote: > On 3/16/21 9:15 AM, John Garry wrote: >> I'll have a look at this ASAP -  a bit busy. >> >> But a quick scan and I notice this: >> >>  > @@ -226,6 +226,7 @@ static inline void >> __blk_mq_put_driver_tag(struct blk_mq_hw_ctx *hctx, >>  >                          struct request *rq) >>  >   { >>  >       blk_mq_put_tag(hctx->tags, rq->mq_ctx, rq->tag); >>  > +    rcu_assign_pointer(hctx->tags->rqs[rq->tag], NULL); >> >> Wasn't a requirement to not touch the fastpath at all, including even >> if only NULLifying a pointer? >> >> IIRC, Kashyap some time ago had a patch like above (but without RCU >> usage), but the request from Jens was to not touch the fastpath. >> >> Maybe I'm mistaken - I will try to dig up the thread. > Hi Bart, > > I agree that Jens asked at the end of 2018 not to touch the fast path to > fix this use-after-free (maybe that request has been repeated more > recently). If Jens or anyone else feels strongly about not clearing > hctx->tags->rqs[rq->tag] from the fast path then I will make that > change. Is that possible for this same approach? I need to check the code more.. And don't we still have the problem that some iter callbacks may sleep/block, which is not allowed in an RCU read-side critical section? > My motivation for clearing these pointers from the fast path is > as follows: > - This results in code that is easier to read and easier to maintain. > - Every modern CPU pipelines store instructions so the performance > impact of adding an additional store should be small. > - Since the block layer has a tendency to reuse tags that have been > freed recently, it is likely that hctx->tags->rqs[rq->tag] will be used > for a next request and hence that it will have to be loaded into the CPU > cache anyway. > Those points make sense to me, but obviously it's the maintainers call. Thanks, john