From patchwork Tue Jan 24 22:06:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9535997 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 530AD601D3 for ; Tue, 24 Jan 2017 22:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31EC523B23 for ; Tue, 24 Jan 2017 22:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22E372787C; Tue, 24 Jan 2017 22:06:59 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 3874B23B23 for ; Tue, 24 Jan 2017 22:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750892AbdAXWG5 (ORCPT ); Tue, 24 Jan 2017 17:06:57 -0500 Received: from mail-it0-f46.google.com ([209.85.214.46]:36082 "EHLO mail-it0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbdAXWG5 (ORCPT ); Tue, 24 Jan 2017 17:06:57 -0500 Received: by mail-it0-f46.google.com with SMTP id c7so96005529itd.1 for ; Tue, 24 Jan 2017 14:06:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=CErTeE50/7lKCYMUhCp6yLMMg7o0GZv/mu1txkwSzz8=; b=jB7Xz+SL9u+NviufsKzSl33eh76Ny/u4pSu+Wcg/Fle51XH2d1snXaT+dVATpkeIQh uBFHBpTUMyXuwwdqsweD8rU1UgZ8GVQyl94vTtfbb1GdOLiitGPpOlVFgk3V6TfcHaXD LJoylhezzsxqzleKSVgyX4FftZ9xsMyrrZGBQtNypLdts6set+wVmirJc0JE+nkgviWH DpKwky4hnsThW9gttWI+Wk6Vh+n5YxSe6NMEtO7a5TYyNWUXadE7QxM60BTY2mU2jRup g3UfYA58/vKCQw32mMhi+KS/57Nzee36ziiLINJUU+LOFnHgpkXxckldnaULuqzKYmd3 7cMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=CErTeE50/7lKCYMUhCp6yLMMg7o0GZv/mu1txkwSzz8=; b=JmZAfLqzHBDkIrdeUQdBlTax2y133ArLZphIsI+u8wmeIKbFmRFskhh3LarpeUXSlO pSJ/nQ6vofJOJfXvqI9RbGz7vKK314TzUDVrH4n93MYjK1IrOZLm/IHq7vZGZmOhsT46 RTEsgUQQ9SntbrtG3qTimnNybDQojcUacUVrZ0e98AHf0Zd3W/wK1c4yRoxUKo2dDf/S 33clt9RgoWw2wSZ0fT1yVaX+nuwFH0Q2fuIw7cFml73tqTEgmk4ENR9GQNnStjOyH9Bz a+tjKd0Au7z55cWgouZAQSIokpTTepItQ7gLlI5Hjve2Jw2oTx5V/3rxRNpTGjDYgFpL Df3w== X-Gm-Message-State: AIkVDXLyz0Y++aQ4sffB2KC+9dHmuDMTYG5KZuczqbSg0uxUA1pEUkFwshtjSBvpr20czg== X-Received: by 10.36.102.195 with SMTP id k186mr23449365itc.75.1485295616130; Tue, 24 Jan 2017 14:06:56 -0800 (PST) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id m128sm9035391itm.16.2017.01.24.14.06.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 14:06:54 -0800 (PST) Subject: Re: [PATCH] queue stall with blk-mq-sched To: Hannes Reinecke References: <762cb508-1de0-93e2-5643-3fe946428eb5@fb.com> <8abc2430-e1fd-bece-ad52-c6d1d482c1e0@suse.de> <1663de5d-cdf7-a6ed-7539-c7d1f5e98f6c@fb.com> Cc: "linux-block@vger.kernel.org" , Omar Sandoval From: Jens Axboe Message-ID: <717c595a-a3a6-0508-b537-8cf9e273271e@kernel.dk> Date: Tue, 24 Jan 2017 15:06:53 -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: <1663de5d-cdf7-a6ed-7539-c7d1f5e98f6c@fb.com> 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 On 01/24/2017 12:55 PM, Jens Axboe wrote: > Try this patch. We only want to bump it for the driver tags, not the > scheduler side. More complete version, this one actually tested. I think this should fix your issue, let me know. diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index a49ec77..1b156ca 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -90,9 +90,11 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx, return atomic_read(&hctx->nr_active) < depth; } -static int __blk_mq_get_tag(struct blk_mq_hw_ctx *hctx, struct sbitmap_queue *bt) +static int __blk_mq_get_tag(struct blk_mq_alloc_data *data, + struct sbitmap_queue *bt) { - if (!hctx_may_queue(hctx, bt)) + if (!(data->flags & BLK_MQ_REQ_INTERNAL) && + !hctx_may_queue(data->hctx, bt)) return -1; return __sbitmap_queue_get(bt); } @@ -118,7 +120,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) tag_offset = tags->nr_reserved_tags; } - tag = __blk_mq_get_tag(data->hctx, bt); + tag = __blk_mq_get_tag(data, bt); if (tag != -1) goto found_tag; @@ -129,7 +131,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) do { prepare_to_wait(&ws->wait, &wait, TASK_UNINTERRUPTIBLE); - tag = __blk_mq_get_tag(data->hctx, bt); + tag = __blk_mq_get_tag(data, bt); if (tag != -1) break; @@ -144,7 +146,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data) * Retry tag allocation after running the hardware queue, * as running the queue may also have found completions. */ - tag = __blk_mq_get_tag(data->hctx, bt); + tag = __blk_mq_get_tag(data, bt); if (tag != -1) break; diff --git a/block/blk-mq.c b/block/blk-mq.c index ee69e5e..dcb5676 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -230,15 +230,14 @@ struct request *__blk_mq_alloc_request(struct blk_mq_alloc_data *data, rq = tags->static_rqs[tag]; - if (blk_mq_tag_busy(data->hctx)) { - rq->rq_flags = RQF_MQ_INFLIGHT; - atomic_inc(&data->hctx->nr_active); - } - if (data->flags & BLK_MQ_REQ_INTERNAL) { rq->tag = -1; rq->internal_tag = tag; } else { + if (blk_mq_tag_busy(data->hctx)) { + rq->rq_flags = RQF_MQ_INFLIGHT; + atomic_inc(&data->hctx->nr_active); + } rq->tag = tag; rq->internal_tag = -1; } @@ -869,6 +868,10 @@ static bool blk_mq_get_driver_tag(struct request *rq, rq->tag = blk_mq_get_tag(&data); if (rq->tag >= 0) { + if (blk_mq_tag_busy(data.hctx)) { + rq->rq_flags |= RQF_MQ_INFLIGHT; + atomic_inc(&data.hctx->nr_active); + } data.hctx->tags->rqs[rq->tag] = rq; goto done; }