Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: introduce alloc_sched_data and free_sched_data elevator methods

The recent lockdep splat [1] highlights a potential deadlock risk
involving ->elevator_lock and ->freeze_lock dependencies on -pcpu_alloc_
mutex. The trace shows that the issue occurs when the Kyber scheduler
allocates dynamic memory for its elevator data during initialization.

To address this, introduce two new elevator operation callbacks:
->alloc_sched_data and ->free_sched_data. The subsequent patch would
build upon these newly introduced methods to suppress lockdep splat[1].

[1] https://lore.kernel.org/all/CAGVVp+VNW4M-5DZMNoADp6o2VKFhi7KxWpTDkcnVyjO0=-D5+A@mail.gmail.com/

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Nilay Shroff and committed by
Jens Axboe
61019afd 04728ce9

+26
+24
block/blk-mq-sched.h
··· 38 38 struct blk_mq_tag_set *set); 39 39 void blk_mq_free_sched_res_batch(struct xarray *et_table, 40 40 struct blk_mq_tag_set *set); 41 + /* 42 + * blk_mq_alloc_sched_data() - Allocates scheduler specific data 43 + * Returns: 44 + * - Pointer to allocated data on success 45 + * - NULL if no allocation needed 46 + * - ERR_PTR(-ENOMEM) in case of failure 47 + */ 48 + static inline void *blk_mq_alloc_sched_data(struct request_queue *q, 49 + struct elevator_type *e) 50 + { 51 + void *sched_data; 52 + 53 + if (!e || !e->ops.alloc_sched_data) 54 + return NULL; 55 + 56 + sched_data = e->ops.alloc_sched_data(q); 57 + return (sched_data) ?: ERR_PTR(-ENOMEM); 58 + } 59 + 60 + static inline void blk_mq_free_sched_data(struct elevator_type *e, void *data) 61 + { 62 + if (e && e->ops.free_sched_data) 63 + e->ops.free_sched_data(data); 64 + } 41 65 42 66 static inline void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx) 43 67 {
+2
block/elevator.h
··· 58 58 int (*init_hctx)(struct blk_mq_hw_ctx *, unsigned int); 59 59 void (*exit_hctx)(struct blk_mq_hw_ctx *, unsigned int); 60 60 void (*depth_updated)(struct request_queue *); 61 + void *(*alloc_sched_data)(struct request_queue *); 62 + void (*free_sched_data)(void *); 61 63 62 64 bool (*allow_merge)(struct request_queue *, struct request *, struct bio *); 63 65 bool (*bio_merge)(struct request_queue *, struct bio *, unsigned int);