Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3439707imc; Wed, 13 Mar 2019 18:58:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSS1kGjBhg0Eh3t1oao8wU21Sa8u3yWC1BRcPA1Xqq2CgpIvzP2myGMSubJixgmnHU0/O0 X-Received: by 2002:a17:902:54f:: with SMTP id 73mr49033903plf.210.1552528701327; Wed, 13 Mar 2019 18:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552528701; cv=none; d=google.com; s=arc-20160816; b=gYbTuRtTsihf/LAeoaPbbSi/k07AnS4k4TxA6s2WIkpIMJWrz5g/O3KgxoNvfQuE24 d0F3VYVj2IYBf41cES3uC3CwO4wF9PynIGMiEJTTSl+Y/P1deIB2ELSpcaQ87txAwr60 HoX0SPWNcu+DF2EznEDDKM/J/AJR6XH10plgOW0fpgCUxKty7LQLjoyc+hLQYXDPb7bi Lu+yIsY98ypm/gUAJKVN7fK9E9U/n5jOVW3RWV70fSEXZpPU6Hstb275EQZ6PVK2Jgck 3Uh2TsOZz07AoVt9whLlnSsfoRmPBn/fAB8eq02k0CzbJPwzEn3uVgPior4WNoYmVQi/ KdBg== 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; bh=zTogEPxr8KFwqIm+HWNq4t9Fxj0GFqi+46svnFq43v4=; b=WEzcCn74C0QrMgYbZ93TbtER25UnFaECUfu/ucJkvRpWcWk0/Pqq1rYTj6SoAS5Pux zUBnb2zhNIKpmmfszn4PxTJP953UjMOxmaK0AVUmv36WbGI7ni9f+pVGVbnaRV5gE45I /8gRk+g7RroA1ZDmAbG61PP50lVikyI5DyOX7lBBhUMbFPSGa78aUwN0CnZaxEkzSxNT eFDZ3OvpEg+82OCnw5o8fj8QmXNg8whvSwBP4AHG1oz5tQyXzVk5r/oHGrWaRA+fiQip AJ+iasfn+HKQoE1n13q7IHBQvcl+BPpkSVYWUaKx56Ngliccz0iGKthH5f7umUraJReN 8KCA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ct12si13404385plb.422.2019.03.13.18.58.05; Wed, 13 Mar 2019 18:58:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbfCNB52 (ORCPT + 99 others); Wed, 13 Mar 2019 21:57:28 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4679 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726141AbfCNB52 (ORCPT ); Wed, 13 Mar 2019 21:57:28 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 224F6F1C37253045D3E8; Thu, 14 Mar 2019 09:57:25 +0800 (CST) Received: from [127.0.0.1] (10.177.96.203) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Thu, 14 Mar 2019 09:57:20 +0800 Subject: Re: [RFC PATCH] scsi: fix oops in scsi_uninit_cmd() To: Bart Van Assche , Christoph Hellwig CC: , , Jens Axboe , , , , , , Steffen Maier References: <20190219072743.13606-1-yanaijie@huawei.com> <1550595388.31902.133.camel@acm.org> <20190220151836.GA11695@infradead.org> <10ea95ec-e259-3511-44c4-58e4d255eb9f@huawei.com> <1552521077.45180.119.camel@acm.org> From: Jason Yan Message-ID: <0043eef5-0be1-a86b-d438-252e4ef274af@huawei.com> Date: Thu, 14 Mar 2019 09:57:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <1552521077.45180.119.camel@acm.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.96.203] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/3/14 7:51, Bart Van Assche wrote: > On Thu, 2019-02-21 at 16:53 +0800, Jason Yan wrote: >> On 2019/2/20 23:18, Christoph Hellwig wrote: >>> [fullquote removed, please follow proper mail etiquette] >>> >>> On Tue, Feb 19, 2019 at 08:56:28AM -0800, Bart Van Assche wrote: >>>> regression in the SCSI sd driver due to the switch from the legacy block >>>> layer to scsi-mq. The above patch introduces two atomic operations in the >>>> hot path and hence would introduce a performance regression. I think this >>>> can be avoided by making sure that sd_uninit_command() gets called before >>>> the request tag is freed. What changes would be required to make the block >>>> layer core call sd_uninit_command() before the request tag is freed? Would >>>> introducing prep_rq_fn and unprep_rq_fn callbacks in struct blk_mq_ops and >>>> making sure that the SCSI core sets these callback function pointers >>>> appropriately be sufficient? Would such a change allow to simplify the NVMe >>>> initiator driver? Are there any alternatives to this approach that are more >>>> elegant? >>> >>> Additional indirect calls in the I/O fast path is something I'd rather >>> avoid. But I don't fully understand the problem yet - where do >>> we release a disk reference from blk_update_request? >> >> When userspace close the fd after blk_update_request() and before >> scsi_mq_uninit_cmd(), a disk reference will be released. It is not the >> blk_update_request() directly released it. >> >> close >> ->sd_release >> ->scsi_disk_put >> ->scsi_disk_release >> ->disk->private_data = NULL; >> >> The userspace can close the fd because blk_update_request() returned the >> last IO , the userspace application does not have to stuck on read() or >> write(). The window is very small, but it can be reproduce every day >> in our testcases. So I'm very curious why. One possible explanation is >> that we enabled kernel preempt(CONFIG_PREEMPT). >> >> And why can't we move that release to __blk_mq_end_request? > > Hi Jason, > > What is the current status of this issue? > Hi Bart, I did not find any other approach that will not affect the hot path. I don't know if you guys have other suggestions? > Thanks, > > Bart. > > . >