Skip to content

Commit b295291

Browse files
author
Ming Lei
committed
block: move sched debugfs register into elvevator_register_queue
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit 92c22d7 Author: Ming Lei <ming.lei@redhat.com> Date: Mon May 5 22:17:44 2025 +0800 block: move sched debugfs register into elvevator_register_queue sched debugfs shares same lifetime with scheduler's kobject, and same lock(elevator lock), so move sched debugfs register/unregister into elevator_register_queue() and elevator_unregister_queue(). Then we needn't blk_mq_debugfs_register() for us to register sched debugfs any more. Reviewed-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20250505141805.2751237-7-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent e8185b8 commit b295291

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

block/blk-mq-debugfs.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -625,20 +625,9 @@ void blk_mq_debugfs_register(struct request_queue *q)
625625

626626
debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
627627

628-
/*
629-
* blk_mq_init_sched() attempted to do this already, but q->debugfs_dir
630-
* didn't exist yet (because we don't know what to name the directory
631-
* until the queue is registered to a gendisk).
632-
*/
633-
if (q->elevator && !q->sched_debugfs_dir)
634-
blk_mq_debugfs_register_sched(q);
635-
636-
/* Similarly, blk_mq_init_hctx() couldn't do this previously. */
637628
queue_for_each_hw_ctx(q, hctx, i) {
638629
if (!hctx->debugfs_dir)
639630
blk_mq_debugfs_register_hctx(q, hctx);
640-
if (q->elevator && !hctx->sched_debugfs_dir)
641-
blk_mq_debugfs_register_sched_hctx(q, hctx);
642631
}
643632

644633
if (q->rq_qos) {

block/blk-mq-sched.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static int blk_mq_init_sched_shared_tags(struct request_queue *queue)
434434
return 0;
435435
}
436436

437-
static void blk_mq_sched_reg_debugfs(struct request_queue *q)
437+
void blk_mq_sched_reg_debugfs(struct request_queue *q)
438438
{
439439
struct blk_mq_hw_ctx *hctx;
440440
unsigned long i;
@@ -446,7 +446,7 @@ static void blk_mq_sched_reg_debugfs(struct request_queue *q)
446446
mutex_unlock(&q->debugfs_mutex);
447447
}
448448

449-
static void blk_mq_sched_unreg_debugfs(struct request_queue *q)
449+
void blk_mq_sched_unreg_debugfs(struct request_queue *q)
450450
{
451451
struct blk_mq_hw_ctx *hctx;
452452
unsigned long i;
@@ -503,10 +503,6 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
503503
}
504504
}
505505
}
506-
507-
/* sched is initialized, it is ready to export it via debugfs */
508-
blk_mq_sched_reg_debugfs(q);
509-
510506
return 0;
511507

512508
err_free_map_and_rqs:
@@ -544,9 +540,6 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
544540
unsigned long i;
545541
unsigned int flags = 0;
546542

547-
/* unexport via debugfs before exiting sched */
548-
blk_mq_sched_unreg_debugfs(q);
549-
550543
queue_for_each_hw_ctx(q, hctx, i) {
551544
if (e->type->ops.exit_hctx && hctx->sched_data) {
552545
e->type->ops.exit_hctx(hctx, i);

block/elevator.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ int elv_register_queue(struct request_queue *q, bool uevent)
472472
if (uevent)
473473
kobject_uevent(&e->kobj, KOBJ_ADD);
474474

475+
/*
476+
* Sched is initialized, it is ready to export it via
477+
* debugfs
478+
*/
479+
blk_mq_sched_reg_debugfs(q);
475480
set_bit(ELEVATOR_FLAG_REGISTERED, &e->flags);
476481
}
477482
return error;
@@ -486,6 +491,9 @@ void elv_unregister_queue(struct request_queue *q)
486491
if (e && test_and_clear_bit(ELEVATOR_FLAG_REGISTERED, &e->flags)) {
487492
kobject_uevent(&e->kobj, KOBJ_REMOVE);
488493
kobject_del(&e->kobj);
494+
495+
/* unexport via debugfs before exiting sched */
496+
blk_mq_sched_unreg_debugfs(q);
489497
}
490498
}
491499

block/elevator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,7 @@ extern struct request *elv_rb_find(struct rb_root *, sector_t);
181181
#define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist)
182182
#define rq_fifo_clear(rq) list_del_init(&(rq)->queuelist)
183183

184+
void blk_mq_sched_reg_debugfs(struct request_queue *q);
185+
void blk_mq_sched_unreg_debugfs(struct request_queue *q);
186+
184187
#endif /* _ELEVATOR_H */

0 commit comments

Comments
 (0)