Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3115627pxb; Sun, 26 Sep 2021 05:50:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLIFC8VBwLUEZ0S8g1qpLoogn/WObzRsVDvY+9xgBa6T96rCLQdpltgGmOeBjqiyq8EN/V X-Received: by 2002:a17:906:c249:: with SMTP id bl9mr21580519ejb.225.1632660626850; Sun, 26 Sep 2021 05:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632660626; cv=none; d=google.com; s=arc-20160816; b=KuTWnMzb/tpNKF18CFji3UpRASeLyeLqYgBLruhjfnj/NVwLI64K97SGyzX98FluKc gN0AHamrB6NMo0bPW5RVq79k3A7he4hllQkbxl0hzLAJcmszYprR5lAPkzxZQz36D9xo mskpk7oQpnGo00EyRjWclu7jxXkKm+RLioS6pMwV9HUFkZm8VzFTyuiNSb2O3D9AFQ5q iNr6vUtiU1hSvawTAijnOJlQswpA372qdYcoQLuz+JBOnCoGJYbp1tJ5TljaBHrL+Ivp Jb013cIsTpblsJeD4Dq+njOkRNLAp/E0/BgfJviFkVNOrQKmHxUSI0qSiuYfs+zv0e2g aFhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TIU1SliLHR0gPG253uhvPBnlkJkKd7zvq1PnYr5EWUg=; b=x3tZcbLq74rXHUeNEVcmfZIYatMp9bgiYMzUGj7O5g0JP2kzO2cO/bg2fqI9Mv3TcS NiVPY5gXCNNmDnsSZzbtzHgt1fUsFU1rm6u+Gl5yT30NMo+kjM3EnrgskYgODKx+/o+3 5TRF5Ceu7r1l5qnAxoA9+ct0fGq3QY/mUUL8uoo9YSi0r0yzBvf4Q3a/oEnxcDtEEsT9 2z1vdIpK8X22+d37fo5BX6OForwlZi5PYJDRWNzfFh6cOzatejtQgFFNut6cz6YRsgae Hc1rx5YxE4KDipSzCJt4ezjST7EM6Rh3QHt52Z2bAgj26+mVpcAXMdliuetFMfgq3aIO sr/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KqMbSuLZ; 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 dc16si14685865ejb.287.2021.09.26.05.50.00; Sun, 26 Sep 2021 05:50:26 -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=KqMbSuLZ; 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 S231441AbhIZMtW (ORCPT + 99 others); Sun, 26 Sep 2021 08:49:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24675 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbhIZMtV (ORCPT ); Sun, 26 Sep 2021 08:49:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632660465; 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=TIU1SliLHR0gPG253uhvPBnlkJkKd7zvq1PnYr5EWUg=; b=KqMbSuLZtpd4EMUZqn3krJZ1ZVV7WInqAv3widCmxOaNNv0PffAOZttRAsqwvkLndp7soj Z+P/uKug/FctFDlCqsIug9o7wHgzuznn8bipYQui0CAZ1v5V9ypJMAhssXJUBR0bzk31Db 0HtG0fS0OGuqpc8KEvYHuMqI+tBMRCE= 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-450-lrhylb9gPjypIXuBOSCoEw-1; Sun, 26 Sep 2021 08:47:43 -0400 X-MC-Unique: lrhylb9gPjypIXuBOSCoEw-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 C0D1A1006AA2; Sun, 26 Sep 2021 12:47:41 +0000 (UTC) Received: from T590 (ovpn-8-24.pek2.redhat.com [10.72.8.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57D2F60C04; Sun, 26 Sep 2021 12:47:32 +0000 (UTC) Date: Sun, 26 Sep 2021 20:47:48 +0800 From: Ming Lei To: Laibin Qiu Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, hare@suse.de, asml.silence@gmail.com, bvanassche@acm.org Subject: Re: [PATCH -next] blk-mq: fix tag_get wait task can't be awakened Message-ID: References: <20210913081248.3201596-1-qiulaibin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210913081248.3201596-1-qiulaibin@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Laibin, On Mon, Sep 13, 2021 at 04:12:48PM +0800, Laibin Qiu wrote: > When multiple hctx share one tagset. The wake_batch is calculated > during initialization by queue_depth. But when multiple hctx share one > tagset. The queue depth assigned to each user may be smaller than > wakup_batch. This may cause the waiting queue to fail to wakup and leads > to Hang. In case of shared tags, there might be more than one hctx which allocates tag from single tags, and each hctx is limited to allocate at most: hctx_max_depth = max((bt->sb.depth + users - 1) / users, 4U); and users = atomic_read(&hctx->tags->active_queues) See hctx_may_queue(). tag idle detection is lazy, and may be delayed for 30sec, so there could be just one real active hctx(queue) but all others are actually idle and still accounted as active because of the lazy idle detection. Then if wake_batch is > hctx_max_depth, driver tag allocation may wait forever on this real active hctx. Correct me if my understanding is wrong. > > Fix this by recalculating wake_batch when inc or dec active_queues. > > Fixes: 0d2602ca30e41 ("blk-mq: improve support for shared tags maps") > Signed-off-by: Laibin Qiu > --- > block/blk-mq-tag.c | 44 +++++++++++++++++++++++++++++++++++++++-- > include/linux/sbitmap.h | 8 ++++++++ > lib/sbitmap.c | 3 ++- > 3 files changed, 52 insertions(+), 3 deletions(-) > > diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c > index 86f87346232a..d02f5ac0004c 100644 > --- a/block/blk-mq-tag.c > +++ b/block/blk-mq-tag.c > @@ -16,6 +16,27 @@ > #include "blk-mq-sched.h" > #include "blk-mq-tag.h" > > +static void bt_update_wake_batch(struct sbitmap_queue *bt, unsigned int users) > +{ > + unsigned int depth; > + > + depth = max((bt->sb.depth + users - 1) / users, 4U); > + sbitmap_queue_update_wake_batch(bt, depth); > +} Use the hctx's max queue depth could reduce wake_batch a lot, then performance may be degraded. Just wondering why not set sbq->wake_batch as hctx_max_depth if sbq->wake_batch is < hctx_max_depth? Thanks, Ming