From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751514AbeA2IO7 (ORCPT ); Mon, 29 Jan 2018 03:14:59 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:43940 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeA2IO6 (ORCPT ); Mon, 29 Jan 2018 03:14:58 -0500 Subject: Re: [PATCH] nvme-pci: use NOWAIT flag for nvme_set_host_mem To: keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org References: <1517195255-21832-1-git-send-email-jianchao.w.wang@oracle.com> From: "jianchao.wang" Message-ID: <40b52195-95c8-4c33-39cc-dc80043161a2@oracle.com> Date: Mon, 29 Jan 2018 16:06:13 +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: <1517195255-21832-1-git-send-email-jianchao.w.wang@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8788 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801290113 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/29/2018 11:07 AM, Jianchao Wang wrote: > nvme_set_host_mem will invoke nvme_alloc_request without NOWAIT > flag, it is unsafe for nvme_dev_disable. The adminq driver tags > may have been used up when the previous outstanding adminq requests > cannot be completed due to some hardware error. We have to depend > on the timeout path to complete the previous outstanding adminq > requests and free the tags. > However, nvme_timeout will invoke nvme_dev_disable and try to > get the shutdown_lock which is held by another context who is > sleeping to wait for the tags to be freed by timeout path. A > deadlock comes up. > > To fix it, let nvme_set_host_mem use NOWAIT flag. In fact, this is the only case about nvme_set_host_mem in nvme_dev_disable. Consider the following case: A adminq request expired. timeout_work context nvme_timeout -> nvme_dev_disable -> nvme_set_host_mem if this adminq request expires again, the timeout_work cannot handle this case, because it is waiting for the result of nvme_set_host_mem. Thanks Jianchao