From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753390AbdJMXnv (ORCPT ); Fri, 13 Oct 2017 19:43:51 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:38193 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753276AbdJMXnt (ORCPT ); Fri, 13 Oct 2017 19:43:49 -0400 X-IronPort-AV: E=Sophos;i="5.43,373,1503331200"; d="scan'208";a="153994015" From: Bart Van Assche To: "hch@infradead.org" , "linux-block@vger.kernel.org" , "axboe@fb.com" , "ming.lei@redhat.com" CC: "linux-kernel@vger.kernel.org" , "tom81094@gmail.com" , "paolo.valente@linaro.org" , Bart Van Assche , "linux-scsi@vger.kernel.org" , "oleksandr@natalenko.name" , "john.garry@huawei.com" , "osandov@fb.com" , "loberman@redhat.com" Subject: Re: [PATCH V9 4/7] blk-mq: introduce .get_budget and .put_budget in blk_mq_ops Thread-Topic: [PATCH V9 4/7] blk-mq: introduce .get_budget and .put_budget in blk_mq_ops Thread-Index: AQHTRE4U11nn+FzAMkW4+t0s7B03IaLicZiA Date: Fri, 13 Oct 2017 23:43:44 +0000 Message-ID: <1507938223.13345.66.camel@wdc.com> References: <20171013180532.29304-1-ming.lei@redhat.com> <20171013180532.29304-5-ming.lei@redhat.com> In-Reply-To: <20171013180532.29304-5-ming.lei@redhat.com> 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: [63.163.107.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1536;20:MFyzysflmDzYrBXLqog75HyCwIpbSmlhMfFUQGJf0Fcm8v7WYBYJGE2jHSEFgcotnjBgMCK2K4RaFwLkE6KODzViVfs3WGag4o8vGJee/zAMnfmXgSK0np+vvUU4oOeZP2zI/FI2bMgWEjx9zLqJmFL8u1h1RgP67foh6CWdQek= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 7d275d04-38ce-4d8d-85a7-08d512943e05 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:CY1PR0401MB1536; x-ms-traffictypediagnostic: CY1PR0401MB1536: wdcipoutbound: EOP-TRUE x-exchange-antispam-report-test: UriScan:(17755550239193); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(20161123558100)(20161123562025)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR0401MB1536;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR0401MB1536; x-forefront-prvs: 04599F3534 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(346002)(199003)(51444003)(24454002)(377424004)(189002)(305945005)(8676002)(7736002)(316002)(54356999)(3280700002)(54906003)(72206003)(103116003)(478600001)(53936002)(86362001)(101416001)(99286003)(14454004)(2906002)(2501003)(66066001)(6512007)(25786009)(3660700001)(189998001)(6436002)(8936002)(68736007)(2201001)(110136005)(105586002)(7416002)(50986999)(33646002)(4326008)(39060400002)(2950100002)(36756003)(6506006)(5660300001)(3846002)(6486002)(81156014)(106356001)(102836003)(97736004)(76176999)(6246003)(2900100001)(77096006)(229853002)(4001150100001)(6116002)(81166006)(142923001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1536;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: <456E36D9432ABA41ACD454825453806B@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Oct 2017 23:43:44.5614 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1536 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 v9DNi0tB010578 On Sat, 2017-10-14 at 02:05 +0800, Ming Lei wrote: > @@ -89,19 +89,36 @@ static bool blk_mq_sched_restart_hctx(struct blk_mq_hw_ctx *hctx) > return false; > } > > -static void blk_mq_do_dispatch_sched(struct blk_mq_hw_ctx *hctx) > +static bool blk_mq_do_dispatch_sched(struct blk_mq_hw_ctx *hctx) Shouldn't the meaning of the return value of this function be documented? > { > struct request_queue *q = hctx->queue; > struct elevator_queue *e = q->elevator; > LIST_HEAD(rq_list); > > do { > - struct request *rq = e->type->ops.mq.dispatch_request(hctx); > + struct request *rq; > + blk_status_t ret; > > - if (!rq) > + if (e->type->ops.mq.has_work && > + !e->type->ops.mq.has_work(hctx)) > break; > + > + ret = blk_mq_get_dispatch_budget(hctx); > + if (ret == BLK_STS_RESOURCE) > + return true; > + > + rq = e->type->ops.mq.dispatch_request(hctx); > + if (!rq) { > + blk_mq_put_dispatch_budget(hctx, true); > + break; > + } else if (ret != BLK_STS_OK) { > + blk_mq_end_request(rq, ret); > + continue; > + } > list_add(&rq->queuelist, &rq_list); > - } while (blk_mq_dispatch_rq_list(q, &rq_list)); > + } while (blk_mq_dispatch_rq_list(q, &rq_list, true)); > + > + return false; > } This means that the request in rq_list becomes the owner of the budget allocated by blk_mq_get_dispatch_budget(). Shouldn't that be mentioned as a comment above blk_mq_dispatch_rq_list()? > + if (run_queue) { > + if (!blk_mq_sched_needs_restart(hctx) && > + !test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state)) { > + blk_mq_sched_mark_restart_hctx(hctx); > + blk_mq_run_hw_queue(hctx, true); > + } > } > } The above if-statement can be changed from a nested if into a single if-statement. Additionally, why has the code been added to blk_mq_sched_dispatch_requests() that reruns the queue if blk_mq_get_dispatch_budget() returned BLK_STS_RESOURCE? Is that code necessary or can it be left out? > +static inline void blk_mq_put_dispatch_budget(struct blk_mq_hw_ctx *hctx, > + bool got_budget) > +{ > + struct request_queue *q = hctx->queue; > + > + if (q->mq_ops->put_budget && got_budget) > + q->mq_ops->put_budget(hctx); > +} So the above function is passed a boolean as second argument and all what that boolean is used for is to decide whether or not the function is executed? Sorry but I think that's wrong and that the second argument should be removed and that it should be evaluated by the caller instead of inside blk_mq_put_dispatch_budget(). Bart.