From patchwork Sun Feb 9 12:20:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966859 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 4A6FC13D28F for ; Sun, 9 Feb 2025 12:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103664; cv=none; b=Xe6LExMiZQMG3PFL8Z20mWkadyAAg46Edlh8n79ge022nlwh76xcq+uIY3poDNdgajg5F1bhMCrKqEm8CVDtOwUgz/z0gghQ1WWonlmRE9xStwJqUxGbj9E4aGo5R2obxFqzzGwPOJLB1MzAipETzNcODTmo3FaNuHJHICKAY80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103664; c=relaxed/simple; bh=DEdkhJoaZa9Oip23tyYq6N6EVlLfc2dj47FH++LaxYI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J1EAKIaOKeFA2hMErKx/29V6YELFft7LwFpH/hrHTvhHDXnpZQ/rDJARbDg654y5271qHCgTMat/nuy0G5L+crIV4NWd+yeE74uNME4a1ywJZjspvTamxgIFjB3WCqFsuxx/T00/ZMVEgFm9htmOBc2aqlJLwxwDN6flZbWEacE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ExDbVtAn; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ExDbVtAn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BlbW6NkLpKRKs2CyKKIo+1aczqF1MbmxnRxNQ1PFD90=; b=ExDbVtAnVk8eG4vTQ0hF4qUWVg/dknLamK5+fsqSg9XB+0VbAH4+zJsWHFUol4xwxtT9KW Wy01R8GlzwHm6CpopiEGtQKaB3QouOtaCJuOjvPJBfvmvW+BdWHwX5+UXZe9n/tG7iZEto bI/K+jG/IeTaBvoM/qoEcUr1wDeAtc0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-ezgko9HpOqGv-2P6Zbwl1g-1; Sun, 09 Feb 2025 07:20:57 -0500 X-MC-Unique: ezgko9HpOqGv-2P6Zbwl1g-1 X-Mimecast-MFC-AGG-ID: ezgko9HpOqGv-2P6Zbwl1g Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5EC37195608C; Sun, 9 Feb 2025 12:20:56 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D918B1800267; Sun, 9 Feb 2025 12:20:54 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 1/7] block: remove hctx->debugfs_dir Date: Sun, 9 Feb 2025 20:20:25 +0800 Message-ID: <20250209122035.1327325-2-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 For each hctx, its debugfs path is fixed, which can be queried from its parent dentry and hctx queue num, so it isn't necessary to cache it in hctx structure because it isn't used in fast path. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 47 ++++++++++++++++++++++++++++++++---------- include/linux/blk-mq.h | 5 ----- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index adf5f0697b6b..16260bba4d11 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -633,8 +633,7 @@ void blk_mq_debugfs_register(struct request_queue *q) /* Similarly, blk_mq_init_hctx() couldn't do this previously. */ queue_for_each_hw_ctx(q, hctx, i) { - if (!hctx->debugfs_dir) - blk_mq_debugfs_register_hctx(q, hctx); + blk_mq_debugfs_register_hctx(q, hctx); if (q->elevator && !hctx->sched_debugfs_dir) blk_mq_debugfs_register_sched_hctx(q, hctx); } @@ -649,14 +648,28 @@ void blk_mq_debugfs_register(struct request_queue *q) } } +static __must_check struct dentry *blk_mq_get_hctx_entry( + struct blk_mq_hw_ctx *hctx) +{ + char name[20]; + + snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); + return debugfs_lookup(name, hctx->queue->debugfs_dir); +} + static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx) { + struct dentry *hctx_dir = blk_mq_get_hctx_entry(hctx); struct dentry *ctx_dir; char name[20]; + if (IS_ERR_OR_NULL(hctx_dir)) + return; + snprintf(name, sizeof(name), "cpu%u", ctx->cpu); - ctx_dir = debugfs_create_dir(name, hctx->debugfs_dir); + ctx_dir = debugfs_create_dir(name, hctx_dir); + dput(hctx_dir); debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs); } @@ -664,6 +677,7 @@ static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, void blk_mq_debugfs_register_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx) { + struct dentry *hctx_dir; struct blk_mq_ctx *ctx; char name[20]; int i; @@ -672,9 +686,11 @@ void blk_mq_debugfs_register_hctx(struct request_queue *q, return; snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); - hctx->debugfs_dir = debugfs_create_dir(name, q->debugfs_dir); + hctx_dir = debugfs_create_dir(name, q->debugfs_dir); + if (IS_ERR_OR_NULL(hctx_dir)) + return; - debugfs_create_files(hctx->debugfs_dir, hctx, blk_mq_debugfs_hctx_attrs); + debugfs_create_files(hctx_dir, hctx, blk_mq_debugfs_hctx_attrs); hctx_for_each_ctx(hctx, ctx, i) blk_mq_debugfs_register_ctx(hctx, ctx); @@ -682,11 +698,18 @@ void blk_mq_debugfs_register_hctx(struct request_queue *q, void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) { + struct dentry *hctx_dir; + if (!hctx->queue->debugfs_dir) return; - debugfs_remove_recursive(hctx->debugfs_dir); + + hctx_dir = blk_mq_get_hctx_entry(hctx); + if (IS_ERR_OR_NULL(hctx_dir)) + return; + + debugfs_remove_recursive(hctx_dir); hctx->sched_debugfs_dir = NULL; - hctx->debugfs_dir = NULL; + dput(hctx_dir); } void blk_mq_debugfs_register_hctxs(struct request_queue *q) @@ -780,6 +803,7 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx) { + struct dentry *hctx_dir = blk_mq_get_hctx_entry(hctx); struct elevator_type *e = q->elevator->type; lockdep_assert_held(&q->debugfs_mutex); @@ -789,16 +813,17 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, * We will be called again later on with appropriate parent debugfs * directory from blk_register_queue() */ - if (!hctx->debugfs_dir) + if (IS_ERR_OR_NULL(hctx_dir)) return; if (!e->hctx_debugfs_attrs) - return; + goto exit; - hctx->sched_debugfs_dir = debugfs_create_dir("sched", - hctx->debugfs_dir); + hctx->sched_debugfs_dir = debugfs_create_dir("sched", hctx_dir); debugfs_create_files(hctx->sched_debugfs_dir, hctx, e->hctx_debugfs_attrs); +exit: + dput(hctx_dir); } void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 9ebb53f031cd..8c8682491403 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -427,11 +427,6 @@ struct blk_mq_hw_ctx { struct kobject kobj; #ifdef CONFIG_BLK_DEBUG_FS - /** - * @debugfs_dir: debugfs directory for this hardware queue. Named - * as cpu. - */ - struct dentry *debugfs_dir; /** @sched_debugfs_dir: debugfs directory for the scheduler. */ struct dentry *sched_debugfs_dir; #endif From patchwork Sun Feb 9 12:20:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966860 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 CB14618132A for ; Sun, 9 Feb 2025 12:21:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103666; cv=none; b=GyKHl6w57SAYLUfPaGCBwzGDcBof6TjIeYmhcZuG9dNeEXOCRJ534wF/6rQ6nBB5qHUvzwuvcaTpwhb0zGWy7/LznNZw8bbvwMP0wU9HlYmDtP30W48u5x1GcTjbVHXPUCFBkmWWwirjXyv2zMbgJG7+X//e7BPZ+QscPMYiCJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103666; c=relaxed/simple; bh=SSXGUU8ButB/RNBdttiqvE0/fHfOdEpqLf8EipzIjME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=quADGdLQesHo9H/QI7Xm0E29lhQufAZOfKXv48fF1SIyJkS2r3wYCOPAcCO73x5j8IVkIbC1b9sh+ibssy5nwomfddfoyOt67vGqok0Yuuq5M10VgOJecYcmS+POzYsXSO8t+tptN13pDXHI42Au1by2UOnHMzCKKJ5RbH9HLjs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ICnLDgyS; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ICnLDgyS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ir8Tsi10g9Su1R1sfRreEALH3yhmQaDXa9ngfyHmWwo=; b=ICnLDgyS7/PO5pVOT3riNEL3KzlG0Alc+mob2KeV7s60NIk/S7goJooU2Swukq8w3tvWOZ uB5vHAwNlwme741fiqwNmjN3sXkDy8zi6v2PakubuWWGjgcXylW/VZmg8FMVjvSPJEvFxq IeBykMv9FYAfZ2YcN/fOJDuSsu5zaTs= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-kRFkwGODNvu2RQJDYVcdUw-1; Sun, 09 Feb 2025 07:21:02 -0500 X-MC-Unique: kRFkwGODNvu2RQJDYVcdUw-1 X-Mimecast-MFC-AGG-ID: kRFkwGODNvu2RQJDYVcdUw Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E24AF1800876; Sun, 9 Feb 2025 12:21:00 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E2B2630001AB; Sun, 9 Feb 2025 12:20:59 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 2/7] block: remove hctx->sched_debugfs_dir Date: Sun, 9 Feb 2025 20:20:26 +0800 Message-ID: <20250209122035.1327325-3-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 For each hctx, its sched debugfs path is fixed, which can be queried from its parent dentry directly, so it isn't necessary to cache it in hctx instance because it isn't used in fast path. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 31 ++++++++++++++++++++++++------- include/linux/blk-mq.h | 5 ----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 16260bba4d11..3abb38ea2577 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -634,7 +634,7 @@ void blk_mq_debugfs_register(struct request_queue *q) /* Similarly, blk_mq_init_hctx() couldn't do this previously. */ queue_for_each_hw_ctx(q, hctx, i) { blk_mq_debugfs_register_hctx(q, hctx); - if (q->elevator && !hctx->sched_debugfs_dir) + if (q->elevator) blk_mq_debugfs_register_sched_hctx(q, hctx); } @@ -657,6 +657,19 @@ static __must_check struct dentry *blk_mq_get_hctx_entry( return debugfs_lookup(name, hctx->queue->debugfs_dir); } +static __must_check struct dentry *blk_mq_get_hctx_sched_entry( + struct blk_mq_hw_ctx *hctx) +{ + struct dentry *hctx_dir = blk_mq_get_hctx_entry(hctx); + struct dentry *sched_dir = NULL; + + if (hctx_dir) { + sched_dir = debugfs_lookup("sched", hctx_dir); + dput(hctx_dir); + } + return sched_dir; +} + static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx) { @@ -708,7 +721,6 @@ void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) return; debugfs_remove_recursive(hctx_dir); - hctx->sched_debugfs_dir = NULL; dput(hctx_dir); } @@ -805,6 +817,7 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, { struct dentry *hctx_dir = blk_mq_get_hctx_entry(hctx); struct elevator_type *e = q->elevator->type; + struct dentry *sched_dir; lockdep_assert_held(&q->debugfs_mutex); @@ -819,19 +832,23 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, if (!e->hctx_debugfs_attrs) goto exit; - hctx->sched_debugfs_dir = debugfs_create_dir("sched", hctx_dir); - debugfs_create_files(hctx->sched_debugfs_dir, hctx, - e->hctx_debugfs_attrs); + sched_dir = debugfs_create_dir("sched", hctx_dir); + debugfs_create_files(sched_dir, hctx, e->hctx_debugfs_attrs); exit: dput(hctx_dir); } void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) { + struct dentry *sched_dir; + lockdep_assert_held(&hctx->queue->debugfs_mutex); if (!hctx->queue->debugfs_dir) return; - debugfs_remove_recursive(hctx->sched_debugfs_dir); - hctx->sched_debugfs_dir = NULL; + sched_dir = blk_mq_get_hctx_sched_entry(hctx); + if (sched_dir) { + debugfs_remove_recursive(sched_dir); + dput(sched_dir); + } } diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 8c8682491403..965aeea75ddd 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -426,11 +426,6 @@ struct blk_mq_hw_ctx { /** @kobj: Kernel object for sysfs. */ struct kobject kobj; -#ifdef CONFIG_BLK_DEBUG_FS - /** @sched_debugfs_dir: debugfs directory for the scheduler. */ - struct dentry *sched_debugfs_dir; -#endif - /** * @hctx_list: if this hctx is not in use, this is an entry in * q->unused_hctx_list. From patchwork Sun Feb 9 12:20:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966861 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 C7EEC18132A for ; Sun, 9 Feb 2025 12:21:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103674; cv=none; b=ZHivYznVKuXK8KpsWkNgXtzkKvDYRG3z5uqIfsZ2A30psKaHMikXpxT6Vg1vkhvqk3TCBJMfvSqmp8iQjPQN6j0FNpoc10UKK+J7wGchkAnNrBrVxOosvOH1PxkssqRKJL/+q9/0D9FlV9oghRH2k9fhorecCqhq6vP1sqx/mw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103674; c=relaxed/simple; bh=sLKiBRrQzliZS5EauWutuXQcJMgKBXS5dTyqBWUbmv8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HWCiEpmB4Zi0IC12AQGRTbEdj8XCySvgzDnL9yiFdlsDaTfblob9nhyxmjyy1qPTId0BlBN60nSGcn3KDxQKV3oB6ffg398s8kWKiAktZsS1MBlkWw94MijazP7COOmiuqR1msAfyJZJE4DlouT8e8T9zNU5MZIcRdAzxLw/LzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FfkKC6bE; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FfkKC6bE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9zM0LxXjIcrRWYRqpl5YfwCfb8GR7Xn5MKtORf1nwdo=; b=FfkKC6bEb5RWP8tB9rtG+rxyEudb3KNKa/u1O+39E7+ckW4YZLKJjrb2MLzC6Zw/x1AExj A9Z88kXcx007x82jRjvPlQqKfLbFyItEH7127q9YHbrvZy5AIE7WaWcYOyXLHRmliAftkN 2N614N9innPD2hgUtINOKw/52zot37w= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-547-BqqQMo-QNAm6JS9I6CHSbg-1; Sun, 09 Feb 2025 07:21:07 -0500 X-MC-Unique: BqqQMo-QNAm6JS9I6CHSbg-1 X-Mimecast-MFC-AGG-ID: BqqQMo-QNAm6JS9I6CHSbg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D78E1800374; Sun, 9 Feb 2025 12:21:06 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8FF6F1956094; Sun, 9 Feb 2025 12:21:03 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 3/7] block: remove q->sched_debugfs_dir Date: Sun, 9 Feb 2025 20:20:27 +0800 Message-ID: <20250209122035.1327325-4-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 For each request_queue, its sched debugfs path is fixed, which can be queried from its parent dentry directly, so it isn't necessary to cache it in request_queue instance because it isn't used in fast path. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 10 +++++----- block/blk-sysfs.c | 1 - include/linux/blkdev.h | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 3abb38ea2577..3d3346fc4c4e 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -628,7 +628,7 @@ void blk_mq_debugfs_register(struct request_queue *q) * didn't exist yet (because we don't know what to name the directory * until the queue is registered to a gendisk). */ - if (q->elevator && !q->sched_debugfs_dir) + if (q->elevator) blk_mq_debugfs_register_sched(q); /* Similarly, blk_mq_init_hctx() couldn't do this previously. */ @@ -745,6 +745,7 @@ void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) void blk_mq_debugfs_register_sched(struct request_queue *q) { struct elevator_type *e = q->elevator->type; + struct dentry *sched_dir; lockdep_assert_held(&q->debugfs_mutex); @@ -758,17 +759,16 @@ void blk_mq_debugfs_register_sched(struct request_queue *q) if (!e->queue_debugfs_attrs) return; - q->sched_debugfs_dir = debugfs_create_dir("sched", q->debugfs_dir); + sched_dir = debugfs_create_dir("sched", q->debugfs_dir); - debugfs_create_files(q->sched_debugfs_dir, q, e->queue_debugfs_attrs); + debugfs_create_files(sched_dir, q, e->queue_debugfs_attrs); } void blk_mq_debugfs_unregister_sched(struct request_queue *q) { lockdep_assert_held(&q->debugfs_mutex); - debugfs_remove_recursive(q->sched_debugfs_dir); - q->sched_debugfs_dir = NULL; + debugfs_lookup_and_remove("sched", q->debugfs_dir); } static const char *rq_qos_id_to_name(enum rq_qos_id id) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 6f548a4376aa..35d92ed10fdb 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -748,7 +748,6 @@ static void blk_debugfs_remove(struct gendisk *disk) blk_trace_shutdown(q); debugfs_remove_recursive(q->debugfs_dir); q->debugfs_dir = NULL; - q->sched_debugfs_dir = NULL; q->rqos_debugfs_dir = NULL; mutex_unlock(&q->debugfs_mutex); } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 248416ecd01c..5efe6f00d86f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -598,7 +598,6 @@ struct request_queue { struct list_head tag_set_list; struct dentry *debugfs_dir; - struct dentry *sched_debugfs_dir; struct dentry *rqos_debugfs_dir; /* * Serializes all debugfs metadata operations using the above dentries. From patchwork Sun Feb 9 12:20:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966862 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 535861D5170 for ; Sun, 9 Feb 2025 12:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103677; cv=none; b=RgdXFPfhkTTP0s4J0B6eH+pbVr+dSZiMSbK58W92Kdu1N9Yub8hpk0faK2C5GpWILOuTdxyKGG0T+b64YmjmbkWVt6oKvC0TFHQYW2DI8lnG0LaBiO9tFmCT3B+w56GxhxalThNLJ6iExrxs4VsImeXb+6pDy+ohYKSqpQVpiLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103677; c=relaxed/simple; bh=AfNgNKKDZM9ZM3mzHEmSiah6JxqWVzP7XPxmWxqUGkc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VkfTAzgDnpxy/Z9fg5WIuyxFX+r/9pXYmlNcd0XV/obJfSsUhq4q/WZ5MKyiTVP5DgD446K9kPWrpf09bcjAo/Th4MLTKwk+0CFl4YIp4p3vMoE7ov/wptFWwXcag2ZAtRYVqAzieLds3+8ddeMZGRAKWi5UICq446doypEXzxs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GBeWviFZ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GBeWviFZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ezmciec7ag/xJTN47wZ9wFBbwQakbRbuYurnXAEVsJw=; b=GBeWviFZse89ahCeJk16ZDH/Oxmou4P9IndoZKiiweyPk1vi/KvlWDZpL1WMjg9GpXCWco UBJIpg35+5EHZ456RdX6JuiWhcXz3Az6OrMrV+Xsolf3OYU4uPBneDBmi3fS3ott4N5DXo LUeun33ONTHubK9J4/5jAJvFATWMY6Y= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-3bS3kezwN-qd0f5mIhotNQ-1; Sun, 09 Feb 2025 07:21:11 -0500 X-MC-Unique: 3bS3kezwN-qd0f5mIhotNQ-1 X-Mimecast-MFC-AGG-ID: 3bS3kezwN-qd0f5mIhotNQ Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A43501800268; Sun, 9 Feb 2025 12:21:10 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C0D9180087A; Sun, 9 Feb 2025 12:21:08 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 4/7] block: remove q->rqos_debugfs_dir Date: Sun, 9 Feb 2025 20:20:28 +0800 Message-ID: <20250209122035.1327325-5-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 For each request_queue, its rqos debugfs path is fixed, which can be queried from its parent dentry directly, so it isn't necessary to cache it in request_queue instance because it isn't used in fast path. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 12 ++++++++---- block/blk-sysfs.c | 1 - include/linux/blkdev.h | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 3d3346fc4c4e..9ccaf506514e 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -638,6 +638,8 @@ void blk_mq_debugfs_register(struct request_queue *q) blk_mq_debugfs_register_sched_hctx(q, hctx); } + debugfs_create_dir("rqos", q->debugfs_dir); + if (q->rq_qos) { struct rq_qos *rqos = q->rq_qos; @@ -798,17 +800,19 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) { struct request_queue *q = rqos->disk->queue; const char *dir_name = rq_qos_id_to_name(rqos->id); + struct dentry *rqos_top; lockdep_assert_held(&q->debugfs_mutex); if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) return; - if (!q->rqos_debugfs_dir) - q->rqos_debugfs_dir = debugfs_create_dir("rqos", - q->debugfs_dir); + rqos_top = debugfs_lookup("rqos", q->debugfs_dir); + if (IS_ERR_OR_NULL(rqos_top)) + return; - rqos->debugfs_dir = debugfs_create_dir(dir_name, q->rqos_debugfs_dir); + rqos->debugfs_dir = debugfs_create_dir(dir_name, rqos_top); + dput(rqos_top); debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs); } diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 35d92ed10fdb..0679116bb195 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -748,7 +748,6 @@ static void blk_debugfs_remove(struct gendisk *disk) blk_trace_shutdown(q); debugfs_remove_recursive(q->debugfs_dir); q->debugfs_dir = NULL; - q->rqos_debugfs_dir = NULL; mutex_unlock(&q->debugfs_mutex); } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 5efe6f00d86f..7663f0c482de 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -598,7 +598,6 @@ struct request_queue { struct list_head tag_set_list; struct dentry *debugfs_dir; - struct dentry *rqos_debugfs_dir; /* * Serializes all debugfs metadata operations using the above dentries. */ From patchwork Sun Feb 9 12:20:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966863 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 2773F18132A for ; Sun, 9 Feb 2025 12:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103684; cv=none; b=qXdX6693CrWOC/Q1vzSzePQbBgRtWhN8Al6/ggiGhUvnFirH5XqdPVMqQE1s8Qex6ckt7lfQiSljBcyLnpMzP/LgBg/XFou0GpeXLVxnNHiIppJN/N2SuRZHQys0v0ryOqjvI/nF4ggoAZACVzJJbnIt9hLV2XvzFyYoZoV6O9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103684; c=relaxed/simple; bh=ZVLyiR1o3f19kGBvpBGZzV9I2kgiaoBZJZoV73DKs3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pLgUdI5TRnb6ufzeVPdsSIOVzbY9+90dH2fiivnWRBNXVzhJ3KzjJ2fMcn7FTLnqatREWvAKFnZSlmSO4haDi1FWTyx9iEmaN6sBhOKB7ouDZaFLd8q58+zDqr2vddc3iTXdLYZrYkICQeMbtPDsiMErq400UXlK6pfah9tllkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N7wPAzPm; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N7wPAzPm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TgNDisvTIx0HrETNPEbhoWdWx+G0dcVlCMSfhjbPwZI=; b=N7wPAzPmqJdmKVs5fBt56ixT4WP6DvexL9Gp7BbAjBZXADC1yB3pbUZGQIpTzhMng9DZW8 COrNJked9pg3pslSnqdTUXwuX55hX7pM7mX8rVGdrhNGXr+c0FEnbiFArxuAlGvJFbImE6 hv0qHj4zs8aynuWRHFW5CNro0P3uZ5c= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-358-a5L7ZNmLM0GuzAbsPyE20Q-1; Sun, 09 Feb 2025 07:21:16 -0500 X-MC-Unique: a5L7ZNmLM0GuzAbsPyE20Q-1 X-Mimecast-MFC-AGG-ID: a5L7ZNmLM0GuzAbsPyE20Q Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 955891800873; Sun, 9 Feb 2025 12:21:15 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 54F1730001AB; Sun, 9 Feb 2025 12:21:13 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 5/7] block: remove rqos->debugfs_dir Date: Sun, 9 Feb 2025 20:20:29 +0800 Message-ID: <20250209122035.1327325-6-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 For each rqos instance, its debugfs path is fixed, which can be queried from its parent dentry & rqos name directly, so it isn't necessary to cache it in rqos instance because it isn't used in fast path. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 30 ++++++++++++++++++++++-------- block/blk-rq-qos.h | 3 --- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 9ccaf506514e..40eb104fc1d5 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -786,14 +786,27 @@ static const char *rq_qos_id_to_name(enum rq_qos_id id) return "unknown"; } +static __must_check struct dentry *blk_mq_debugfs_get_rqos_top( + struct request_queue *q) +{ + return debugfs_lookup("rqos", q->debugfs_dir); +} + void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) { - lockdep_assert_held(&rqos->disk->queue->debugfs_mutex); + struct request_queue *q = rqos->disk->queue; + struct dentry *rqos_top; + + lockdep_assert_held(&q->debugfs_mutex); + + if (!q->debugfs_dir) + return; - if (!rqos->disk->queue->debugfs_dir) + rqos_top = blk_mq_debugfs_get_rqos_top(q); + if (IS_ERR_OR_NULL(rqos_top)) return; - debugfs_remove_recursive(rqos->debugfs_dir); - rqos->debugfs_dir = NULL; + debugfs_lookup_and_remove(rq_qos_id_to_name(rqos->id), rqos_top); + dput(rqos_top); } void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) @@ -801,19 +814,20 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) struct request_queue *q = rqos->disk->queue; const char *dir_name = rq_qos_id_to_name(rqos->id); struct dentry *rqos_top; + struct dentry *rqos_dir; lockdep_assert_held(&q->debugfs_mutex); - if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) + if (!rqos->ops->debugfs_attrs) return; - rqos_top = debugfs_lookup("rqos", q->debugfs_dir); + rqos_top = blk_mq_debugfs_get_rqos_top(q); if (IS_ERR_OR_NULL(rqos_top)) return; - rqos->debugfs_dir = debugfs_create_dir(dir_name, rqos_top); + rqos_dir = debugfs_create_dir(dir_name, rqos_top); dput(rqos_top); - debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs); + debugfs_create_files(rqos_dir, rqos, rqos->ops->debugfs_attrs); } void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 37245c97ee61..49c31f1e5578 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -29,9 +29,6 @@ struct rq_qos { struct gendisk *disk; enum rq_qos_id id; struct rq_qos *next; -#ifdef CONFIG_BLK_DEBUG_FS - struct dentry *debugfs_dir; -#endif }; struct rq_qos_ops { From patchwork Sun Feb 9 12:20:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966864 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 536DB14885D for ; Sun, 9 Feb 2025 12:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103688; cv=none; b=dIZsmbW3dqPhN8AtWDo18vwxAYWFhDBcSPgDHnNTHgx7z98CSIuVgUchRHzYBVZFJCwF3Kcu3BM2tlnfxWCqwj/weDr9p29bm/pntZSIelGbU/GJGeZRqVpBW+t/McF+84XvlS+Vkr2b2jcl9lXPrdK7PwsiVrcYmYvv5GMqpdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103688; c=relaxed/simple; bh=1SUA5oSQ3LyAmB+Zqt7w7ry2YOfi54OgMjAKSMzZKu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D5gPljR5Ok4daiuHVifPf6KR6N1QOnSEkGjRNYs0gFLdZGonj+P9Xv37jecuaXE0YZAwgMQCyHf+Vw7E0byRZtSRxim0JElUuQlf2v39irNKPD57YOWNk2m/iyiTSKu5oUZH3dglK8FlG/rXwB3CJboSCSeKbeo6TOnSP6H4zyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dIquQ1at; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dIquQ1at" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fbQ4dK4N1DU8LUVoPizsrTjXfHqZpArF+Z+f+IZZTxA=; b=dIquQ1atQOe0HYd3y+DDJmlIgR9VpT3e+QPZ/iJl6C/M5LgXhsMoF0RaLlRUJS16faBPJk vuzTEgowDCcVcNJkjF+gDFuatWQAzmGk7jR2KFyladW/Be1XvOvbJ//RzrOPBHmDylPjSW wH8z0UvNqDeWx8zOMNNHszHOj+aIT7w= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352-R9yv10bqMnSh6J8xqQyJXw-1; Sun, 09 Feb 2025 07:21:21 -0500 X-MC-Unique: R9yv10bqMnSh6J8xqQyJXw-1 X-Mimecast-MFC-AGG-ID: R9yv10bqMnSh6J8xqQyJXw Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C50C218004A7; Sun, 9 Feb 2025 12:21:19 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6D73180087A; Sun, 9 Feb 2025 12:21:18 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 6/7] block: remove q->debugfs_dir Date: Sun, 9 Feb 2025 20:20:30 +0800 Message-ID: <20250209122035.1327325-7-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 For each rqos instance, its debugfs path is fixed, which can be queried from its block debugfs dentry & disk name directly, so it isn't necessary to cache it in request_queue instance because it isn't used in fast path. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 73 ++++++++++++++++++++++++++++++----------- block/blk-sysfs.c | 5 ++- include/linux/blkdev.h | 1 - kernel/trace/blktrace.c | 25 +++++++++++--- 4 files changed, 77 insertions(+), 27 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 40eb104fc1d5..6d98c2a6e7c6 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -616,15 +616,25 @@ static void debugfs_create_files(struct dentry *parent, void *data, (void *)attr, &blk_mq_debugfs_fops); } +static __must_check struct dentry *blk_mq_get_queue_entry( + struct request_queue *q) +{ + return debugfs_lookup(q->disk->disk_name, blk_debugfs_root); +} + void blk_mq_debugfs_register(struct request_queue *q) { + struct dentry *queue_dir = blk_mq_get_queue_entry(q); struct blk_mq_hw_ctx *hctx; unsigned long i; - debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs); + if (IS_ERR_OR_NULL(queue_dir)) + return; + + debugfs_create_files(queue_dir, q, blk_mq_debugfs_queue_attrs); /* - * blk_mq_init_sched() attempted to do this already, but q->debugfs_dir + * blk_mq_init_sched() attempted to do this already, but queue debugfs_dir * didn't exist yet (because we don't know what to name the directory * until the queue is registered to a gendisk). */ @@ -638,7 +648,7 @@ void blk_mq_debugfs_register(struct request_queue *q) blk_mq_debugfs_register_sched_hctx(q, hctx); } - debugfs_create_dir("rqos", q->debugfs_dir); + debugfs_create_dir("rqos", queue_dir); if (q->rq_qos) { struct rq_qos *rqos = q->rq_qos; @@ -648,15 +658,25 @@ void blk_mq_debugfs_register(struct request_queue *q) rqos = rqos->next; } } + + dput(queue_dir); } static __must_check struct dentry *blk_mq_get_hctx_entry( struct blk_mq_hw_ctx *hctx) { + struct dentry *queue_dir = blk_mq_get_queue_entry(hctx->queue); + struct dentry *dir; char name[20]; + if (IS_ERR_OR_NULL(queue_dir)) + return NULL; + snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); - return debugfs_lookup(name, hctx->queue->debugfs_dir); + dir = debugfs_lookup(name, queue_dir); + dput(queue_dir); + + return dir; } static __must_check struct dentry *blk_mq_get_hctx_sched_entry( @@ -692,32 +712,32 @@ static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, void blk_mq_debugfs_register_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx) { + struct dentry *queue_dir = blk_mq_get_queue_entry(q); struct dentry *hctx_dir; struct blk_mq_ctx *ctx; char name[20]; int i; - if (!q->debugfs_dir) + if (IS_ERR_OR_NULL(queue_dir)) return; snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); - hctx_dir = debugfs_create_dir(name, q->debugfs_dir); + hctx_dir = debugfs_create_dir(name, queue_dir); if (IS_ERR_OR_NULL(hctx_dir)) - return; + goto exit; debugfs_create_files(hctx_dir, hctx, blk_mq_debugfs_hctx_attrs); hctx_for_each_ctx(hctx, ctx, i) blk_mq_debugfs_register_ctx(hctx, ctx); +exit: + dput(queue_dir); } void blk_mq_debugfs_unregister_hctx(struct blk_mq_hw_ctx *hctx) { struct dentry *hctx_dir; - if (!hctx->queue->debugfs_dir) - return; - hctx_dir = blk_mq_get_hctx_entry(hctx); if (IS_ERR_OR_NULL(hctx_dir)) return; @@ -746,6 +766,7 @@ void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) void blk_mq_debugfs_register_sched(struct request_queue *q) { + struct dentry *queue_dir = blk_mq_get_queue_entry(q); struct elevator_type *e = q->elevator->type; struct dentry *sched_dir; @@ -755,22 +776,29 @@ void blk_mq_debugfs_register_sched(struct request_queue *q) * If the parent directory has not been created yet, return, we will be * called again later on and the directory/files will be created then. */ - if (!q->debugfs_dir) + if (IS_ERR_OR_NULL(queue_dir)) return; if (!e->queue_debugfs_attrs) - return; + goto exit; - sched_dir = debugfs_create_dir("sched", q->debugfs_dir); + sched_dir = debugfs_create_dir("sched", queue_dir); debugfs_create_files(sched_dir, q, e->queue_debugfs_attrs); +exit: + dput(queue_dir); } void blk_mq_debugfs_unregister_sched(struct request_queue *q) { + struct dentry *queue_dir = blk_mq_get_queue_entry(q); + lockdep_assert_held(&q->debugfs_mutex); - debugfs_lookup_and_remove("sched", q->debugfs_dir); + if (IS_ERR_OR_NULL(queue_dir)) + return; + debugfs_lookup_and_remove("sched", queue_dir); + dput(queue_dir); } static const char *rq_qos_id_to_name(enum rq_qos_id id) @@ -789,24 +817,33 @@ static const char *rq_qos_id_to_name(enum rq_qos_id id) static __must_check struct dentry *blk_mq_debugfs_get_rqos_top( struct request_queue *q) { - return debugfs_lookup("rqos", q->debugfs_dir); + struct dentry *queue_dir = blk_mq_get_queue_entry(q); + struct dentry *dir = NULL; + + if (queue_dir) + dir = debugfs_lookup("rqos", queue_dir); + dput(queue_dir); + return dir; } void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) { struct request_queue *q = rqos->disk->queue; + struct dentry *queue_dir = blk_mq_get_queue_entry(q); struct dentry *rqos_top; lockdep_assert_held(&q->debugfs_mutex); - if (!q->debugfs_dir) + if (IS_ERR_OR_NULL(queue_dir)) return; rqos_top = blk_mq_debugfs_get_rqos_top(q); if (IS_ERR_OR_NULL(rqos_top)) - return; + goto exit; debugfs_lookup_and_remove(rq_qos_id_to_name(rqos->id), rqos_top); dput(rqos_top); +exit: + dput(queue_dir); } void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) @@ -862,8 +899,6 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) lockdep_assert_held(&hctx->queue->debugfs_mutex); - if (!hctx->queue->debugfs_dir) - return; sched_dir = blk_mq_get_hctx_sched_entry(hctx); if (sched_dir) { debugfs_remove_recursive(sched_dir); diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 0679116bb195..68bd84e06aac 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -746,8 +746,7 @@ static void blk_debugfs_remove(struct gendisk *disk) mutex_lock(&q->debugfs_mutex); blk_trace_shutdown(q); - debugfs_remove_recursive(q->debugfs_dir); - q->debugfs_dir = NULL; + debugfs_lookup_and_remove(disk->disk_name, blk_debugfs_root); mutex_unlock(&q->debugfs_mutex); } @@ -773,7 +772,7 @@ int blk_register_queue(struct gendisk *disk) mutex_lock(&q->sysfs_lock); mutex_lock(&q->debugfs_mutex); - q->debugfs_dir = debugfs_create_dir(disk->disk_name, blk_debugfs_root); + debugfs_create_dir(disk->disk_name, blk_debugfs_root); if (queue_is_mq(q)) blk_mq_debugfs_register(q); mutex_unlock(&q->debugfs_mutex); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 7663f0c482de..adde68134ce4 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -597,7 +597,6 @@ struct request_queue { struct blk_mq_tag_set *tag_set; struct list_head tag_set_list; - struct dentry *debugfs_dir; /* * Serializes all debugfs metadata operations using the above dentries. */ diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 3679a6d18934..32cda8f5d008 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -311,17 +311,31 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, local_irq_restore(flags); } +static struct dentry *blk_get_queue_debugfs_dir(struct request_queue *q) +{ + struct dentry *dir = NULL;; + + if (q->disk) + dir = debugfs_lookup(q->disk->disk_name, blk_debugfs_root); + return dir; +} + static void blk_trace_free(struct request_queue *q, struct blk_trace *bt) { relay_close(bt->rchan); /* * If 'bt->dir' is not set, then both 'dropped' and 'msg' are created - * under 'q->debugfs_dir', thus lookup and remove them. + * under block queue debugfs dir, thus lookup and remove them. */ if (!bt->dir) { - debugfs_lookup_and_remove("dropped", q->debugfs_dir); - debugfs_lookup_and_remove("msg", q->debugfs_dir); + struct dentry *dir = blk_get_queue_debugfs_dir(q); + + if (!IS_ERR_OR_NULL(dir)) { + debugfs_lookup_and_remove("dropped", dir); + debugfs_lookup_and_remove("msg", dir); + dput(dir); + } } else { debugfs_remove(bt->dir); } @@ -517,6 +531,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, { struct blk_trace *bt = NULL; struct dentry *dir = NULL; + struct dentry *dir_to_drop = NULL; int ret; lockdep_assert_held(&q->debugfs_mutex); @@ -563,7 +578,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, * directory that will be removed once the trace ends. */ if (bdev && !bdev_is_partition(bdev)) - dir = q->debugfs_dir; + dir_to_drop = dir = blk_get_queue_debugfs_dir(q); else bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root); @@ -614,6 +629,8 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, err: if (ret) blk_trace_free(q, bt); + if (!IS_ERR_OR_NULL(dir_to_drop)) + dput(dir_to_drop); return ret; } From patchwork Sun Feb 9 12:20:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13966865 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 95A1113D28F for ; Sun, 9 Feb 2025 12:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103692; cv=none; b=PGUNWyVk+apTSIukBm2gkVezceRqapNcoC70YrPR7tmrhWqRtTV83ekiD/Pu8FBe3I3/h8HmbyPCM0HA7dG7TyA5FWDMM8+jFfA+b4bJZcpXqAkNEBxHgWsTqdAH/p66Na9hh192gAj2F1Pyg+hpOwjn5xKk/jS4NpYcBdy3D0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739103692; c=relaxed/simple; bh=RE6+26sA268ejnWTVotebq0zmGe987wJUrx+7uoppkw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=owNiKRin7Es1bBGLzEUZl3z7j5/TKyDxQgDIva7KA5nQct1wdQfV659s/263CAAF7SwIj6nZUF/TMg/kHYv4eFNYa6I1oxytR5r1sUbGmnhAX1CUxLhUVvaVNW4yRbkM/eZFnUd2u0vAY3w1z/E+/rzpEYigPTgVAgcItBLAfIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AW1Qs5B5; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AW1Qs5B5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739103689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kWIoHiz2awyXmVeZbGLuG1ySnYN09kxBetSD+HavMj8=; b=AW1Qs5B5iAux9bkOEXLX46vvCsLij+XeM80AjyBVX6wOuAJqnVInr7UnDtZ4WFqSiTyO7T pJhMfPvs2+X9QtrHya3qYTahCbIxd6rKAYnNsIQ7SKo2X+ycq0+RmMEoJjPrHabO7lqLp2 cs/KxUa9B6PqToaNZbc1hY/oZ/11n/U= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-275-5wkc_G91NfyKY70H1F7Vww-1; Sun, 09 Feb 2025 07:21:26 -0500 X-MC-Unique: 5wkc_G91NfyKY70H1F7Vww-1 X-Mimecast-MFC-AGG-ID: 5wkc_G91NfyKY70H1F7Vww Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E1B3180034A; Sun, 9 Feb 2025 12:21:25 +0000 (UTC) Received: from localhost (unknown [10.72.116.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 077581800265; Sun, 9 Feb 2025 12:21:22 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Nilay Shroff , Shinichiro Kawasaki , Ming Lei Subject: [PATCH 7/7] block: don't grab q->debugfs_mutex Date: Sun, 9 Feb 2025 20:20:31 +0800 Message-ID: <20250209122035.1327325-8-ming.lei@redhat.com> In-Reply-To: <20250209122035.1327325-1-ming.lei@redhat.com> References: <20250209122035.1327325-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 All block internal state for dealing adding/removing debugfs entries have been removed, and debugfs can sync everything for us in fs level, so don't grab q->debugfs_mutex for adding/removing block internal debugfs entries. Now q->debugfs_mutex is only used for blktrace, meantime move creating queue debugfs dir code out of q->sysfs_lock. Both the two locks are connected with queue freeze IO lock. Then queue freeze IO lock chain with debugfs lock is cut. The following lockdep report can be fixed: https://lore.kernel.org/linux-block/ougniadskhks7uyxguxihgeuh2pv4yaqv4q3emo4gwuolgzdt6@brotly74p6bs/ Follows contexts which adds/removes debugfs entries: - update nr_hw_queues - add/remove disks - elevator switch - blktrace blktrace only adds entries under disk top directory, so we can ignore it, because it can only work iff disk is added. Also nothing overlapped with the other two contex, blktrace context is fine. Elevator switch is only allowed after disk is added, so there isn't race with add/remove disk. blk_mq_update_nr_hw_queues() always restores to previous elevator, so no race between these two. Elevator switch context is fine. So far blk_mq_update_nr_hw_queues() doesn't hold debugfs lock for adding/removing hctx entries, there might be race with add/remove disk, which is just fine in reality: - blk_mq_update_nr_hw_queues() is usually for error recovery, and disk won't be added/removed at the same time - even though there is race between the two contexts, it is just fine, since hctx won't be freed until queue is dead - we never see reports in this area without holding debugfs in blk_mq_update_nr_hw_queues() Reported-by: Shinichiro Kawasaki Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 12 ------------ block/blk-mq-sched.c | 8 -------- block/blk-rq-qos.c | 7 +------ block/blk-sysfs.c | 6 +----- kernel/trace/blktrace.c | 2 ++ 5 files changed, 4 insertions(+), 31 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 6d98c2a6e7c6..9601823730e2 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -770,8 +770,6 @@ void blk_mq_debugfs_register_sched(struct request_queue *q) struct elevator_type *e = q->elevator->type; struct dentry *sched_dir; - lockdep_assert_held(&q->debugfs_mutex); - /* * If the parent directory has not been created yet, return, we will be * called again later on and the directory/files will be created then. @@ -793,8 +791,6 @@ void blk_mq_debugfs_unregister_sched(struct request_queue *q) { struct dentry *queue_dir = blk_mq_get_queue_entry(q); - lockdep_assert_held(&q->debugfs_mutex); - if (IS_ERR_OR_NULL(queue_dir)) return; debugfs_lookup_and_remove("sched", queue_dir); @@ -832,8 +828,6 @@ void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) struct dentry *queue_dir = blk_mq_get_queue_entry(q); struct dentry *rqos_top; - lockdep_assert_held(&q->debugfs_mutex); - if (IS_ERR_OR_NULL(queue_dir)) return; @@ -853,8 +847,6 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) struct dentry *rqos_top; struct dentry *rqos_dir; - lockdep_assert_held(&q->debugfs_mutex); - if (!rqos->ops->debugfs_attrs) return; @@ -874,8 +866,6 @@ void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, struct elevator_type *e = q->elevator->type; struct dentry *sched_dir; - lockdep_assert_held(&q->debugfs_mutex); - /* * If the parent debugfs directory has not been created yet, return; * We will be called again later on with appropriate parent debugfs @@ -897,8 +887,6 @@ void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx) { struct dentry *sched_dir; - lockdep_assert_held(&hctx->queue->debugfs_mutex); - sched_dir = blk_mq_get_hctx_sched_entry(hctx); if (sched_dir) { debugfs_remove_recursive(sched_dir); diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 7442ca27c2bf..1ca127297b2c 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -469,9 +469,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) if (ret) goto err_free_map_and_rqs; - mutex_lock(&q->debugfs_mutex); blk_mq_debugfs_register_sched(q); - mutex_unlock(&q->debugfs_mutex); queue_for_each_hw_ctx(q, hctx, i) { if (e->ops.init_hctx) { @@ -484,9 +482,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e) return ret; } } - mutex_lock(&q->debugfs_mutex); blk_mq_debugfs_register_sched_hctx(q, hctx); - mutex_unlock(&q->debugfs_mutex); } return 0; @@ -527,9 +523,7 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e) unsigned int flags = 0; queue_for_each_hw_ctx(q, hctx, i) { - mutex_lock(&q->debugfs_mutex); blk_mq_debugfs_unregister_sched_hctx(hctx); - mutex_unlock(&q->debugfs_mutex); if (e->type->ops.exit_hctx && hctx->sched_data) { e->type->ops.exit_hctx(hctx, i); @@ -538,9 +532,7 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e) flags = hctx->flags; } - mutex_lock(&q->debugfs_mutex); blk_mq_debugfs_unregister_sched(q); - mutex_unlock(&q->debugfs_mutex); if (e->type->ops.exit_sched) e->type->ops.exit_sched(e); diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index d4d4f4dc0e23..529640ed2ff5 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -320,11 +320,8 @@ int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id id, blk_mq_unfreeze_queue(q, memflags); - if (rqos->ops->debugfs_attrs) { - mutex_lock(&q->debugfs_mutex); + if (rqos->ops->debugfs_attrs) blk_mq_debugfs_register_rqos(rqos); - mutex_unlock(&q->debugfs_mutex); - } return 0; ebusy: @@ -349,7 +346,5 @@ void rq_qos_del(struct rq_qos *rqos) } blk_mq_unfreeze_queue(q, memflags); - mutex_lock(&q->debugfs_mutex); blk_mq_debugfs_unregister_rqos(rqos); - mutex_unlock(&q->debugfs_mutex); } diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 68bd84e06aac..b0bfb4c82e0e 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -744,10 +744,8 @@ static void blk_debugfs_remove(struct gendisk *disk) { struct request_queue *q = disk->queue; - mutex_lock(&q->debugfs_mutex); blk_trace_shutdown(q); debugfs_lookup_and_remove(disk->disk_name, blk_debugfs_root); - mutex_unlock(&q->debugfs_mutex); } /** @@ -769,14 +767,12 @@ int blk_register_queue(struct gendisk *disk) if (ret) goto out_put_queue_kobj; } - mutex_lock(&q->sysfs_lock); - mutex_lock(&q->debugfs_mutex); debugfs_create_dir(disk->disk_name, blk_debugfs_root); if (queue_is_mq(q)) blk_mq_debugfs_register(q); - mutex_unlock(&q->debugfs_mutex); + mutex_lock(&q->sysfs_lock); ret = disk_register_independent_access_ranges(disk); if (ret) goto out_debugfs_remove; diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 32cda8f5d008..13efd48adcc3 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -775,9 +775,11 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) **/ void blk_trace_shutdown(struct request_queue *q) { + mutex_lock(&q->debugfs_mutex); if (rcu_dereference_protected(q->blk_trace, lockdep_is_held(&q->debugfs_mutex))) __blk_trace_remove(q); + mutex_unlock(&q->debugfs_mutex); } #ifdef CONFIG_BLK_CGROUP