Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753471AbdLNVNl (ORCPT ); Thu, 14 Dec 2017 16:13:41 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:10155 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752377AbdLNVNi (ORCPT ); Thu, 14 Dec 2017 16:13:38 -0500 X-IronPort-AV: E=Sophos;i="5.45,401,1508774400"; d="scan'208";a="64891709" From: Bart Van Assche To: "tj@kernel.org" CC: "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "linux-block@vger.kernel.org" , "kernel-team@fb.com" , "oleg@redhat.com" , "hch@lst.de" , "axboe@kernel.dk" , "jianchao.w.wang@oracle.com" , "osandov@fb.com" Subject: Re: [PATCH 2/6] blk-mq: replace timeout synchronization with a RCU and generation based scheme Thread-Topic: [PATCH 2/6] blk-mq: replace timeout synchronization with a RCU and generation based scheme Thread-Index: AQHTc3vSEJieVXIS9EOPhdZv8hd1dKNDMgqAgAAH8oCAAB/UAA== Date: Thu, 14 Dec 2017 21:13:32 +0000 Message-ID: <1513286010.2475.58.camel@wdc.com> References: <20171212190134.535941-1-tj@kernel.org> <20171212190134.535941-3-tj@kernel.org> <1513277469.2475.43.camel@wdc.com> <20171214191935.GB3919388@devbig577.frc2.facebook.com> In-Reply-To: <20171214191935.GB3919388@devbig577.frc2.facebook.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY1PR0401MB1530;20:1dJN02goCnG1qvhwQPwUD5w+EAdDIZ11zshw6Spqd2pOkKn5HaddQOlMUVr0MIoe5a1FcCwiRR3aQy/0cDh0EREjz3KDA3Mpu5amV/SrXrG2mXYjRSlWqpBSA6Gc0vGBH5O2EnA76IRHFvye2PwGKXdNWPsTPOKwt4OdcXKMjJg= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: faca3f40-4e71-4589-52f2-08d5433787ff x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7153051);SRVR:BY1PR0401MB1530; x-ms-traffictypediagnostic: BY1PR0401MB1530: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231023)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123560025)(6072148)(201708071742011);SRVR:BY1PR0401MB1530;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BY1PR0401MB1530; x-forefront-prvs: 05214FD68E x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(366004)(396003)(39860400002)(376002)(377424004)(24454002)(199004)(189003)(53936002)(478600001)(14454004)(54906003)(72206003)(2351001)(2900100001)(86362001)(3660700001)(6246003)(3280700002)(105586002)(106356001)(316002)(93886005)(5250100002)(25786009)(103116003)(99286004)(6512007)(97736004)(7416002)(66066001)(1730700003)(8676002)(5660300001)(81156014)(81166006)(36756003)(4001150100001)(7736002)(59450400001)(229853002)(5640700003)(6916009)(76176011)(6436002)(6486002)(6506007)(305945005)(102836003)(68736007)(6116002)(2501003)(3846002)(8936002)(4326008)(2906002)(2950100002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0401MB1530;H:BY1PR0401MB1532.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: faca3f40-4e71-4589-52f2-08d5433787ff X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2017 21:13:32.5306 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0401MB1530 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 vBELDkXF001302 Content-Length: 1850 Lines: 37 On Thu, 2017-12-14 at 11:19 -0800, tj@kernel.org wrote: > On Thu, Dec 14, 2017 at 06:51:11PM +0000, Bart Van Assche wrote: > > On Tue, 2017-12-12 at 11:01 -0800, Tejun Heo wrote: > > > --- a/block/blk-core.c > > > +++ b/block/blk-core.c > > > @@ -126,6 +126,8 @@ void blk_rq_init(struct request_queue *q, struct request *rq) > > > rq->start_time = jiffies; > > > set_start_time_ns(rq); > > > rq->part = NULL; > > > + seqcount_init(&rq->gstate_seq); > > > + u64_stats_init(&rq->aborted_gstate_sync); > > > } > > > EXPORT_SYMBOL(blk_rq_init); > > > > Sorry but the above change looks ugly to me. My understanding is that > > blk_rq_init() is only used inside the block layer to initialize legacy block > > layer requests while gstate_seq and aborted_gstate_sync are only relevant > > for blk-mq requests. Wouldn't it be better to avoid that blk_rq_init() is > > called for blk-mq requests such that the above change can be left out? The > > only callers outside the block layer core of blk_rq_init() I know of are > > ide_prep_sense() and scsi_ioctl_reset(). I can help with converting the SCSI > > code if you want. > > This is also used by flush path. We probably should clean that up, > but let's worry about that later cuz flush handling has enough of its > own complications. We may have a different opinion about this but I think it is more than a detail. This patch needs gstate_seq and aborted_gstate_sync to be preserved across request state transitions from MQ_RQ_IN_FLIGHT to MR_RQ_IDLE. blk_mq_init_request() is called at request allocation time so it's the right context to initialize gstate_seq and aborted_gstate_sync. blk_rq_init() however is called before a every use of a request. Sorry but I'm not enthusiast about the code in blk_rq_init() that reinitializes state information that should survive request reuse. Bart.