Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp306444ybz; Fri, 24 Apr 2020 00:21:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKxd0Gcbc6YlFdradAWtoKR/SFMicLIJKLo9IPriNa8rljIUv4XdpkX3xHFRsHYGrTM4zQa X-Received: by 2002:a17:906:a3ca:: with SMTP id ca10mr6103954ejb.298.1587712871296; Fri, 24 Apr 2020 00:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587712871; cv=none; d=google.com; s=arc-20160816; b=GqcuYCJLrLQygrRuiEsT4dowpvppPF+TX9ePTCJs92O0FZxP7+57E8WVDWbm1Xsxwd Y47V6bedHkAGyt+dJ0BlW00mNbF+VBlla043rOekQZ+KxAxvO8gGocbvtRVaIkaDoQPx mKmRAlVl4/U23FVl3xbm9SsiUZBDaYWVUM6eZQ2nNsqPdCdOCYDNkXRyFmqJWnLOpNat hpC6X9I0B0oe6k19A5JM7J4DtQimRwUApHeKVdp3WVSHlKhmHAV4Vw45ogC0zAGnCryF ffErtNajby3mk5MT6pCbJV8OvUs6s89YXIY0+3AqGCrNZFO3TZIktMGFrZPMT15oZnj2 193A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=muBzdqNUTJAPKatNslH5zpL71xGD5YGNIv9ylQcrQuo=; b=d8Ww/tThlaodLDxkW9CW201MYDrVpBh7sPSIBhmDI1gh7auVr3T/agAM/2lgTQfLTP mf1vwytgpTuoFrOko2t9dmv92rdQw/OQ+983FB3DttxLNn49GYjZnGDuDcvht6QY3zjJ ho/Orqi194PCvH/wCylvFEyQkjXbu8vP0q0i9qqQbTTIregR4AK8HH5F+fG5DDel4Zwt cJ6ollbzbIdxlyczYkXsW5E6yY2JnLCZHZxuc5XHp5pA8t9qEzjqfKwpuUxBH7r+YGBp 0MMEP2r/TdExK4w13nhOMJWeHm8m7DALceRv1EdMkV/YJo/xckXHcqKdvnyQ/yPJjLOu FW9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si2954897edj.96.2020.04.24.00.20.48; Fri, 24 Apr 2020 00:21:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbgDXHTE (ORCPT + 99 others); Fri, 24 Apr 2020 03:19:04 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2092 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726051AbgDXHTD (ORCPT ); Fri, 24 Apr 2020 03:19:03 -0400 Received: from lhreml724-chm.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id DC1392CAC0741D5FB70B; Fri, 24 Apr 2020 08:19:01 +0100 (IST) Received: from [127.0.0.1] (10.47.6.64) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Fri, 24 Apr 2020 08:19:00 +0100 Subject: Re: [PATCH] blk-mq: Put driver tag in blk_mq_dispatch_rq_list() when no budget To: Ming Lei , Doug Anderson CC: Bart Van Assche , Jens Axboe , linux-block , LKML , "stable@vger.kernel.org" , Guenter Roeck References: <1587035931-125028-1-git-send-email-john.garry@huawei.com> <663d472a-5bde-4b89-3137-c7bfdf4d7b97@huawei.com> <20200424013519.GA355437@T590> From: John Garry Message-ID: <3b91a730-0923-c049-bbe4-68fc5a7ae793@huawei.com> Date: Fri, 24 Apr 2020 08:18:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20200424013519.GA355437@T590> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.6.64] X-ClientProxiedBy: lhreml722-chm.china.huawei.com (10.201.108.73) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/04/2020 02:35, Ming Lei wrote: > On Thu, Apr 23, 2020 at 03:42:37PM -0700, Doug Anderson wrote: >> 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. > > The thing is that there may not user visible effect by this issue, > when one tag isn't freed, this request will be re-dispatched soon. > That said it just makes the tag lifetime longer. > > It could only be an issue in case of request dependency, meantime > the tag space is quite limited. However, not sure if there is such > case in reality. > FWIW, this was pretty nasty to debug, and if it's not going to cause harm, then I'd be more inclined to add to stable. In addition, some distro may backport patches on a stable baseline where it is visible separately, and miss this one. Thanks, John