Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp272218imp; Thu, 21 Feb 2019 00:54:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IaaysFW+3fRZy7Qb7CgxJ/jcLjIs0qgy33AZsroC1Y3jW81xpeW/h8OnNk2suEWAEEnF/z1 X-Received: by 2002:a17:902:b598:: with SMTP id a24mr24242036pls.27.1550739294785; Thu, 21 Feb 2019 00:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550739294; cv=none; d=google.com; s=arc-20160816; b=aPSh88/KCj737Mor2+kvhzU8abShMFQU3Gph1nW/y2rGQAoT9mub/WqiBHJx1Xz7WG r1TPoRQKAnjeRO7aQFTCGwU0fbV3K9jtjHj8A06oP7DiK7x3X7MJv0WI2ObLvQS4EOfW 2s0cZW5+vkcGmuYDIfXEjVr8Nc6Go1ldgEdX8dbfmf95kzwIFD7WB5KZDaf8R1nqnb1R ZxPOb1OK8UgkTMHKz6nLgDsb/wfvFhABA19+T/HoMiJImo597VQlZxMx/a+aPy816GMv Ao8udWdtE3lAxEXdjrLy3ptC5/i2Cc49z5kMLamjEkgIWTTk+GfgYir2dxPp0B6pidYR Rk4A== 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=/U4hbOv11fLuXWwREWuhN0FOL3h1dymDnenT6H/dFKw=; b=isiXPCewGytxagDc6kHzr6VRib5iL1FowZddahrbEnkJpRLRTPb0XrXXr1CqN5Rwrn Zzi5smwe8DWouii7OWdeuCKGSskSut0mCH1U5mxpUuH3djIv56oP8CNw/6++pM3iJM8k c+SgNCkdrEUquBEAAfQu9AO7kIILP/XcyRBaANJr0t2s9Rs0u9UrZ9k+zG4aPVUpToHu 6+c1tR7vGlaTdtFptFc9BYfX0wdT8YO70c3ra9o+FL3sDSkZWIpmUTgWpikxIVCz+ZuQ rG+ziuXKCiyN7Qmr8Tcij79PxgGCNLyhxcp3/q0Vn5LStYy47rJTs134zf3BarZ4JWYm bruw== 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 t70si1781540pgd.85.2019.02.21.00.54.38; Thu, 21 Feb 2019 00:54:54 -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; 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 S1727260AbfBUIyI (ORCPT + 99 others); Thu, 21 Feb 2019 03:54:08 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:4244 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726354AbfBUIyI (ORCPT ); Thu, 21 Feb 2019 03:54:08 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E324495B190FBFD9B5F5; Thu, 21 Feb 2019 16:53:58 +0800 (CST) Received: from [127.0.0.1] (10.177.96.203) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Feb 2019 16:53:56 +0800 Subject: Re: [RFC PATCH] scsi: fix oops in scsi_uninit_cmd() To: Christoph Hellwig , Bart Van Assche CC: , , Jens Axboe , , , , , , Steffen Maier References: <20190219072743.13606-1-yanaijie@huawei.com> <1550595388.31902.133.camel@acm.org> <20190220151836.GA11695@infradead.org> From: Jason Yan Message-ID: <10ea95ec-e259-3511-44c4-58e4d255eb9f@huawei.com> Date: Thu, 21 Feb 2019 16:53:54 +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: <20190220151836.GA11695@infradead.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 Hi, Christoph 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? > >> >> Thanks, >> >> Bart. > ---end quoted text--- > > . >