Received: by 10.223.176.5 with SMTP id f5csp3782065wra; Mon, 29 Jan 2018 19:42:28 -0800 (PST) X-Google-Smtp-Source: AH8x224ibi5FnS5HA+DLUbKsBQLEJR5BKQt9h1N/7hwoFCUrS0cIMfgN9RC0XXcLtlwPb8fJWskP X-Received: by 10.98.67.82 with SMTP id q79mr28484026pfa.144.1517283748423; Mon, 29 Jan 2018 19:42:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517283748; cv=none; d=google.com; s=arc-20160816; b=TxzI8oxqBi4q/rm6jeBOfiOMcSb1omNKHoJQzuF+Gc3NeoIrG/eSKzc4CaUJCSvCg5 OapcSEoKjO649doxixHwh571Ti+IzSS4Bnz8VeqfLmJzT5QXkOSpJhVH8sZIFXsJH7gj eSDMZrPsd3yofevN457eV1Rf/qHrD3w5MmPaLUUE/YnHYCNGv0/z5l1aKnz5cW9O/a6P OGZ0FSuksGSpw39cgXuO1322xUHKIVlaDNt1LtimV5M/CVAWuUYTlIDrH4Z6F6xteCi1 IhPw6Ju+xM6hQjFZXk9BA5JJI2uRMifidRmTsySBf8RhC/HjQus8hZ3b9NdXXsu/3Y+j qg/A== 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 :arc-authentication-results; bh=5YEIylqjAGkv97W1EQU21Pe2dpx0A6xOn3DwO87cGa8=; b=X13Q1Dwol8/3rUARojH9K2NtnByOb/hMH/ktOhgD0kBvwudIJWyq9qVo9WShIVpM8b pwjvesJd2z3QQ1DYJCenXbAQnz8+bbx6Ur0yGIgWsfXoZHobaqz9OqjMrtm/HnNZmCc3 O1JgCPHP8nsd2IaDq0dLOO4UcdxuHXwCyknBZrLLsjaie7vAvCYNbPmI+FXd5QjCdTll HT0307ODwEXAks0s5QyAYouoJBza5Dj+E36F6yHbyl/7K3vracbsVUio+5mo4SF4h0OV 9xbJMDxVFdoSGRO0I0wzLkLY3rP+6PHCjmj1zaxZFjJzrks3lR3V36msbETuerWjDppz XSrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=mLL37Te5; 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 p5-v6si315913plo.32.2018.01.29.19.42.14; Mon, 29 Jan 2018 19:42:28 -0800 (PST) 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-2017-10-26 header.b=mLL37Te5; 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 S1752584AbeA3Dlu (ORCPT + 99 others); Mon, 29 Jan 2018 22:41:50 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:42362 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186AbeA3Dlt (ORCPT ); Mon, 29 Jan 2018 22:41:49 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0U3bcoI004831; Tue, 30 Jan 2018 03:41:06 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-2017-10-26; bh=5YEIylqjAGkv97W1EQU21Pe2dpx0A6xOn3DwO87cGa8=; b=mLL37Te5zOTGqdYs1pWPPyne0JcHlpjAgMT4Z1JXar+WfIbM/edydo08yPbXx/s6XvJT xc/LOgpyJYrIDs//2gyN2Es97BZ2sfAPDz0VpGzbsyq7Jq73Ny3SQ1e2Hk94m6qAyRKP 1bcerDPdvyjXmercUj4E8igQVs7LfDCc5UXvuz9pQ5zB+BQf9HcahtEKD9167nIvOa/J l/LmUiwuqOlnMehxQ9+nJcXj6upjeYc2tTI/gj13sWVVgksU1pAS06RprCukimG26r+E nYFFI0q+hCdYCChOqY9m7DXlQsi6TfadJwfFLo5NJ8jfGYgE72zfzJOOGURQYCVfYlrH GA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2ftfm5g6p9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jan 2018 03:41:06 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w0U3f4oi005531 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Jan 2018 03:41:04 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w0U3f2Y4030380; Tue, 30 Jan 2018 03:41:02 GMT Received: from [10.182.70.180] (/10.182.70.180) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Jan 2018 19:41:02 -0800 Subject: Re: [PATCH] nvme-pci: use NOWAIT flag for nvme_set_host_mem To: Keith Busch , Sagi Grimberg Cc: axboe@fb.com, hch@lst.de, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <1517195255-21832-1-git-send-email-jianchao.w.wang@oracle.com> <20180129160145.GA25515@localhost.localdomain> <1b7d3700-945f-9272-b6aa-d2ebeaf0cb1e@grimberg.me> <20180129201716.GB25515@localhost.localdomain> From: "jianchao.wang" Message-ID: Date: Tue, 30 Jan 2018 11:41:07 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180129201716.GB25515@localhost.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8789 signatures=668655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=854 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801300046 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Keith and Sagi Thanks for your kindly response. :) On 01/30/2018 04:17 AM, Keith Busch wrote: > On Mon, Jan 29, 2018 at 09:55:41PM +0200, Sagi Grimberg wrote: >>> Thanks for the fix. It looks like we still have a problem, though. >>> Commands submitted with the "shutdown_lock" held need to be able to make >>> forward progress without relying on a completion, but this one could >>> block indefinitely. >> >> Can you explain to me why is the shutdown_lock needed to synchronize >> nvme_dev_disable? More concretely, how is nvme_dev_disable different >> from other places where we rely on the ctrl state to serialize stuff? >> >> The only reason I see would be to protect against completion-after-abort >> scenario but I think the block layer should protect against it (checks >> if the request timeout timer fired). > > We can probably find a way to use the state machine for this. Disabling > the controller pre-dates the state machine, and the mutex is there to > protect against two actors shutting the controller down at the same > time, like a hot removal at the same time as a timeout handling reset. > Another point that confuses me is that whether nvme_set_host_mem is necessary in nvme_dev_disable ? As the comment: ---- /* * If the controller is still alive tell it to stop using the * host memory buffer. In theory the shutdown / reset should * make sure that it doesn't access the host memoery anymore, * but I'd rather be safe than sorry.. */ if (dev->host_mem_descs) nvme_set_host_mem(dev, 0); ---- It is to avoid accessing to host memory from controller. But the host memory is just freed when nvme_remove. It looks like we just need to do this in nvme_remove. For example: ----- @@ -2553,6 +2545,14 @@ static void nvme_remove(struct pci_dev *pdev) flush_work(&dev->ctrl.reset_work); nvme_stop_ctrl(&dev->ctrl); nvme_remove_namespaces(&dev->ctrl); + /* + * If the controller is still alive tell it to stop using the + * host memory buffer. In theory the shutdown / reset should + * make sure that it doesn't access the host memoery anymore, + * but I'd rather be safe than sorry.. + */ + if (dev->host_mem_descs) + nvme_set_host_mem(dev, 0); nvme_dev_disable(dev, true); nvme_free_host_mem(dev); ---- If anything missed, please point out. That's really appreciated. Sincerely Jianchao