Message ID | 20240711082339.1155658-5-john.g.garry@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: Catch missing debugfs flag array members | expand |
On 7/11/24 1:23 AM, John Garry wrote: > diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h > index 89ba6b16fe8b..225e51698470 100644 > --- a/include/linux/blk-mq.h > +++ b/include/linux/blk-mq.h > @@ -664,12 +664,14 @@ enum { > BLK_MQ_F_ALLOC_POLICY_START_BIT = 8, > BLK_MQ_F_ALLOC_POLICY_BITS = 1, > > + /* Keep hctx_state_name[] in sync with the definitions below */ > BLK_MQ_S_STOPPED = 0, > BLK_MQ_S_TAG_ACTIVE = 1, > BLK_MQ_S_SCHED_RESTART = 2, > > /* hw queue is inactive after all its CPUs become offline */ > BLK_MQ_S_INACTIVE = 3, > + BLK_MQ_S_MAX, Please create a new "enum {" section for the BLK_MQ_S_ constants. That will make it more clear that these are unrelated to the other constants defined above and below the BLK_MQ_S_ constants. Thanks, Bart.
On 11/07/2024 19:08, Bart Van Assche wrote: > On 7/11/24 1:23 AM, John Garry wrote: >> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h >> index 89ba6b16fe8b..225e51698470 100644 >> --- a/include/linux/blk-mq.h >> +++ b/include/linux/blk-mq.h >> @@ -664,12 +664,14 @@ enum { >> BLK_MQ_F_ALLOC_POLICY_START_BIT = 8, >> BLK_MQ_F_ALLOC_POLICY_BITS = 1, >> + /* Keep hctx_state_name[] in sync with the definitions below */ >> BLK_MQ_S_STOPPED = 0, >> BLK_MQ_S_TAG_ACTIVE = 1, >> BLK_MQ_S_SCHED_RESTART = 2, >> /* hw queue is inactive after all its CPUs become offline */ >> BLK_MQ_S_INACTIVE = 3, >> + BLK_MQ_S_MAX, > > Please create a new "enum {" section for the BLK_MQ_S_ constants. > That will make it more clear that these are unrelated to the other > constants defined above and below the BLK_MQ_S_ constants. ok, fine. If we are going to start breaking up this misc enum, then where do BLK_MQ_MAX_DEPTH and BLK_MQ_CPU_WORK_BATCH really belong? I'd be more inclined to have a separate #define for each of them. I am not sure how they ever ended up in this same enum. BTW, BLK_MQ_CPU_WORK_BATCH is only used in block/blk-mq.c, so I don't see why it is even in a public API.
On 7/15/24 12:54 AM, John Garry wrote: > BTW, BLK_MQ_CPU_WORK_BATCH is only used in block/blk-mq.c, so I don't > see why it is even in a public API. I'm in favor of moving this constant into block/blk-mq.c. Thanks, Bart.
On 15/07/2024 18:28, Bart Van Assche wrote: > On 7/15/24 12:54 AM, John Garry wrote: >> BTW, BLK_MQ_CPU_WORK_BATCH is only used in block/blk-mq.c, so I don't >> see why it is even in a public API. > > I'm in favor of moving this constant into block/blk-mq.c. I was actually thinking of moving it to block/blk-mq.h, as much blk-mq internal defines/prototypes/inline functions are located there.
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 9e18ba6b1c4d..fca8b82464b4 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -165,6 +165,7 @@ static int hctx_state_show(void *data, struct seq_file *m) { struct blk_mq_hw_ctx *hctx = data; + BUILD_BUG_ON(ARRAY_SIZE(hctx_state_name) != BLK_MQ_S_MAX); blk_flags_show(m, hctx->state, hctx_state_name, ARRAY_SIZE(hctx_state_name)); seq_puts(m, "\n"); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 89ba6b16fe8b..225e51698470 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -664,12 +664,14 @@ enum { BLK_MQ_F_ALLOC_POLICY_START_BIT = 8, BLK_MQ_F_ALLOC_POLICY_BITS = 1, + /* Keep hctx_state_name[] in sync with the definitions below */ BLK_MQ_S_STOPPED = 0, BLK_MQ_S_TAG_ACTIVE = 1, BLK_MQ_S_SCHED_RESTART = 2, /* hw queue is inactive after all its CPUs become offline */ BLK_MQ_S_INACTIVE = 3, + BLK_MQ_S_MAX, BLK_MQ_MAX_DEPTH = 10240,
Add a build-time assert that we are not missing entries from hctx_state_name[]. For this, add a "max" entry for BLK_MQ_S_x flags. Signed-off-by: John Garry <john.g.garry@oracle.com> --- block/blk-mq-debugfs.c | 1 + include/linux/blk-mq.h | 2 ++ 2 files changed, 3 insertions(+)