mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
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>
This commit is contained in:
@@ -625,20 +625,9 @@ void blk_mq_debugfs_register(struct request_queue *q)
|
||||
|
||||
debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
|
||||
|
||||
/*
|
||||
* blk_mq_init_sched() attempted to do this already, but q->debugfs_dir
|
||||
* 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)
|
||||
blk_mq_debugfs_register_sched(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);
|
||||
if (q->elevator && !hctx->sched_debugfs_dir)
|
||||
blk_mq_debugfs_register_sched_hctx(q, hctx);
|
||||
}
|
||||
|
||||
if (q->rq_qos) {
|
||||
|
||||
@@ -434,7 +434,7 @@ static int blk_mq_init_sched_shared_tags(struct request_queue *queue)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void blk_mq_sched_reg_debugfs(struct request_queue *q)
|
||||
void blk_mq_sched_reg_debugfs(struct request_queue *q)
|
||||
{
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
unsigned long i;
|
||||
@@ -446,7 +446,7 @@ static void blk_mq_sched_reg_debugfs(struct request_queue *q)
|
||||
mutex_unlock(&q->debugfs_mutex);
|
||||
}
|
||||
|
||||
static void blk_mq_sched_unreg_debugfs(struct request_queue *q)
|
||||
void blk_mq_sched_unreg_debugfs(struct request_queue *q)
|
||||
{
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
unsigned long i;
|
||||
@@ -503,10 +503,6 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* sched is initialized, it is ready to export it via debugfs */
|
||||
blk_mq_sched_reg_debugfs(q);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free_map_and_rqs:
|
||||
@@ -544,9 +540,6 @@ void blk_mq_exit_sched(struct request_queue *q, struct elevator_queue *e)
|
||||
unsigned long i;
|
||||
unsigned int flags = 0;
|
||||
|
||||
/* unexport via debugfs before exiting sched */
|
||||
blk_mq_sched_unreg_debugfs(q);
|
||||
|
||||
queue_for_each_hw_ctx(q, hctx, i) {
|
||||
if (e->type->ops.exit_hctx && hctx->sched_data) {
|
||||
e->type->ops.exit_hctx(hctx, i);
|
||||
|
||||
@@ -472,6 +472,11 @@ int elv_register_queue(struct request_queue *q, bool uevent)
|
||||
if (uevent)
|
||||
kobject_uevent(&e->kobj, KOBJ_ADD);
|
||||
|
||||
/*
|
||||
* Sched is initialized, it is ready to export it via
|
||||
* debugfs
|
||||
*/
|
||||
blk_mq_sched_reg_debugfs(q);
|
||||
set_bit(ELEVATOR_FLAG_REGISTERED, &e->flags);
|
||||
}
|
||||
return error;
|
||||
@@ -486,6 +491,9 @@ void elv_unregister_queue(struct request_queue *q)
|
||||
if (e && test_and_clear_bit(ELEVATOR_FLAG_REGISTERED, &e->flags)) {
|
||||
kobject_uevent(&e->kobj, KOBJ_REMOVE);
|
||||
kobject_del(&e->kobj);
|
||||
|
||||
/* unexport via debugfs before exiting sched */
|
||||
blk_mq_sched_unreg_debugfs(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,4 +181,7 @@ extern struct request *elv_rb_find(struct rb_root *, sector_t);
|
||||
#define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist)
|
||||
#define rq_fifo_clear(rq) list_del_init(&(rq)->queuelist)
|
||||
|
||||
void blk_mq_sched_reg_debugfs(struct request_queue *q);
|
||||
void blk_mq_sched_unreg_debugfs(struct request_queue *q);
|
||||
|
||||
#endif /* _ELEVATOR_H */
|
||||
|
||||
Reference in New Issue
Block a user