From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C115817C8 for ; Sun, 4 Jun 2023 00:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685839658; 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=XL9m4/QrEyoU43AAPUnZxDdKBE2GdTGoILFW1/x9cuo=; b=dekco/RjQGSXt6udNlOUyyRf2IVYXuCeogxObJBi7grwerZnx19Rxl1fF3pPaXqQVZ2LYu dZRnOVE0wGqP0cgd0D1VcTPyfl2jXkoWEySTyD/gFAAjqvpzufXmsX9QNYatXTQTmGRPAj nUN19AAJoHSjNTYRV9vT7D0JHdUIiHc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-18-MhiJLfrENMunlBSWq1YHXg-1; Sat, 03 Jun 2023 20:47:35 -0400 X-MC-Unique: MhiJLfrENMunlBSWq1YHXg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4250380673B; Sun, 4 Jun 2023 00:47:34 +0000 (UTC) Received: from ovpn-8-19.pek2.redhat.com (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C5052166B25; Sun, 4 Jun 2023 00:47:28 +0000 (UTC) Date: Sun, 4 Jun 2023 08:47:24 +0800 From: Ming Lei To: Tian Lan Cc: axboe@kernel.dk, horms@kernel.org, linux-block@vger.kernel.org, lkp@intel.com, llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, tian.lan@twosigma.com, Hannes Reinecke , stable@vger.kernel.org Subject: Re: [PATCH] blk-mq: fix blk_mq_hw_ctx active request accounting Message-ID: References: <20230603223912.827913-1-tilan7663@gmail.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230603223912.827913-1-tilan7663@gmail.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 On Sat, Jun 03, 2023 at 06:39:12PM -0400, Tian Lan wrote: > From: Tian Lan > > The nr_active counter continues to increase over time which causes the > blk_mq_get_tag to hang until the thread is rescheduled to a different > core despite there are still tags available. > > kernel-stack > > INFO: task inboundIOReacto:3014879 blocked for more than 2 seconds > Not tainted 6.1.15-amd64 #1 Debian 6.1.15~debian11 > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > task:inboundIORe state:D stack:0 pid:3014879 ppid:4557 flags:0x00000000 > Call Trace: > > __schedule+0x351/0xa20 > scheduler+0x5d/0xe0 > io_schedule+0x42/0x70 > blk_mq_get_tag+0x11a/0x2a0 > ? dequeue_task_stop+0x70/0x70 > __blk_mq_alloc_requests+0x191/0x2e0 > > kprobe output showing RQF_MQ_INFLIGHT bit is not cleared before > __blk_mq_free_request being called. > > 320 320 kworker/29:1H __blk_mq_free_request rq_flags 0x220c0 > b'__blk_mq_free_request+0x1 [kernel]' > b'bt_iter+0x50 [kernel]' > b'blk_mq_queue_tag_busy_iter+0x318 [kernel]' > b'blk_mq_timeout_work+0x7c [kernel]' > b'process_one_work+0x1c4 [kernel]' > b'worker_thread+0x4d [kernel]' > b'kthread+0xe6 [kernel]' > b'ret_from_fork+0x1f [kernel]' > > This issue arises when both bt_iter() and blk_mq_end_request_batch() > are iterating on the same request. The leak happens when > blk_mq_find_and_get_req() is executed(from bt_iter) before > req_ref_put_and_test() gets called by blk_mq_end_request_batch(). > And because non-flush request freed by blk_mq_put_rq_ref() bypasses the > active request tracking, the counter would slowly leak overtime. > > Fixes: f794f3351f26 ("block: add support for blk_mq_end_request_batch()") f794f3351f26 is merged to v5.16, and the leak starts. > Fixes: 2e315dc07df0 ("blk-mq: grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter") 2e315dc07df0 is merged to v5.14, when everything is just fine. Both two aren't marked as -stable, so 'Fixes: 2e315dc07df0' is actually not correct. thanks, Ming