Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681AbdLGVHG (ORCPT ); Thu, 7 Dec 2017 16:07:06 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:59312 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752512AbdLGVHB (ORCPT ); Thu, 7 Dec 2017 16:07:01 -0500 X-IronPort-AV: E=Sophos;i="5.45,374,1508774400"; d="scan'208";a="64439981" From: Bart Van Assche To: "ming.lei@redhat.com" CC: "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "hch@infradead.org" , "martin.petersen@oracle.com" , "linux-scsi@vger.kernel.org" , "axboe@fb.com" , "hare@suse.com" , "holger@applied-asynchrony.com" , "jejb@linux.vnet.ibm.com" Subject: Re: [PATCH] SCSI: run queue if SCSI device queue isn't ready and queue is idle Thread-Topic: [PATCH] SCSI: run queue if SCSI device queue isn't ready and queue is idle Thread-Index: AQHTbZ4g7T3yQq9yCkKeO51Qk7DLeaM060uAgAAFpYCAA3J1gA== Date: Thu, 7 Dec 2017 21:06:58 +0000 Message-ID: <1512680817.2624.29.camel@wdc.com> References: <20171205075256.10319-1-ming.lei@redhat.com> <1512490099.2660.6.camel@sandisk.com> <20171205162825.GA23788@ming.t460p> In-Reply-To: <20171205162825.GA23788@ming.t460p> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1533;20:RJY0zFpe/7Fb+jp/nO6UOdS6gQqkw5njxBfeJCZIlG0x6TK1sEkpUjotkOvcX//L0vIe1oaOyGWtZtUld5aVOaGYPcmx0k90UsD2WD4abt9ZE+TZ/8rr74s8gkpu+AKeI51on7c/huRNvlKE+20zr3jP7jah78mGilQfcpUIHs4= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: da55251e-4062-4a74-ed74-08d53db6744e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603286);SRVR:CY1PR0401MB1533; x-ms-traffictypediagnostic: CY1PR0401MB1533: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(3231022)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6072148)(201708071742011);SRVR:CY1PR0401MB1533;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY1PR0401MB1533; x-forefront-prvs: 05143A8241 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(346002)(39860400002)(376002)(199004)(189003)(24454002)(52314003)(377424004)(77096006)(316002)(6916009)(6512007)(14454004)(2351001)(54906003)(105586002)(36756003)(2906002)(106356001)(478600001)(97736004)(5660300001)(5640700003)(66066001)(25786009)(6436002)(2950100002)(68736007)(6506006)(86362001)(76176011)(7416002)(6486002)(8936002)(6246003)(3846002)(72206003)(102836003)(103116003)(6116002)(53936002)(2501003)(229853002)(4326008)(81156014)(81166006)(8676002)(3280700002)(33646002)(2900100001)(101416001)(3660700001)(305945005)(7736002)(99286004);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1533;H:CY1PR0401MB1536.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: da55251e-4062-4a74-ed74-08d53db6744e X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2017 21:06:58.5902 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1533 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vB7L7AXw024178 Content-Length: 2084 Lines: 47 On Wed, 2017-12-06 at 00:28 +0800, Ming Lei wrote: > On Tue, Dec 05, 2017 at 04:08:20PM +0000, Bart Van Assche wrote: > > On Tue, 2017-12-05 at 15:52 +0800, Ming Lei wrote: > > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > > > index db9556662e27..1816dd8259b3 100644 > > > --- a/drivers/scsi/scsi_lib.c > > > +++ b/drivers/scsi/scsi_lib.c > > > @@ -1967,6 +1967,8 @@ static bool scsi_mq_get_budget(struct blk_mq_hw_ctx *hctx) > > > out_put_device: > > > put_device(&sdev->sdev_gendev); > > > out: > > > + if (atomic_read(&sdev->device_busy) == 0 && !scsi_device_blocked(sdev)) > > > + blk_mq_delay_run_hw_queue(hctx, SCSI_QUEUE_DELAY); > > > return false; > > > } > > > > This cannot work since multiple threads can call scsi_mq_get_budget() > > That is exactly the way we are handling these cases before 0df21c86bdbf(scsi: > implement .get_budget and .put_budget for blk-mq), so if it can't work, > that is not fault of commit 0df21c86bdbf. > > > concurrently and hence it can happen that none of them sees > > atomic_read(&sdev->device_busy) == 0. BTW, the above patch is something I > > If there is concurrent .get_budget(), one of them will see the counter > becoming zero finally because each sdev->device_busy is inc/dec > atomically. Or scsi_dev_queue_ready() return true. > > Anyway, we need this patch to avoid possible regression. If you think > there are bugs in blk-mq RESTART, just root cause and and fix it. Hello Ming, When I looked at the patch at the start of this thread for the first time I got frustrated because I didn't see how this patch could fix the queue stall I ran into myself. Today I started realizing that what Holger reported is probably another issue than what I ran into myself. Since this patch by itself looks now useful to me: Reviewed-by: Bart Van Assche BTW, do you think the patch at the start of this thread also fixes the issue that resulted in commit 826a70a08b12 ("SCSI: don't get target/host busy_count in scsi_mq_get_budget()")? Do you think we still need that patch? Bart.