Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4868067img; Tue, 26 Mar 2019 19:29:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYwl2e0m3Ai0cYfwZEtH3rROxyTX92iyFp+wKUolH7IokvQQVcLrD4WTVx5Smlzxu4ebfJ X-Received: by 2002:a17:902:be18:: with SMTP id r24mr11651870pls.69.1553653769373; Tue, 26 Mar 2019 19:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553653769; cv=none; d=google.com; s=arc-20160816; b=HgXiWVAzfp9oEu2WiZQDwvwTzrtWdm9jOGSVn7Yeo/Rk9G3Ux0doBbbHgnkRQ/5viq AJbQ1LWtXyfwzMDE3ka4ZG8z3B48F2uft7an0hJQ4o1A50bYTxsVOwt1SPOYLNWEhb1Q RhUSDRY1dgLVgRrUIhi1Bmj4GOVTJMaRzckP3BOou5pRF1dAxDFImm3PJNi1vAhJICRE 8L0m2GwDD6XS1jiqT8V18BGaWhw5UMb7icl2CGD4bcrF7K+F2AGZThKGvYHN8eqvij6L cZ5A4e2OZMOuzpVIIXEAL5SZ4nF3SrZ/z8r1OouRiVpOlQUW7wKCjnLcqxS6Se03ZDji QOPw== 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=b5+RGWj+E5eK6IbAMmRbOrSnXzITWamXd/TqlrRPG6A=; b=raRZOId/QTeLlo61Ec9aB5Y6TEoG0x2SqPkui2uAKpY9v7F73vq61hWk0+oJdxfvJa IUYVKEL1qYQ0qgRUlALU832URJmsJ1WmbxlgLNva61UUa1GwlShUpjqwzUQPjTMzgCOK XE3IEmR0WGBumVP2shA4W0eAB3lqzuqSLCQqgUmOgtxlAHfzU214cvLclemZII6MzuHA Ic7laKA95wxA0oOtxfOxV+X45Yd9w/bqDiiytK9TLYMMgXyUnaF8fXdMREHk68s3u3Ky 5cG37yuyxfUhKNuFgMnClBlA7gnWlgeK058a7HVl8sYgkyipu+x9CVReJxu+EKIkblky I1jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=y35MTOzw; 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 101si18769744pld.334.2019.03.26.19.29.14; Tue, 26 Mar 2019 19:29:29 -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=y35MTOzw; 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 S1732713AbfC0C2V (ORCPT + 99 others); Tue, 26 Mar 2019 22:28:21 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42730 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731664AbfC0C2V (ORCPT ); Tue, 26 Mar 2019 22:28:21 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2R2KOw3067126; Wed, 27 Mar 2019 02:28:00 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=b5+RGWj+E5eK6IbAMmRbOrSnXzITWamXd/TqlrRPG6A=; b=y35MTOzw3YZABJsVzD40XtjIvb9jVH2cWzrACR+yBvZAPLDrcQQNMtRjP+vX2iltcLtt NqefIUqL2LcgbxRpRRWS1+lPm1XOq5Aro1XOoANbAFzwFd5nfZgl4xWN6RQNu7mzkK9h oVgStvJ1W4wY4A22mnPkJQQrPuZfSeEkF7l225FDwll8dZH5+8hV1iKZp4SkdT0Izurl bjrTa5cFBJ0P+0ghz9Y4aTMAD4kmJUBXW3gXTnNuRs+KoSXItvMGScXbhm3o2tWVjAWD v2HxEVitd3VqsYSWJPJTElHKzlbITjhBZH/Y+J6me/o7MYi0jZ/X/5t8F6Oo68ZamqbQ +Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2re6g15uvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 02:27:59 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2R2RwZG011023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 02:27:58 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2R2Rvgd026969; Wed, 27 Mar 2019 02:27:57 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:27:56 -0700 Subject: Re: [PATCH V2 7/8] nvme: use blk_mq_queue_tag_inflight_iter To: Keith Busch Cc: Jens Axboe , "Busch, Keith" , James Smart , Bart Van Assche , Ming Lei , Josef Bacik , linux-nvme , Linux Kernel Mailing List , linux-block , 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> <20190327021521.GA7389@localhost.localdomain> From: "jianchao.wang" Message-ID: <1bbe1b5c-3564-55e8-6824-f679b3c5dd3f@oracle.com> Date: Wed, 27 Mar 2019 10:27:57 +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: <20190327021521.GA7389@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-1903270015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/27/19 10:15 AM, Keith Busch wrote: > On Wed, Mar 27, 2019 at 10:03:26AM +0800, jianchao.wang wrote: >> 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. > > How is that request state going to be anyting other than IDLE? A freed > request state is IDLE, and continues to be IDLE until dispatched. But > dispatch is blocked for the entire tagset, so request states can't be > started during an nvme reset. > As the comment above, the stable request maybe something that has been freed due to following case, 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 freed request could be allocated by others which may change the field of request->state. Thanks Jianchao