All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Pavel Begunkov <asml.silence@gmail.com>,
	Jens Axboe <axboe@kernel.dk>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1 16/28] block: fix hctx checks for batch allocation
Date: Fri,  3 Feb 2023 11:13:04 +0100	[thread overview]
Message-ID: <20230203101010.657044513@linuxfoundation.org> (raw)
In-Reply-To: <20230203101009.946745030@linuxfoundation.org>

From: Pavel Begunkov <asml.silence@gmail.com>

[ Upstream commit 7746564793978fe2f43b18a302b22dca0ad3a0e8 ]

When there are no read queues read requests will be assigned a
default queue on allocation. However, blk_mq_get_cached_request() is not
prepared for that and will fail all attempts to grab read requests from
the cache. Worst case it doubles the number of requests allocated,
roughly half of which will be returned by blk_mq_free_plug_rqs().

It only affects batched allocations and so is io_uring specific.
For reference, QD8 t/io_uring benchmark improves by 20-35%.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/80d4511011d7d4751b4cf6375c4e38f237d935e3.1673955390.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 block/blk-mq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 63abbe342b28..83fbc7c54617 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2858,6 +2858,7 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
 		struct blk_plug *plug, struct bio **bio, unsigned int nsegs)
 {
 	struct request *rq;
+	enum hctx_type type, hctx_type;
 
 	if (!plug)
 		return NULL;
@@ -2870,7 +2871,10 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
 		return NULL;
 	}
 
-	if (blk_mq_get_hctx_type((*bio)->bi_opf) != rq->mq_hctx->type)
+	type = blk_mq_get_hctx_type((*bio)->bi_opf);
+	hctx_type = rq->mq_hctx->type;
+	if (type != hctx_type &&
+	    !(type == HCTX_TYPE_READ && hctx_type == HCTX_TYPE_DEFAULT))
 		return NULL;
 	if (op_is_flush(rq->cmd_flags) != op_is_flush((*bio)->bi_opf))
 		return NULL;
-- 
2.39.0




  parent reply	other threads:[~2023-02-03 10:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 10:12 [PATCH 6.1 00/28] 6.1.10-rc1 review Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 01/28] ARM: dts: imx: Fix pca9547 i2c-mux node name Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 02/28] ARM: dts: vf610: Fix pca9548 i2c-mux node names Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 03/28] arm64: dts: freescale: Fix pca954x " Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 04/28] arm64: dts: imx8mq-thor96: fix no-mmc property for SDHCI Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 05/28] firmware: arm_scmi: Clear stale xfer->hdr.status Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 06/28] bpf: Skip task with pid=1 in send_signal_common() Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 07/28] erofs/zmap.c: Fix incorrect offset calculation Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 08/28] mac80211: Fix MLO address translation for multiple bss case Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 09/28] arm64: dts: msm8994-angler: fix the memory map Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 10/28] ARM: omap1: fix building gpio15xx Greg Kroah-Hartman
2023-02-03 10:12 ` [PATCH 6.1 11/28] kselftest: Fix error message for unconfigured LLVM builds Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 12/28] erofs: clean up parsing of fscache related options Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 13/28] blk-cgroup: fix missing pd_online_fn() while activating policy Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 14/28] LoongArch: Get frame info in unwind_start() when regs is not available Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 15/28] ACPI: video: Add backlight=native DMI quirk for Acer Aspire 4810T Greg Kroah-Hartman
2023-02-03 10:13 ` Greg Kroah-Hartman [this message]
2023-02-03 10:13 ` [PATCH 6.1 17/28] s390: workaround invalid gcc-11 out of bounds read warning Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 18/28] HID: uclogic: Add support for XP-PEN Deco 01 V2 Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 19/28] HID: playstation: sanity check DualSense calibration data Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 20/28] dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 21/28] gpiolib: acpi: Allow ignoring wake capability on pins that arent in _AEI Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 22/28] cifs: fix return of uninitialized rc in dfs_cache_update_tgthint() Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 23/28] nvme-apple: only reset the controller when RTKit is running Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 24/28] gpiolib: acpi: Add a ignore wakeup quirk for Clevo NL5xRU Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 25/28] gpiolib-acpi: Dont set GPIOs for wakeup in S3 mode Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 26/28] net: fix NULL pointer in skb_segment_list Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 27/28] rust: print: avoid evaluating arguments in `pr_*` macros in `unsafe` blocks Greg Kroah-Hartman
2023-02-03 10:13 ` [PATCH 6.1 28/28] net: mctp: purge receive queues on sk destruction Greg Kroah-Hartman
2023-02-03 13:58 ` [PATCH 6.1 00/28] 6.1.10-rc1 review ogasawara takeshi
2023-02-03 18:02 ` Justin Forbes
2023-02-03 20:16 ` Florian Fainelli
2023-02-03 22:34 ` Ron Economos
2023-02-04  0:49 ` Shuah Khan
2023-02-04  1:51 ` Guenter Roeck
2023-02-04  3:28 ` Bagas Sanjaya
2023-02-04  7:25 ` Naresh Kamboju
2023-02-05 19:51   ` Nathan Chancellor
2023-02-06 14:12     ` Naresh Kamboju
2023-02-04  7:27 ` Fenil Jain
2023-02-04 23:45 ` Rudi Heitbaum
2023-02-06  8:57 ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230203101010.657044513@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.