This is a note to let you know that I've just added the patch titled bfq: Remove pointless bfq_init_rq() calls to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: bfq-remove-pointless-bfq_init_rq-calls.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Mon Jun 6 08:05:28 PM CEST 2022 From: Jan Kara <jack@xxxxxxx> Date: Mon, 6 Jun 2022 19:56:38 +0200 Subject: bfq: Remove pointless bfq_init_rq() calls To: stable@xxxxxxxxxxxxxxx Cc: <linux-block@xxxxxxxxxxxxxxx>, Paolo Valente <paolo.valente@xxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, Jan Kara <jack@xxxxxxx>, "yukuai (C)" <yukuai3@xxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx> Message-ID: <20220606175655.8993-3-jack@xxxxxxx> From: Jan Kara <jack@xxxxxxx> commit 5f550ede5edf846ecc0067be1ba80514e6fe7f8e upstream. We call bfq_init_rq() from request merging functions where requests we get should have already gone through bfq_init_rq() during insert and anyway we want to do anything only if the request is already tracked by BFQ. So replace calls to bfq_init_rq() with RQ_BFQQ() instead to simply skip requests untracked by BFQ. We move bfq_init_rq() call in bfq_insert_request() a bit earlier to cover request merging and thus can transfer FIFO position in case of a merge. CC: stable@xxxxxxxxxxxxxxx Tested-by: "yukuai (C)" <yukuai3@xxxxxxxxxx> Signed-off-by: Jan Kara <jack@xxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Link: https://lore.kernel.org/r/20220401102752.8599-6-jack@xxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/bfq-iosched.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2267,8 +2267,6 @@ static int bfq_request_merge(struct requ return ELEVATOR_NO_MERGE; } -static struct bfq_queue *bfq_init_rq(struct request *rq); - static void bfq_request_merged(struct request_queue *q, struct request *req, enum elv_merge type) { @@ -2277,7 +2275,7 @@ static void bfq_request_merged(struct re blk_rq_pos(req) < blk_rq_pos(container_of(rb_prev(&req->rb_node), struct request, rb_node))) { - struct bfq_queue *bfqq = bfq_init_rq(req); + struct bfq_queue *bfqq = RQ_BFQQ(req); struct bfq_data *bfqd; struct request *prev, *next_rq; @@ -2329,8 +2327,8 @@ static void bfq_request_merged(struct re static void bfq_requests_merged(struct request_queue *q, struct request *rq, struct request *next) { - struct bfq_queue *bfqq = bfq_init_rq(rq), - *next_bfqq = bfq_init_rq(next); + struct bfq_queue *bfqq = RQ_BFQQ(rq), + *next_bfqq = RQ_BFQQ(next); if (!bfqq) return; @@ -5518,6 +5516,8 @@ static inline void bfq_update_insert_sta unsigned int cmd_flags) {} #endif /* CONFIG_BFQ_CGROUP_DEBUG */ +static struct bfq_queue *bfq_init_rq(struct request *rq); + static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, bool at_head) { @@ -5532,6 +5532,7 @@ static void bfq_insert_request(struct bl bfqg_stats_update_legacy_io(q, rq); #endif spin_lock_irq(&bfqd->lock); + bfqq = bfq_init_rq(rq); if (blk_mq_sched_try_insert_merge(q, rq)) { spin_unlock_irq(&bfqd->lock); return; @@ -5539,7 +5540,6 @@ static void bfq_insert_request(struct bl blk_mq_sched_request_inserted(rq); - bfqq = bfq_init_rq(rq); if (!bfqq || at_head || blk_rq_is_passthrough(rq)) { if (at_head) list_add(&rq->queuelist, &bfqd->dispatch); Patches currently in stable-queue which might be from jack@xxxxxxx are queue-5.10/bfq-split-shared-queues-on-move-between-cgroups.patch queue-5.10/ext4-avoid-cycles-in-directory-h-tree.patch queue-5.10/bfq-get-rid-of-__bio_blkcg-usage.patch queue-5.10/ext4-fix-bug_on-in-__es_tree_search.patch queue-5.10/bfq-track-whether-bfq_group-is-still-online.patch queue-5.10/bfq-make-sure-bfqg-for-which-we-are-queueing-requests-is-online.patch queue-5.10/bfq-drop-pointless-unlock-lock-pair.patch queue-5.10/ext4-fix-bug_on-in-ext4_writepages.patch queue-5.10/dax-fix-cache-flush-on-pmd-mapped-pages.patch queue-5.10/fsnotify-fix-wrong-lockdep-annotations.patch queue-5.10/bfq-avoid-merging-queues-with-different-parents.patch queue-5.10/inotify-show-inotify-mask-flags-in-proc-fdinfo.patch queue-5.10/ext4-fix-use-after-free-in-ext4_rename_dir_prepare.patch queue-5.10/fs-writeback-writeback_sb_inodes-recalculate-wrote-according-skipped-pages.patch queue-5.10/bfq-remove-pointless-bfq_init_rq-calls.patch queue-5.10/ext4-verify-dir-block-before-splitting-it.patch queue-5.10/block-fix-bio_clone_blkg_association-to-associate-with-proper-blkcg_gq.patch queue-5.10/bfq-update-cgroup-information-before-merging-bio.patch