From patchwork Thu Jan 19 17:37:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9526593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF19660113 for ; Thu, 19 Jan 2017 18:00:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D057628531 for ; Thu, 19 Jan 2017 18:00:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C51322853E; Thu, 19 Jan 2017 18:00:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8947A284D5 for ; Thu, 19 Jan 2017 18:00:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753822AbdASSAZ (ORCPT ); Thu, 19 Jan 2017 13:00:25 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:52474 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753798AbdASSAL (ORCPT ); Thu, 19 Jan 2017 13:00:11 -0500 Received: from pps.filterd (m0044008.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v0JHXcNP004473 for ; Thu, 19 Jan 2017 09:37:39 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=to : cc : from : subject : message-id : date : mime-version : content-type : content-transfer-encoding; s=facebook; bh=GbuVZSt/4rMp2AwHNy/TBM/6VGwZ0GG2eInu1wPUreA=; b=jIYl+MfM2+RShPubmym7QqajIxgz7qrkhyqAi1EkmxQcwg+ZIW+Otxb9FtnzeIQJ5sym ELZOmtbEtEjGJyCJ7KnshHQSSFLHnnRFyaIM7FkB5+Pa0ZuuRkHOsZn4tR8rrHd0pXSq zeYErtqBz9A9l+PES74E6/ny1oBA222pekA= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2831tkr1rg-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 19 Jan 2017 09:37:39 -0800 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 19 Jan 2017 09:37:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GbuVZSt/4rMp2AwHNy/TBM/6VGwZ0GG2eInu1wPUreA=; b=dN+SzeXVslaTxx9uY5wa25vvfNlwseFepfKx/XWwX/WrZb5nfhg60JuANvWQuYQNPv8D9rHCvtoN/1h+jbW6Vdo0WKz6XusbQNgZwwy8ai8iq1EvEPZ/oYpXyhgxOTHbCRN4lwgzanVAYHOnp1HsmddtkgsU1m+RwzRxDA6UbUY= Received: from [IPv6:2620:10d:c082:1055:9a8a:7d82:4d5f:1afe] (2620:10d:c090:200::2:2533) by CY4PR15MB1192.namprd15.prod.outlook.com (10.172.177.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Thu, 19 Jan 2017 17:37:37 +0000 To: "linux-block@vger.kernel.org" CC: Omar Sandoval From: Jens Axboe Subject: [PATCH] blk-mq: allow resize of scheduler requests Message-ID: <62d3fe78-9a16-edce-8746-e8d2e7181f23@fb.com> Date: Thu, 19 Jan 2017 09:37:34 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::2:2533] X-ClientProxiedBy: MWHPR20CA0016.namprd20.prod.outlook.com (10.171.151.154) To CY4PR15MB1192.namprd15.prod.outlook.com (10.172.177.14) X-MS-Office365-Filtering-Correlation-Id: a363c408-44f2-420b-6568-08d44091dc24 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR15MB1192; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 3:x1Ar0i+0Mh4d4fi+Ht2qlhHXn+Ua/MZxwyxiDdo6Yb7Ekpq0031m44Y96+3y4YjYAK3/rS1ne2Eujemvu4+SVzlXfG6GU043KXNSOuxbu2o/7g6YXrzaCFmXqgbCnSQkP51ZyWDo2CNMUvxNjDMjvb857zRpb6j7HhvTO108ghbZ8QQuYP8vuooiM5EL9AypXC/j65Dj/tdQ9xzz5pqG3riWpHW4fPzeZgO8wVkIP8qEe9ES0l1UsLcweKtiGtyimcdeSYGFYAEDYDx+k8LDIQ== X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 25:WHbfmq+GsdpG3DAZl22XYiPtgypJUX66MpbeDrCEF0GF+xtM3yuF7OH8oEzZolGCIVCe/qXtEVQD5qnHaGkq5tn2QHLiv9Y0jXMv3RqjdS6v+lV00P2U+KwaCx112IFNh0Bx4HGQdZ7By6oIZ6yOI4hu5inpz5/f4sQ66zfLgIwFUi6Ej4O0bDmkt8i71+f8ninOkC20WEDWzKLH1CrgCW6Q4jcAqST7yRun/TTio2AQ2LP4i5Sjb5M+VqXSGpTNrGkIu52Tj90dpzQkjQfT28GPkh9ySd34ZWp86YZUK6V0Xz8T+TxaeWXeBmrj5UipOaMf2hjR0eX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h0uA9ykux4zqd9GA/FLIBv6ReNwTyTZSaZIZJqX6FXF7PM2tOlj24yE/RSIIiYCLLxo0FejKm6dWe2zpd2HE43fJMhwCcWR1CiTu8Df0SwFdyOzxwqcxlX5Ns+/bDTzwReP/yrWPO7Kv6JjzHK1DGVVHZMfFIzJw76vlcJ/gJEBpkCfdEsRLih1NhRMHaoEx2Ihs7bcJ2NyNQIkM/w1h9loQQM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:CY4PR15MB1192; BCL:0; PCL:0; RULEID:; SRVR:CY4PR15MB1192; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 4:qcyD/92h0VAT4BCpFbGxktAMmTxS/fIE4yGoyExxo/6V6Atz/1pgaBVawU6clyqA6xgEBOR86oggPTnfxG+nlK8YFS728uWNAZw8ZQNqMC2H91Xl85JtiT4jkQPha24dzstDbhAQzxkk+1JVSgOqzUvhnyOPd9mQIBB4FvQzXjFYmlufU+PLcP/Un/L4qqlL0yjXa++fsdBDp1bNh7SFcp0ZAaGLX9kKrDMNKB9z1OFb+A4RKCrsH9Iq1hOwxmi8eSuzatiPYgbGYDyfNISFRrd+xndv5iEyKlQWpdlgUnlHaIJFLR7cNYICEvQ0h8qlYifqY0TiXzmaxRQ/JWR/tLnTxTOD6IzINYpwghlw+kF/Gch3AMS6aAzIu1E0Us/HwoKUXldifBpbbudzMjngklPp2ug2okUCP6IHL2WB7NGpb2ClEIr2JN5vBuJbi5FjuP//qKFKuAnUm3ywOVIqs5bwr6CHJrzv2BrzCMVmw0WS8QvPl/2bHe7YsEDry7voQzh/3XS0JHmxewO8SI84vqdwxiP7K2vv5T24uda3thBQuZWRmoQpvCmOOiCUthbMBXbECXsJvYrZyPmzEaNGNg7lBRnqqgZWUTEikoKq1ai8r8yWbtNKEPReoVbsLEf8 X-Forefront-PRVS: 0192E812EC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(39830400002)(39450400003)(39410400002)(189002)(199003)(81166006)(305945005)(7736002)(23676002)(86362001)(189998001)(36756003)(92566002)(68736007)(53936002)(4001350100001)(33646002)(31696002)(50466002)(47776003)(2501003)(65806001)(65956001)(8676002)(31686004)(81156014)(42186005)(83506001)(6666003)(2351001)(38730400001)(4326007)(101416001)(6486002)(5640700003)(25786008)(105586002)(450100001)(6916009)(65826007)(50986999)(5660300001)(1706002)(6116002)(230700001)(64126003)(97736004)(54356999)(2906002)(110136003)(106356001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1192; H:[IPv6:2620:10d:c082:1055:9a8a:7d82:4d5f:1afe]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjE1TUIxMTkyOzIzOmU2MHBtWkMvcTl5SDV1UGx3WnlSbVlYWjFG?= =?utf-8?B?RUpyNkVuVlpnZ0hJbGxVNDRUS3k1WmlzMXlRNU91NkdBMEl5eHRmQWNLNzhZ?= =?utf-8?B?VUhMTlkzU0I2M0VCYmdtSThWb1JSTWFNYnhoMlgrR0pCOWlySUFIbzVaWDkx?= =?utf-8?B?cC9OUU9VaXplZjBSODFPOWtsTDlTdXpmNHdrYlpZVDkvOVBvM2J0WnYxOEl0?= =?utf-8?B?MDdzbzNpUHdRY0Vmc1Z3eUZvQ0tRVUk4YVZHZktEN1U5eFI1SzRxYzFPMXpo?= =?utf-8?B?S0hwZUZJMUN0M1ZiZko5SEgrd2dveVdHLzRzWnQ3UjNMTlZvaTVYMUNNd0Uz?= =?utf-8?B?MHIzc3o0MjUrL0JGTHRnN0FtbmhSb3NqWGNsTXZQQU9qc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OeNA0KDdawym66vqvynVC+MqxrvQhRalbNLFl9NjWJVwYcaE+Xhj3VVEhX753V8ERI4z6LpEWZMGTYKTnUa+vNb4tZzusKVd0xIyZdEAZ+jD4zExMkzIRlvYHJNAWU146Yv+Imce8dWNfBB/FV4Uy+Gyx+/CqY7Y=; 24:qChhtrg+LP+CNKUjIL2qSLl8LBVLn8Y3sIsYYtEnK2gjFCtkRrdi6dRXyVIazhgUB8pCIYFCq9qFrlRvtedid06yBiaCDv+F1FQOspHD2Rk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1192; 7:/WSG6FDHuYGeX0qsgaRG9kcDJqU8efyCJT4rJP46RHQjrEx/fho/u4BZLDcKJXAJ/20LN7sNhpmslvkbm14sY2Jbvz2GegYzJraKes3FLsvvkUZkiZ8i9pMF/WF2oSI3BvqqvQ6PaZ2C0zoHv14k7ilgJGm9F/Jhr6OiDT5Zfuiy4Yzug2LZvSL6lwIHg+t9tPNiwhDPDg5FkP8Y1a50Ff8eO0mtrZPRH8hl4uND7kHc6o0X5ZAIwzBxiRG4/aPH0wWiXrkbE+jaG0g3pdE2XSNK1sIWS+ATpK3DfNmfCNSOAK3b/iFZEuSEWTSt5shvxyhHb8ICGgu2nYAbcehQci9qYNznGpyAyzgn65qaahLCuGlLsne6qzKHoseosFvVCenK9g0dOIJsgvI/eg3L6UK7C2jPSmBAAAt1cx3aU+/BgEgFapbWSnvmVwkYvD79sCFXaXNntpH0D1HeXHSlNQ==; 20:U1wsK3mArRUhy78p2SiDAAQ7rKz2ugBScmIk/kp62FrsYUNl9r2n0B0C88Du3uKHHeb75eeL6z+tY5wPNVZGLFXYluahMloSCbzRltepl26VSwaVuKARh5K6ME2SaBzj1ASAtwlTWHpkg5yqNQNXLDoUChyQxShiGixbCJL7fYo= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2017 17:37:37.1378 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1192 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-19_06:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for growing the tags associated with a hardware queue, for the scheduler tags. Currently we only support resizing within the limits of the original depth, change that so we can grow it as well by allocating and replacing the existing scheduler tag set. This is similar to how we could increase the software queue depth with the legacy IO stack and schedulers. Signed-off-by: Jens Axboe --- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 5504eb7ed10b..3ab514f6f288 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -387,19 +387,52 @@ void blk_mq_free_tags(struct blk_mq_tags *tags) kfree(tags); } -int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int tdepth) +int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx, + struct blk_mq_tags **tagsptr, unsigned int tdepth, + bool can_grow) { + struct blk_mq_tags *tags = *tagsptr; + tdepth -= tags->nr_reserved_tags; - if (tdepth > tags->nr_tags) - return -EINVAL; + + /* + * If we are allowed to grow beyond the original size, allocate + * a new set of tags before freeing the old one. + */ + if (tdepth > tags->nr_tags) { + struct blk_mq_tag_set *set = hctx->queue->tag_set; + struct blk_mq_tags *new; + bool ret; + + if (!can_grow) + return -EINVAL; + + /* + * We need some sort of upper limit, set it high enough that + * no valid use cases should require more. + */ + if (tdepth > 16 * BLKDEV_MAX_RQ) + return -EINVAL; + + new = blk_mq_alloc_rq_map(set, hctx->queue_num, tdepth, 0); + if (!new) + return -ENOMEM; + ret = blk_mq_alloc_rqs(set, new, hctx->queue_num, tdepth); + if (ret) { + blk_mq_free_rq_map(new); + return -ENOMEM; + } + + blk_mq_free_rqs(set, *tagsptr, hctx->queue_num); + blk_mq_free_rq_map(*tagsptr); + tags = *tagsptr = new; + } /* * Don't need (or can't) update reserved tags here, they remain * static and should never need resizing. */ sbitmap_queue_resize(&tags->bitmap_tags, tdepth); - - blk_mq_tag_wakeup_all(tags, false); return 0; } diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h index 41cd15fd1afd..ac22878462e7 100644 --- a/block/blk-mq-tag.h +++ b/block/blk-mq-tag.h @@ -29,7 +29,9 @@ extern void blk_mq_put_tag(struct blk_mq_hw_ctx *hctx, struct blk_mq_tags *tags, struct blk_mq_ctx *ctx, unsigned int tag); extern bool blk_mq_has_free_tags(struct blk_mq_tags *tags); extern ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page); -extern int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int depth); +extern int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx, + struct blk_mq_tags **tags, + unsigned int depth, bool can_grow); extern void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool); void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn, void *priv); diff --git a/block/blk-mq.c b/block/blk-mq.c index b365cde4c909..ee69e5e89769 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2561,6 +2561,9 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) if (!set) return -EINVAL; + blk_mq_freeze_queue(q); + blk_mq_quiesce_queue(q); + ret = 0; queue_for_each_hw_ctx(q, hctx, i) { if (!hctx->tags) @@ -2569,11 +2572,14 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) * If we're using an MQ scheduler, just update the scheduler * queue depth. This is similar to what the old code would do. */ - if (!hctx->sched_tags) - ret = blk_mq_tag_update_depth(hctx->tags, - min(nr, set->queue_depth)); - else - ret = blk_mq_tag_update_depth(hctx->sched_tags, nr); + if (!hctx->sched_tags) { + ret = blk_mq_tag_update_depth(hctx, &hctx->tags, + min(nr, set->queue_depth), + false); + } else { + ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags, + nr, true); + } if (ret) break; } @@ -2581,6 +2587,9 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) if (!ret) q->nr_requests = nr; + blk_mq_unfreeze_queue(q); + blk_mq_start_stopped_hw_queues(q, true); + return ret; }