Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934207AbcLMPPK (ORCPT ); Tue, 13 Dec 2016 10:15:10 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:37492 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934010AbcLMPPD (ORCPT ); Tue, 13 Dec 2016 10:15:03 -0500 Subject: Re: [PATCH 5/7] blk-mq-sched: add framework for MQ capable IO schedulers To: Bart Van Assche , , , References: <1481228005-9245-1-git-send-email-axboe@fb.com> <1481228005-9245-6-git-send-email-axboe@fb.com> <69c1261a-1a21-7347-c753-0bcb9a2ab65e@sandisk.com> CC: , From: Jens Axboe Message-ID: Date: Tue, 13 Dec 2016 08:14:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <69c1261a-1a21-7347-c753-0bcb9a2ab65e@sandisk.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [216.160.245.98] X-ClientProxiedBy: BY2PR02CA0004.namprd02.prod.outlook.com (10.163.44.142) To MWHPR15MB1197.namprd15.prod.outlook.com (10.175.2.139) X-MS-Office365-Filtering-Correlation-Id: 29be2dcc-b72a-4d12-a848-08d4236ac890 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR15MB1197; X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1197;3:Orq41x8rU6H/5fIsZHlFWxYxhRrjuDMJ9QN9pxiP8g1s6lTPuOc35NlPpbbbENp/yFb7g9Wdms8qKcKFdOzGHTQurWgfq89Bf2ZW8lKdGOYpVKjLrR+QnYIXr+vvxIioYCVQ1MZj4GnEAO8CNwBdcnSMy0eTP0NE75KFW9J2ElLF5WC1jRj9USOiwPhJXMWtwBQjsBTuNLStNHuJt0E3mt+cSmGbmF5R5zYcp6NOqGL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uTadHMk8q4lYBDZSMD6jFSQxHVMTlZyDg1NEjiPg55DOaFBxOjOC5kwaK155WATCPjvhCN/mvwewqfwLCXrXbe3Q==;20:+EJpIEHcpsCZzcYoMcAZXJMJp+s7932KGq/en35QiKTwWb500iteLhaWrcuOIxPsLlhPEYqe+QqqM/ABL1XeY0nRYmLsWWPuBhbKsbZ3LKQ3rjealwMvp91oOUn/FQGPm191oFRG2hg9G4fMNteWPA2JPxpx128u352manvy8kfI3IYY6uXPbk+911NjXgkPxwAg0+RrcUimI2weZBJ0laNqKjcI+HcJzQLbdvR3rmSf3G4NXQRxLX2CUOykQ2LTSvXltfnZg/6UcqW4h4XoMWrbOnIssRufY4mQvbDd9SC1qn1zreJMbk1m3VBu6cccruB5/cGfrvphPzw7sQzLdbVmgI+t9TttJCzNDGHWwJCSKv1wgHY8JDDO2kL63Qc0/nXDPsdndikUU9ZuwrMCK2qKhaa0rhsyUekgwy3GC0PcQpHEOTOQ8MFJIJyd+mwtMyCFAZ6v+X2CNvyAoHXcYj83oL4ofCacgnL/0C2kr+UNpFyGb1JnJKoTmTkzppdv X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148);SRVR:MWHPR15MB1197;BCL:0;PCL:0;RULEID:;SRVR:MWHPR15MB1197; X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1197;4:QvvQdfYZT5So2BCQz4avx6xmPiRUDIrv9DOU4gKJRhNCLB6z3OvA3E7xya+lYo97/bLEAgNDS3ej8jAeC1yWmCpBPIy/YXWawSYV3fxCZw3mwLUxRNVheZICVJoOgrixd230C/NnLR24C494+0uB5f6GzRao38gWVtUuk/NDglS8pc8YXka7W3G/98+Fld5D2oadJeZ5C9yWIX+ZGS3iyG5Ffp0bqdswvKSD1/xRK3DddPkUVy1GWV0ZU1rngBJjG2Tg9QIFxIeRn6MjPll8PmHn3PKJuKSvR9eWUJfwkW35cQIuxM6RWHlpgAcEapmaF6nMGx+qRza7WDQpcTXV7csTinWntycfbjMQ4YLeb6etCe24YHdwCnXnAYNphdu8V9NUX7LMbsC9cq2c6O/BK//q4UyFE+s8M7JUe9xSWgEHzRvHcn0mL4cGwf02jtLljS9GztpKCRjJQGQz3okwuUXdpCxoIv6swjijQsQEA1E9NzPTP9Pv/IgZ2pdD58B0awR8lfQFB149KFcwjd0PE17tNXGWv2LSNzR/uOZn4+1tROkqt2fxChBkC4xBSDQ40ow7pEwcN3B9y7IgApektA== X-Forefront-PRVS: 01559F388D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(39850400002)(39410400002)(39860400002)(39840400002)(39450400003)(189002)(199003)(52314003)(377454003)(24454002)(65956001)(65806001)(81166006)(8666005)(66066001)(31686004)(230783001)(8676002)(305945005)(81156014)(5660300001)(83506001)(6116002)(3846002)(101416001)(42186005)(7736002)(6666003)(50466002)(68736007)(105586002)(2950100002)(2906002)(4326007)(65826007)(92566002)(47776003)(106356001)(64126003)(117156001)(230700001)(54356999)(33646002)(50986999)(38730400001)(31696002)(36756003)(2201001)(97736004)(1691005)(90366009)(23746002)(5001770100001)(86362001)(77096006)(6486002)(229853002)(76176999)(4001350100001)(189998001)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1197;H:[192.168.1.129];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;MWHPR15MB1197;23:ovEInYpPnpWVOnbDMMfXHoK/FebdrXAwOEfBo?= =?Windows-1252?Q?c8b+NLNwK0JmUVWKcVD4rgY3GEN/1hD9NMd7YXff8MvVJR+Hj9luZBmH?= =?Windows-1252?Q?pGZiw+kris+8HnjDoNXGXTSwRUKLUA8Leqyp3GU+aLlguMdJPMUolmpp?= =?Windows-1252?Q?nFo5Lw/S7967YNEFe+TAMOzN0irZFrcpULr95+3yYeqoMxEHn34NHREO?= =?Windows-1252?Q?rCWhoMLhbXq078PXB2jc4BsZJYZxVHBobmQNT8A/3WYwCWeNbgsuDscg?= =?Windows-1252?Q?BrWcpaIzcriAC+UW0Ge3G0aWEGPkwr1b7DR6xBH5c0pQFciCJAFDtETu?= =?Windows-1252?Q?b7OsFtySPC8AQOdE5cNhhD1rpq+uDSYIU7M/aieqMmi7JuP738hcxUqi?= =?Windows-1252?Q?lrJsdz8eRrCk1BHqqnPRqpbvrj8wCdaQUiMhCWqVIQjAEdc0YiqkyWwR?= =?Windows-1252?Q?duj0YITDx9aNoHCkhLGqLnNGxZgjPGzCI0zOgTKqs87mb+idHPZFokzs?= =?Windows-1252?Q?eRjnI/ymzTHrsQrHikC4a6R4Qp6Pxam3Fn5yQnWE/lmVzmTV0ZWzOT8S?= =?Windows-1252?Q?PhLB7BcLaPWmXuZVpJsMj2Nzg8v2uwhQ3zSX5VYPKcOUfq3xd76807Jo?= =?Windows-1252?Q?ALWnc0SSarPvICSRbPSa+r4325RKQsjNVcJ2aGoxifftIfFjHDSiVdF7?= =?Windows-1252?Q?4oKMbXCGjtH7W1elT5lAhzGw9BZHVTBgeYBisH4PJyu4GiEAZ4gS7FBJ?= =?Windows-1252?Q?r2CC2WIapuZsQeGPRg9BvlfGJ4TpT4CCA/tuqd2HvGgF7kT/raVSWbI7?= =?Windows-1252?Q?09odqKUdqEZMqhmVRisQ5GJSTYIJpMUrlBx7qUc7rJiSCW3VD8gB7pc1?= =?Windows-1252?Q?oQGxht+uZsHW++VvOgKZC2IoPCr9o2/bgughZ7QesnMC7wsbw7SQU/xY?= =?Windows-1252?Q?Y2lNddrbThy/agYXNMBZBbyCxYlUz4dQtrTB2yuXzXT/Z7sqF1Oz7F6R?= =?Windows-1252?Q?PXpOr+4VNNt4BXYmO7MtCYvAk0cggrUGGli7Hd/OAoY9ytAiAvz3uoDG?= =?Windows-1252?Q?iX1T2vcM/yGsspoz9L0z6SC08ENCcS/URBpWB/WXp0D3qPBMCPlZ5IJS?= =?Windows-1252?Q?yILp230UMndlMsYv3co7mo28n9a6Z9egKx5+dPETUVjCkT0vvmrU4rUW?= =?Windows-1252?Q?S8UcBolXO1gpHp64U/s4i10bmkcJd9fBiA7vBDH4eM+etOJ8TuG64gQ/?= =?Windows-1252?Q?INpVeY2qE22Y9WaiBcYcML0R1mtJxb6iKSp3rA0/R7mV4dLb/P8+TYS2?= =?Windows-1252?Q?UcMznYGndtQZDYlsbYoTJAHLysIUCDt1S6A4ykqr8v0Y7tTlQ3mUnTIF?= =?Windows-1252?Q?/TZriui4BWZA25ricQGfE/4rNc4aNaPS/V4xXLn3oW3I1ffFCQa+O8rX?= =?Windows-1252?Q?LK4DqoWEgSbyB3NgtaNsSDehrkhl68RGcXlLTOeXo6C0xaY+MsWedbGO?= =?Windows-1252?Q?eQka1+Abp6h1Bz+r7QpRHIFBmSpO3eLGSG3gZm6681MViXwqACAp7MKV?= =?Windows-1252?Q?qUMqQ619/zFBwAWufTWLOMcN5ttRTRXJFhRAyUniR1avDsKGg60qZDDD?= =?Windows-1252?Q?pzkxjXDyCxu8HtjGfa5YOk+nn8dq+kIE2TGjnEuerxwtFaGk1Zc5HLsz?= =?Windows-1252?Q?xoAupwM+A=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1197;6:SM2r07N4R1fQG5IuwCWOCp7vo2/J3QU8O58bnd2fvzfy9lD6o416NxRpv5p6zo1g/DP0TozGcAt5bRRYIaKti+24T64pNr7in+7vYOUwwPjximzhQmhLu8203O8RplSqH5VCZ6qcFXfo8E4vZ4P7pI7owmn1mm/P71r8ty8IlzesTKNs7vjDuWtBLCXcLsfv1XBZdZFR1nqoLLYnYfPMPmoJagg87N7v6671M2aFJxc192gbDNQfqkQ7ty2rHT1RVxnCSXNAs5IL846TVjI5tMfXUMh7hl0tD72hDNjMp2a/Ik3jadXFWO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/eKt/yfuS/ILBQjRvyuBFEdhzMiE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2016 15:14:50.0027 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1197 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-12-13_11:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3223 Lines: 87 On 12/13/2016 06:56 AM, Bart Van Assche wrote: > On 12/08/2016 09:13 PM, Jens Axboe wrote: >> +/* >> + * Empty set >> + */ >> +static struct blk_mq_ops mq_sched_tag_ops = { >> + .queue_rq = NULL, >> +}; > > Hello Jens, > > Would "static struct blk_mq_ops mq_sched_tag_ops;" have been sufficient? > Can this data structure be declared 'const' if the blk_mq_ops pointers > in struct blk_mq_tag_set and struct request_queue are also declared const? Yes, the static should be enough to ensure that it's all zeroes. I did have this as const, but then realized I'd have to change a few other places too. I'll make that change, hopefully it'll just work out. >> +struct request *blk_mq_sched_alloc_shadow_request(struct request_queue *q, >> + struct blk_mq_alloc_data *data, >> + struct blk_mq_tags *tags, >> + atomic_t *wait_index) >> +{ > > Using the word "shadow" in the function name suggests to me that there > is a shadow request for every request and a request for every shadow > request. However, my understanding from the code is that there can be > requests without shadow requests (for e.g. a flush) and shadow requests > without requests. Shouldn't the name of this function reflect that, e.g. > by using "sched" or "elv" in the function name instead of "shadow"? Shadow might not be the best name. Most do have shadows though, it's only the rare exception like the flush, that you mention. I'll see if I can come up with a better name. >> +struct request * >> +blk_mq_sched_request_from_shadow(struct blk_mq_hw_ctx *hctx, >> + struct request *(*get_sched_rq)(struct blk_mq_hw_ctx *)) > > This function dequeues a request from the I/O scheduler queue, allocates > a request, copies the relevant request structure members into that > request and makes the request refer to the shadow request. Isn't the > request dispatching more important than associating the request with the > shadow request? If so, how about making the function name reflect that? Sure, I can update the naming. Will need to anyway, if we get rid of the shadow naming. >> +{ >> + struct blk_mq_alloc_data data; >> + struct request *sched_rq, *rq; >> + >> + data.q = hctx->queue; >> + data.flags = BLK_MQ_REQ_NOWAIT; >> + data.ctx = blk_mq_get_ctx(hctx->queue); >> + data.hctx = hctx; >> + >> + rq = __blk_mq_alloc_request(&data, 0); >> + blk_mq_put_ctx(data.ctx); >> + >> + if (!rq) { >> + blk_mq_stop_hw_queue(hctx); >> + return NULL; >> + } >> + >> + sched_rq = get_sched_rq(hctx); >> + >> + if (!sched_rq) { >> + blk_queue_enter_live(hctx->queue); >> + __blk_mq_free_request(hctx, data.ctx, rq); >> + return NULL; >> + } > > The mq deadline scheduler calls this function with get_sched_rq == > __dd_dispatch_request. If __blk_mq_alloc_request() fails, shouldn't the > request that was removed from the scheduler queue be pushed back onto > that queue? Additionally, are you sure it's necessary to call > blk_queue_enter_live() from the error path? If __blk_mq_alloc_request() fails, we haven't pulled a request from the scheduler yet. The extra ref is needed because __blk_mq_alloc_request() doesn't get a ref on the request, however __blk_mq_free_request() does put one. -- Jens Axboe