Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp72027ybz; Thu, 23 Apr 2020 18:38:57 -0700 (PDT) X-Google-Smtp-Source: APiQypKi3kwhdX0/0vdMmPeOW9DLPAfU9tyP7uhfg/lU3N5ZGdmQ/JWFsVHmho43ML0HeVCSBFQe X-Received: by 2002:a17:906:558a:: with SMTP id y10mr5351818ejp.192.1587692336871; Thu, 23 Apr 2020 18:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587692336; cv=none; d=google.com; s=arc-20160816; b=uKrCMFY46ifYJbVpwDz0CQ3CWfybeXOOmGu2L7f1Us1NJgO3b9n5ugqlDMiGGX3RSw UIGlneE9ccbHLh/xfcAJCWoSPFTNHmW6AJkyEFmZnpmf+zkbZMuOJoJ/9zv8lrnX61xF C9GLRFvnJRTllFttixvVu4Tlr7MQUGzVhQI/6xmL/FUIGEAa964osnQHbEd3UhB6gT0z w5CqaVpGukTsz0fbmik8jOjnzQIQUzYZaD9EtsbG5mYV1X7B9jGgw1I1mYPmWF+YGt21 7jsPRS3zOb6sW/5pwBoLoTZSHWPKX+srw08qQejNUWeUSpkd2UfotkW8hLlGjY60icCr ixGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=mE9Xh8mrcpOk6T4hIIq35lM4lacrhC50tnRMlWlgS+c=; b=s+55Ls4V7WwNtX9sgdnuvC/p782ElKSaWwHGasZyNdI0b/hQEaj28O/g43BEw0Zbov u2uzZQKPzNpHGL6huPY+jIlHnVWuJbu1leBUq8hEsMrGcuxbSHVAsVFED87HixqYBeKn aADNwqtErj2P6n5HlbSsTTT945MtNkONF0ofpAk4EXPxtFrekyGAaYYjsTw9/UtTSMJ2 A+XQt/L5oND1t14WqaeGtiUSMAqM3H133VrnnVvcqGEtIqAIcG847wrr/JL5+0np21za Vc85V/hPcnQvKIVpEoFqzT4Dlrj6EQ9ERJkZKH7zzEF+XKD56MzjjJsFMTXr4E97Oz1+ BkSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ii2FQ9kj; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si2215851ejr.224.2020.04.23.18.38.31; Thu, 23 Apr 2020 18:38:56 -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=@redhat.com header.s=mimecast20190719 header.b=ii2FQ9kj; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbgDXBfl (ORCPT + 99 others); Thu, 23 Apr 2020 21:35:41 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44186 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725884AbgDXBfl (ORCPT ); Thu, 23 Apr 2020 21:35:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587692139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mE9Xh8mrcpOk6T4hIIq35lM4lacrhC50tnRMlWlgS+c=; b=ii2FQ9kjj7bt7gdiWhEuPSUDJKdLbn6iXWr9UtsWpvYPpLW5vbdhKP4cPKgv+uSfxbIV2M 5OxNbD2KM0HEztNvBQUDVK2Eo6eBPedjaLN+3HuvSMweYABjUa09QnrKdysboQzjsOAatr DfA6fBP1cc1S5XUnF7z+yu4WiOmh79c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-297-ArNzbblSNFSNTtHtyJheKw-1; Thu, 23 Apr 2020 21:35:35 -0400 X-MC-Unique: ArNzbblSNFSNTtHtyJheKw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85AB280B70B; Fri, 24 Apr 2020 01:35:33 +0000 (UTC) Received: from T590 (ovpn-8-25.pek2.redhat.com [10.72.8.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42BF060C81; Fri, 24 Apr 2020 01:35:23 +0000 (UTC) Date: Fri, 24 Apr 2020 09:35:19 +0800 From: Ming Lei To: Doug Anderson Cc: John Garry , Bart Van Assche , Jens Axboe , linux-block , LKML , "stable@vger.kernel.org" , Guenter Roeck Subject: Re: [PATCH] blk-mq: Put driver tag in blk_mq_dispatch_rq_list() when no budget Message-ID: <20200424013519.GA355437@T590> References: <1587035931-125028-1-git-send-email-john.garry@huawei.com> <663d472a-5bde-4b89-3137-c7bfdf4d7b97@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, Ming