Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1273312pxb; Fri, 21 Jan 2022 14:02:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyn8Av4o/9+z7NfQl3Jy9OcFdE8EgA/1wcyaNSOHknlOT7HATK/HwIrNLBkeFKK5/3riQjE X-Received: by 2002:a17:902:7c0b:b0:149:711b:2588 with SMTP id x11-20020a1709027c0b00b00149711b2588mr5265277pll.65.1642802572701; Fri, 21 Jan 2022 14:02:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642802572; cv=none; d=google.com; s=arc-20160816; b=yzZmy9vpzIlLgGHr4ATZ6vFo80YIbio6fv6OobWFKmThGL3ko947te/81b8fLV3rPT IA+yP8z9No8by+bwA+bd3VM31WYOU3cly5onM6Ddhlf61OGCyORCy/h3UyakjF1r+RaU vEO0f4rlM1sZ8v1bLofWQqvbkjgQDsg0IicVfFYteOyMIwLwD4G5CjCZtssKt5ua4W5t LO0mTjhq1qrcZw6JtV9eNP+Zf/0uCZ9cMkvVDCkAoYNWd8zJt/GAgWaF7iv+y5eIssPD 80R7/3X7aEmAWnIprsZ3kr0EYvlfImA5fLg2uDNcsM5gH3mkTxO3i/U3IZcKa6XivvAV yRAg== 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=HnjzfSKHnTIW/FDreC+CYQQVdtBa2Yo1in7OBWnPmf0=; b=VWRrtDVaCEf00PYuNGuB2ZitcGSR8xkvOP1HI8UukvqFse58Bhac4b96z+T9zo/5wW FGv+bz48BY0MTVJP0C2T8vg7f3YOdXREAte+5jS8SqOKzL8t01hypHtME60wQL2mE/7W 0Cn1i2d9ay+3MpE6TCigj82zEEvc5Ig4oRJNN11Kv0JOkBRo6Qjx9zS2t8nST6kYfKnO AXYKHmmwEZ2kDKtp3MsMOvooteqM+EGynYmQuU5060mRlNUOjerH0IkVCaWkrreY7jim tlzU9q/rcp3dsoSq1W/oKJHAFmQ3NCPdAS0TaJnH5uM18rEEQqHNYiwlPlof5yO8aryU aIBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CQn/np9R"; 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 v9si6621740plp.304.2022.01.21.14.02.41; Fri, 21 Jan 2022 14:02:52 -0800 (PST) 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="CQn/np9R"; 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 S244104AbiATM4X (ORCPT + 99 others); Thu, 20 Jan 2022 07:56:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31133 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243904AbiATM4T (ORCPT ); Thu, 20 Jan 2022 07:56:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642683379; 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=HnjzfSKHnTIW/FDreC+CYQQVdtBa2Yo1in7OBWnPmf0=; b=CQn/np9RfwxSPsi9545CTTPyXBC6JueCpefCSpNHM2H+EbRwyXw+zMbMTRniNKDD9vIiL0 iYrJI5L3IsN5JZRRwqWtaYQwahO1/h9YweoSwRXfMU3/2vDb4Klmvi65MCFyShcRCOMERR IbC5R+Ybalrgy58NdAlgscWJS65JB6I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-539-L3eZGrybOe6NN07JrSBFNg-1; Thu, 20 Jan 2022 07:56:14 -0500 X-MC-Unique: L3eZGrybOe6NN07JrSBFNg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 996668144E1; Thu, 20 Jan 2022 12:56:12 +0000 (UTC) Received: from T590 (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01FDB7D72C; Thu, 20 Jan 2022 12:56:07 +0000 (UTC) Date: Thu, 20 Jan 2022 20:56:03 +0800 From: Ming Lei To: Daniel Wagner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Axboe , Hannes Reinecke Subject: Re: [PATCH 2/2] block: hold queue lock while iterating in diskstats_show Message-ID: References: <20220120105248.117025-1-dwagner@suse.de> <20220120105248.117025-3-dwagner@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220120105248.117025-3-dwagner@suse.de> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 11:52:48AM +0100, Daniel Wagner wrote: > The request queues can be freed while we operate on them. Make sure we It shouldn't be freed here. > hold a reference when using blk_mq_queue_tag_busy_iter. > > RIP: blk_mq_queue_tag_busy_iter Any chance to pose the whole stack trace? > Call Trace: > ? blk_mq_hctx_mark_pending > ? diskstats_show > ? blk_mq_hctx_mark_pending > blk_mq_in_flight > diskstats_show > ? klist_next > seq_read > proc_reg_read > vfs_read > ksys_read > do_syscall_64 > entry_SYSCALL_64_after_hwframe > > Signed-off-by: Daniel Wagner > --- > block/genhd.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/block/genhd.c b/block/genhd.c > index c9d4386dd177..0e163055a4e6 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -1167,10 +1167,13 @@ static int diskstats_show(struct seq_file *seqf, void *v) > if (bdev_is_partition(hd) && !bdev_nr_sectors(hd)) > continue; > part_stat_read_all(hd, &stat); > + if (blk_queue_enter(gp->queue, BLK_MQ_REQ_NOWAIT)) > + continue; The disk device's refcnt is supposed to be grabbed by class device iterator code, so queue shouldn't be released in diskstats_show(). Not mention blk_queue_enter() won't prevent disk from being released... thanks, Ming