Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4854790img; Tue, 26 Mar 2019 19:06:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8D5twrxyNNK1ctL+QD7hx+ei5IyXCLIQPgMWYtK7CV4af6ck3/mWj5igYPjePXjDXe/X+ X-Received: by 2002:aa7:8ad4:: with SMTP id b20mr25864018pfd.249.1553652387374; Tue, 26 Mar 2019 19:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553652387; cv=none; d=google.com; s=arc-20160816; b=G8NkbcFSMaIqyJ83NjsVI/9aVd3sP0i1MsI5HSQNM6BNgVOfiz4heDE59tMrgT6wsh RUfvhh5g+4YVrFsW2GuAFGGxNNEvNvSGaAE3Um7zywYa7kiqwQxLJkBjE6KqmhKPpG79 bOywXMKITrjLijzo+lnn6WJWw6pIdEJBJSuCHOAnEvxwXmWTRHgj7W8C8JYG6aM5FVIv 2Fl6FdX1Lo45NShAojd34K24FdCqIok5cE9f4dzbSK+4EiSrYRoEXr+k711ORnd9cxNo j0EQ07L8ff9NNVDfe8XZ1zfC3Qi3WCR7VzqvGyihHA0NTBeOLu/ERzpnBAinQPz85cae oqZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=FGX4+B3Cf8XdJre/h3nKtNd2FVnzk4g8uz+ICXCesgs=; b=FuMqS3EeIinHoDuZghtqgQ8UD/TafxmkRjBDx9P7AFVLZTO27KaiCZ5Qey0R6MuTm1 zt3wGxCbpx5cz/eBCmyPIgekSKI2uN4wU/sP8ClDEBIxrZ/HAtlG+1RiCBBzs9cwnphr cSuq3kvrM/48BmVEb0b8xNL+oCDMtYgwJVteoJMVMpWnhYxwnCBIhacrEKdMUQdA3Mms GK/03lXF59Zx4KbfNoZmI69v6Nd2cANvtUxghhnW83CoOK1E1xskV7YeeknzSNa4Zw+W X9S0NNJOhiDltaBRi4i5usGHi8H6vRY+oG11dyIEsFzRtKXUe9MHFgRdMXOnVQlFW14T mWRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=s5NnGnn1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3si17582370plt.68.2019.03.26.19.06.10; Tue, 26 Mar 2019 19:06:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=s5NnGnn1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731701AbfC0CEI (ORCPT + 99 others); Tue, 26 Mar 2019 22:04:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35204 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727488AbfC0CEI (ORCPT ); Tue, 26 Mar 2019 22:04:08 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2R23YEf065342; Wed, 27 Mar 2019 02:03:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=FGX4+B3Cf8XdJre/h3nKtNd2FVnzk4g8uz+ICXCesgs=; b=s5NnGnn1tXnI9hahPM70kgmdVdnwILxWuwmSYoZie4ZvBPMWVWP6l668Sol5D/fAPd02 Z9crOltgP1nLPPPuSp0ZvQZqA9wDspkQaeh0ifQ3ygHjTH8Kel2MzTo7ndRr5rZYIRgP 6f2ls04lVMwGfIwqdMjAr0KOXFqHD72BHD4F+zQlv3ptdTwodXiqavMfCdqyvPrvEcNn rhRTZXAHHmiy3UEj5MO1G7TNsbG+XXsRNz6sWLqwSBbFq0KvSB6Jo4QVeTWB4zvAkFNS s22pGyhVXVMeteb9MA5XdH5yLzsOMj0vB/l7T/DYhLi0zrD9JfVopNm2PVKuqPRyqfPf 4w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2re6djdw22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 02:03:34 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2R23WS8022870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 02:03:33 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2R23Q9r024593; Wed, 27 Mar 2019 02:03:26 GMT Received: from [10.182.71.8] (/10.182.71.8) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Mar 2019 19:03:26 -0700 Subject: Re: [PATCH V2 7/8] nvme: use blk_mq_queue_tag_inflight_iter To: Keith Busch Cc: Jens Axboe , linux-block , James Smart , Bart Van Assche , Ming Lei , Josef Bacik , linux-nvme , Linux Kernel Mailing List , "Busch, Keith" , Hannes Reinecke , Johannes Thumshirn , Christoph Hellwig , Sagi Grimberg References: <1553492318-1810-1-git-send-email-jianchao.w.wang@oracle.com> <1553492318-1810-8-git-send-email-jianchao.w.wang@oracle.com> <20190325134917.GA4328@localhost.localdomain> <70e14e12-2ffc-37db-dd8f-229bc580546e@oracle.com> <20190326235726.GC4328@localhost.localdomain> From: "jianchao.wang" Message-ID: Date: Wed, 27 Mar 2019 10:03:26 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190326235726.GC4328@localhost.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9207 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903270013 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Keith On 3/27/19 7:57 AM, Keith Busch wrote: > On Mon, Mar 25, 2019 at 08:05:53PM -0700, jianchao.wang wrote: >> What if there used to be a io scheduler and leave some stale requests of sched tags ? >> Or the nr_hw_queues was decreased and leave the hctx->fq->flush_rq ? > > Requests internally queued in scheduler or block layer are not eligible > for the nvme driver's iterator callback. We only use it to reclaim > dispatched requests that the target can't return, which only applies to > requests that must have a valid rq->tag value from hctx->tags. > >> The stable request could be some tings freed and used >> by others and the state field happen to be overwritten to non-zero... > > I am not sure I follow what this means. At least for nvme, every queue > sharing the same tagset is quiesced and frozen, there should be no > request state in flux at the time we iterate. > In nvme_dev_disable, when we try to reclaim the in-flight requests with blk_mq_tagset_busy_iter, the request_queues are quiesced but just start-freeze. We will try to _drain_ the in-flight requests for the _shutdown_ case when controller is not dead. For the reset case, there still could be someone escapes the checking of queue freezing and enters blk_mq_make_request and tries to allocate tag, then we may get, generic_make_request nvme_dev_disable -> blk_queue_enter -> nvme_start_freeze (just start freeze, no drain) -> nvme_stop_queues -> blk_mq_make_request - > blk_mq_get_request -> blk_mq_tagset_busy_iter -> blk_mq_get_tag    -> bt_tags_for_each     -> bt_tags_iter    -> rq = tags->rqs[] ---> [1] -> blk_mq_rq_ctx_init -> data->hctx->tags->rqs[rq->tag] = rq; The rq got on position [1] could be a stale request that has been freed due to, 1. a hctx->fq.flush_rq of dead request_queue that shares the same tagset 2. a removed io scheduler's sched request And this stale request may have been used by others and the request->state is changed to a non-zero value and passes the checking of blk_mq_request_started and then it will be handled by nvme_cancel_request. Thanks Jianchao