diff mbox series

[v2,05/12] block: Catch possible entries missing from hctx_flag_name[]

Message ID 20240711082339.1155658-6-john.g.garry@oracle.com (mailing list archive)
State New, archived
Headers show
Series block: Catch missing debugfs flag array members | expand

Commit Message

John Garry July 11, 2024, 8:23 a.m. UTC
Refresh values BLK_MQ_F_x enum, and then re-arrange members in
hctx_flag_name[] to match that enum.

An entry for NO_SCHED_BY_DEFAULT is missing, so add one.

Finally add a BUILD_BUG_ON() call to ensure that we are not missing entries
in hctx_flag_name[].

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 block/blk-mq-debugfs.c |  8 ++++++--
 include/linux/blk-mq.h | 10 ++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

Comments

Bart Van Assche July 11, 2024, 6:10 p.m. UTC | #1
On 7/11/24 1:23 AM, John Garry wrote:
> -	BLK_MQ_F_NO_SCHED_BY_DEFAULT	= 1 << 7,
> -	BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,
> +	BLK_MQ_F_NO_SCHED_BY_DEFAULT	= 1 << 6,
> +	BLK_MQ_F_ALLOC_POLICY_START_BIT = 7,
>   	BLK_MQ_F_ALLOC_POLICY_BITS = 1,
>   
>   	/* Keep hctx_state_name[] in sync with the definitions below */

The patch description does not explain why 
BLK_MQ_F_ALLOC_POLICY_START_BIT is modified. Please include
an explanation for this change in the patch description.

Thanks,

Bart.
John Garry July 15, 2024, 7:55 a.m. UTC | #2
On 11/07/2024 19:10, Bart Van Assche wrote:
> On 7/11/24 1:23 AM, John Garry wrote:
>> -    BLK_MQ_F_NO_SCHED_BY_DEFAULT    = 1 << 7,
>> -    BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,
>> +    BLK_MQ_F_NO_SCHED_BY_DEFAULT    = 1 << 6,
>> +    BLK_MQ_F_ALLOC_POLICY_START_BIT = 7,
>>       BLK_MQ_F_ALLOC_POLICY_BITS = 1,
>>       /* Keep hctx_state_name[] in sync with the definitions below */
> 
> The patch description does not explain why 
> BLK_MQ_F_ALLOC_POLICY_START_BIT is modified. Please include
> an explanation for this change in the patch description

Can do.
diff mbox series

Patch

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index fca8b82464b4..b9bf4b25b267 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -183,10 +183,11 @@  static const char *const alloc_policy_name[] = {
 static const char *const hctx_flag_name[] = {
 	HCTX_FLAG_NAME(SHOULD_MERGE),
 	HCTX_FLAG_NAME(TAG_QUEUE_SHARED),
-	HCTX_FLAG_NAME(BLOCKING),
-	HCTX_FLAG_NAME(NO_SCHED),
 	HCTX_FLAG_NAME(STACKING),
 	HCTX_FLAG_NAME(TAG_HCTX_SHARED),
+	HCTX_FLAG_NAME(BLOCKING),
+	HCTX_FLAG_NAME(NO_SCHED),
+	HCTX_FLAG_NAME(NO_SCHED_BY_DEFAULT),
 };
 #undef HCTX_FLAG_NAME
 
@@ -195,6 +196,9 @@  static int hctx_flags_show(void *data, struct seq_file *m)
 	struct blk_mq_hw_ctx *hctx = data;
 	const int alloc_policy = BLK_MQ_FLAG_TO_ALLOC_POLICY(hctx->flags);
 
+	BUILD_BUG_ON(ARRAY_SIZE(hctx_flag_name) !=
+			BLK_MQ_F_ALLOC_POLICY_START_BIT);
+
 	seq_puts(m, "alloc_policy=");
 	if (alloc_policy < ARRAY_SIZE(alloc_policy_name) &&
 	    alloc_policy_name[alloc_policy])
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 225e51698470..6a41d5097dd8 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -644,6 +644,7 @@  struct blk_mq_ops {
 #endif
 };
 
+/* Keep hctx_flag_name[] in sync with the definitions below */
 enum {
 	BLK_MQ_F_SHOULD_MERGE	= 1 << 0,
 	BLK_MQ_F_TAG_QUEUE_SHARED = 1 << 1,
@@ -653,15 +654,16 @@  enum {
 	 */
 	BLK_MQ_F_STACKING	= 1 << 2,
 	BLK_MQ_F_TAG_HCTX_SHARED = 1 << 3,
-	BLK_MQ_F_BLOCKING	= 1 << 5,
+	BLK_MQ_F_BLOCKING	= 1 << 4,
 	/* Do not allow an I/O scheduler to be configured. */
-	BLK_MQ_F_NO_SCHED	= 1 << 6,
+	BLK_MQ_F_NO_SCHED	= 1 << 5,
+
 	/*
 	 * Select 'none' during queue registration in case of a single hwq
 	 * or shared hwqs instead of 'mq-deadline'.
 	 */
-	BLK_MQ_F_NO_SCHED_BY_DEFAULT	= 1 << 7,
-	BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,
+	BLK_MQ_F_NO_SCHED_BY_DEFAULT	= 1 << 6,
+	BLK_MQ_F_ALLOC_POLICY_START_BIT = 7,
 	BLK_MQ_F_ALLOC_POLICY_BITS = 1,
 
 	/* Keep hctx_state_name[] in sync with the definitions below */