Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9258606pxu; Mon, 28 Dec 2020 10:39:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlaLdAr+FI1ZbzylgKR32B31tz7WbEGEkqGMx6PAE/5DPUDlBZC0L5chE/Wbpdzu+uzpep X-Received: by 2002:a17:906:3953:: with SMTP id g19mr42195323eje.429.1609180754253; Mon, 28 Dec 2020 10:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609180754; cv=none; d=google.com; s=arc-20160816; b=CJ6tvcfiRDF6owlaQ1K1+3aejqHPZyA4qHzV2BcHmib31JX4ZrNQR/T0d63h4kbwTs V1trVPVZxi6FDVPeaoOXo6hnf3FnHuN1VYXjgGxsq91B+sjscPjStDi7Q53XE1vnz9sB b9Lj/u7Ip1UzChr6mjktO4O5TEyl23bT834cGfnSDB0GdWlHLd2Uo0YwT4bWaD4KXHLg 7KLe4CskC729Lnz97Ug7gAQibQHG9d4PUoJvkDxH5nFGDZwsiZoI3S0YC3RbEA8oWB0P eIrLmkLWjavXeHcHlsZ0P+hZsrwroTE7Iaa5LD9uQCZNDHWDol6FBOFX895r8bZFTbpg ewxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2t7E2V//V+BWmvC0p6GBReUnZ4YXFDp1CBgH0qEPmY4=; b=TLv8v9dke70yLpo37q0b82AQ5O7RsX57D6kWhVxyappmKr5WSIM7HN9n5RQPyobbzd 7Gxeq5JJE7+9IY37yU5km19TKbENBu3kaedMdEAReU58jpT+VV4AEnbfDEkWHV8G2v4f yMC/ZiYncKGgCZ3tCNDDN5EoWnB7MqPmPiHCz5ps3KTVIl1Ak4w1/jBv6SewDT2Uy2y7 SCv8CbBaQ9TjMEVDmP4sf1FE2qRfrd+Zppwnm62V7/8ZXcaNfkqGTP7UahD8qCOLwoMZ 6Gkxbazc6J/oqdYHcAhsjcypIAQ5lFxByDHmkkOjwCydkW1DZuoTHa/i7dS6YK2kQ6xB aTOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vtAfAGnr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a29si21907916edm.401.2020.12.28.10.38.52; Mon, 28 Dec 2020 10:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vtAfAGnr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390485AbgL1Nhw (ORCPT + 99 others); Mon, 28 Dec 2020 08:37:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:37084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390786AbgL1Nh2 (ORCPT ); Mon, 28 Dec 2020 08:37:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 90A81208BA; Mon, 28 Dec 2020 13:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609162633; bh=DYQ9s/7wtHpTAFw8NvX1NAsWf42X/bqg7gd1gFhpoZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vtAfAGnrlAuvP+A1Krql3PEsaBcW+jxQDJLrN1zVPvvyfr/9nMxQNo/xZULHiu46R TjCfOLjyb3sx9RXGpHhrW2ugsPKcJ5Ro3IOWSEtz4EpApmXCSjIlbr1+45RYI4pZq+ 7VNozU4NfQA8YmpyQZ544277gTf3pGKicUft2z0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 5.4 020/453] blk-mq: In blk_mq_dispatch_rq_list() "no budget" is a reason to kick Date: Mon, 28 Dec 2020 13:44:16 +0100 Message-Id: <20201228124938.225832767@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Anderson [ Upstream commit ab3cee3762e5e69f27c302c43691289fdfc12316 ] In blk_mq_dispatch_rq_list(), if blk_mq_sched_needs_restart() returns true and the driver returns BLK_STS_RESOURCE then we'll kick the queue. However, there's another case where we might need to kick it. If we were unable to get budget we can be in much the same state as when the driver returns BLK_STS_RESOURCE, so we should treat it the same. It should be noted that even if we add a whole bunch of extra kicking to the queue in other patches this patch is still important. Specifically any kicking that happened before we re-spliced leftover requests into 'hctx->dispatch' wouldn't have found any work, so we really need to make sure we kick ourselves after we've done the splicing. Signed-off-by: Douglas Anderson Reviewed-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c0efd3e278da6..057a634396a90 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1233,6 +1233,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, bool no_tag = false; int errors, queued; blk_status_t ret = BLK_STS_OK; + bool no_budget_avail = false; if (list_empty(list)) return false; @@ -1251,6 +1252,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, hctx = rq->mq_hctx; if (!got_budget && !blk_mq_get_dispatch_budget(hctx)) { blk_mq_put_driver_tag(rq); + no_budget_avail = true; break; } @@ -1356,13 +1358,15 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, * * If driver returns BLK_STS_RESOURCE and SCHED_RESTART * bit is set, run queue after a delay to avoid IO stalls - * that could otherwise occur if the queue is idle. + * that could otherwise occur if the queue is idle. We'll do + * similar if we couldn't get budget and SCHED_RESTART is set. */ needs_restart = blk_mq_sched_needs_restart(hctx); if (!needs_restart || (no_tag && list_empty_careful(&hctx->dispatch_wait.entry))) blk_mq_run_hw_queue(hctx, true); - else if (needs_restart && (ret == BLK_STS_RESOURCE)) + else if (needs_restart && (ret == BLK_STS_RESOURCE || + no_budget_avail)) blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY); blk_mq_update_dispatch_busy(hctx, true); -- 2.27.0