Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2311022ybz; Thu, 23 Apr 2020 15:44:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJgbj+rYNRzTejK/Sp/PGvPtG8MFcEIWrhd60NqGJ0sgO5k4wT2ewQuKCrXEzVRfPsZTz2v X-Received: by 2002:aa7:d1cc:: with SMTP id g12mr4893119edp.84.1587681890124; Thu, 23 Apr 2020 15:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587681890; cv=none; d=google.com; s=arc-20160816; b=nZRDTQCYS86MPhFmHJ0p7eQ5YtS+cpwZxoRW9XNuo1CbJqfWQ9wr55IsGsZocvCDxV HJpWnJJmzRc5LX8KhnR09gZ98YF4Ayk3tO7G2DKp02dszyFq3zFAfUetpYlQIPc1y2He LCCK0umdXWOLBsw2O2MZ9yboKGHtTN7ROR3s93v6aCRNiWQ74EtmOwW9Ol1AaJsV/GwM ls5AL3jHGemzMBjnjxK2gr1aqQ6sdvSU4+aZsdsUp+7CJaF8yfoBSNz9ftlzSgrsjyme sXtMaoAH5DZcHvsVP8TZYAcp5iBEfRws/Efa9jSMINpFltpg8YMK821wJneAdh3XW81i Z+3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LJ6/10OQi+IjRoROw1bmmwZkTPHiPo4CeITaSJNBJxE=; b=e4dZjSFPSR9lhMGY9Vza04b18kuKmlwHUwQFoPvwKtrPDktKFNnRbJST8qITqARK7u xjo83MUg9efGKaEECGnggAnwzwILejDCmUs7yhSlo0H9svBw1/puThP9Dmor9z+0KaqE yI4pDvW2sGS6mamW1Wa6pMw1ubxHvhZGkDXAysEhcZzD2u9OdZPxHBlvf2KhGZV1nUKI 88AIGeRgahqtvINqGnocvHIhaX+V5i++cBhZ8/aUSdu1QZetUFzUgBlsP+43NTeqxxz9 wETpiTNtt111e2VEwRQHzaOHv1X9Yowtexkp1XznMa8IEDJxCFVgBDz8k/1uc2azb3uv 9Fig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lUYiU6Ce; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 94si1899468edk.562.2020.04.23.15.44.25; Thu, 23 Apr 2020 15:44:50 -0700 (PDT) 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=@chromium.org header.s=google header.b=lUYiU6Ce; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbgDWWmw (ORCPT + 99 others); Thu, 23 Apr 2020 18:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbgDWWmv (ORCPT ); Thu, 23 Apr 2020 18:42:51 -0400 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821DFC09B043 for ; Thu, 23 Apr 2020 15:42:51 -0700 (PDT) Received: by mail-vk1-xa44.google.com with SMTP id d74so2225806vka.10 for ; Thu, 23 Apr 2020 15:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LJ6/10OQi+IjRoROw1bmmwZkTPHiPo4CeITaSJNBJxE=; b=lUYiU6CeDZLAwgfkrnPClfL9mW4Mccm3WgHBgOyJm3Ce+xg7lS02F8RLKC12vsJ7kl VaUzf3INAB4d7QhmeUNBWEZKfokkpuhEy9WQMrxDINFnlAD4RmaDOCx2fpGw5h+Ro1AT Xpnf7jZMZa1SZfYaLwydYhfmGM70QXxDKJwJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LJ6/10OQi+IjRoROw1bmmwZkTPHiPo4CeITaSJNBJxE=; b=NQY1slS4qifuN7Oiz5XC1REZtktJADX0eReoolidqOL89ntXCTpunsymYvYSQYzA9h qobiMtuXwvI6MmaoktLjwjJndNINVYNocqbuXwqvOv6daExEJAI732nRCH5FawwDmv0f 8ZCroOO0o+luEqUB03r3KXKP3n9h2LS1LRA9lkF3EoOiVHYFBGG9mPoDhIo8W+RnZIvK UbQkrcmZDon8VoMVXKaKyBP97P8rg23g1lVhhQTlJdTzgE9TzCF+i2PxkSRzsFKRtxBL 58fNu0nLLcjIRQihSQM06/uxMGZQn6dZElh1SrwEHKuibb9pBm8rvjSyZkSyYk6YECz6 MlmQ== X-Gm-Message-State: AGi0PuamoXdoetRsc73hVrk7l3ViApCmWF0HZAb8dFbbwE9+fwPF67XV 6zXHPIelBiHLfgQPxKd9ZeW+3XLTuEA= X-Received: by 2002:a1f:eb81:: with SMTP id j123mr5652310vkh.16.1587681770187; Thu, 23 Apr 2020 15:42:50 -0700 (PDT) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com. [209.85.222.43]) by smtp.gmail.com with ESMTPSA id 204sm1088966vka.32.2020.04.23.15.42.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Apr 2020 15:42:49 -0700 (PDT) Received: by mail-ua1-f43.google.com with SMTP id 36so3490062uaf.9 for ; Thu, 23 Apr 2020 15:42:48 -0700 (PDT) X-Received: by 2002:a05:6102:4d:: with SMTP id k13mr5446791vsp.198.1587681768455; Thu, 23 Apr 2020 15:42:48 -0700 (PDT) MIME-Version: 1.0 References: <1587035931-125028-1-git-send-email-john.garry@huawei.com> <663d472a-5bde-4b89-3137-c7bfdf4d7b97@huawei.com> In-Reply-To: <663d472a-5bde-4b89-3137-c7bfdf4d7b97@huawei.com> From: Doug Anderson Date: Thu, 23 Apr 2020 15:42:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] blk-mq: Put driver tag in blk_mq_dispatch_rq_list() when no budget To: John Garry Cc: Bart Van Assche , Jens Axboe , linux-block , LKML , Ming Lei , "stable@vger.kernel.org" , Guenter Roeck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Apr 20, 2020 at 1:23 AM John Garry wrote: > > On 18/04/2020 03:43, Bart Van Assche wrote: > > On 2020-04-16 04:18, John Garry wrote: > >> If in blk_mq_dispatch_rq_list() we find no budget, then we break of the > >> dispatch loop, but the request may keep the driver tag, evaulated > >> in 'nxt' in the previous loop iteration. > >> > >> Fix by putting the driver tag for that request. > >> > >> Signed-off-by: John Garry > >> > >> diff --git a/block/blk-mq.c b/block/blk-mq.c > >> index 8e56884fd2e9..a7785df2c944 100644 > >> --- a/block/blk-mq.c > >> +++ b/block/blk-mq.c > >> @@ -1222,8 +1222,10 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, > >> rq = list_first_entry(list, struct request, queuelist); > >> > >> hctx = rq->mq_hctx; > >> - if (!got_budget && !blk_mq_get_dispatch_budget(hctx)) > >> + if (!got_budget && !blk_mq_get_dispatch_budget(hctx)) { > >> + blk_mq_put_driver_tag(rq); > >> break; > >> + } > >> > >> if (!blk_mq_get_driver_tag(rq)) { > >> /* > > > > Is this something that can only happen if q->mq_ops->queue_rq(hctx, &bd) > > returns another value than BLK_STS_OK, BLK_STS_RESOURCE and > > BLK_STS_DEV_RESOURCE? > > Right, as that case is handled in blk_mq_handle_dev_resource() > > If so, please add a comment in the source code > > that explains this. > > So important that we should now do this in an extra patch? > > > > > Is this perhaps a bug fix for 0bca799b9280 ("blk-mq: order getting > > budget and driver tag")? If so, please mention this and add Cc tags for > > the people who were Cc-ed on that patch. > > So it looks like 0bca799b9280 had a flaw, but I am not sure if anything > got broken there and worthy of stable backport. > > I found this issue while debugging Ming's blk-mq cpu hotplug patchset, > which I feel is ready to merge. > > Having said that, this nasty issue did take > 1 day for me to debug... > so let me know. As per the above conversation, presumably this should go to stable then for any kernel that has commit 0bca799b9280 ("blk-mq: order getting budget and driver tag")? For instance, I think 4.19 would be affected? When I picked it there I got a conflict due to not having commit ea4f995ee8b8 ("blk-mq: cache request hardware queue mapping") but I think it's just a context collision and easy to resolve. I'm no expert in the block code, but I posted my backport to 4.19 at . I'm happy to send an email as a patch to the list too or double-check that someone else's conflict resolution matches mine. -Doug