From: Ye Bin <yebin@huaweicloud.com>
To: axboe@kernel.dk, linux-block@vger.kernel.org
Cc: ming.lei@redhat.com
Subject: [PATCH v2 1/4] block/mq-deadline: reject zero prio_aging_expire
Date: Mon, 31 Aug 2026 19:01:41 +0800 [thread overview]
Message-ID: <20260831110144.2648156-2-yebin@huaweicloud.com> (raw)
In-Reply-To: <20260831110144.2648156-1-yebin@huaweicloud.com>
From: Ye Bin <yebin10@huawei.com>
A prio_aging_expire of zero does not disable I/O priority in
mq-deadline. Instead the priority aging path in
dd_dispatch_prio_aged_requests() is invoked with "now - 0 == now",
which causes best-effort and idle requests to be dispatched ahead of
pending real-time requests -- a classic priority inversion, not the
"priority disabled" behavior users may expect when writing zero.
Reject zero (and negative) values in the sysfs store with -EINVAL so
that a misconfiguration is reported rather than silently accepted.
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
block/mq-deadline.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index 5f643c0ce2a8..a4358625cfc8 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -31,7 +31,10 @@ static const int read_expire = HZ / 2; /* max time before a read is submitted.
static const int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */
/*
* Time after which to dispatch lower priority requests even if higher
- * priority requests are pending.
+ * priority requests are pending. Must be > 0: a value of zero would make
+ * the priority aging path dispatch best-effort and idle requests ahead of
+ * pending real-time requests through "now - 0 == now", a classic priority
+ * inversion.
*/
static const int prio_aging_expire = 10 * HZ;
static const int writes_starved = 2; /* max times reads can starve a write */
@@ -770,7 +773,6 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, msecs_to_jiffies)
STORE_JIFFIES(deadline_read_expire_store, &dd->fifo_expire[DD_READ], 0, INT_MAX);
STORE_JIFFIES(deadline_write_expire_store, &dd->fifo_expire[DD_WRITE], 0, INT_MAX);
-STORE_JIFFIES(deadline_prio_aging_expire_store, &dd->prio_aging_expire, 0, INT_MAX);
STORE_INT(deadline_writes_starved_store, &dd->writes_starved, INT_MIN, INT_MAX);
STORE_INT(deadline_front_merges_store, &dd->front_merges, 0, 1);
STORE_INT(deadline_fifo_batch_store, &dd->fifo_batch, 0, INT_MAX);
@@ -778,6 +780,28 @@ STORE_INT(deadline_fifo_batch_store, &dd->fifo_batch, 0, INT_MAX);
#undef STORE_INT
#undef STORE_JIFFIES
+/*
+ * prio_aging_expire must be positive: a value of zero would make the
+ * priority aging path dispatch best-effort and idle requests ahead of
+ * pending real-time requests through "now - 0 == now", a classic priority
+ * inversion. Reject zero and negative values instead of clamping, so that
+ * a misconfiguration is reported rather than silently accepted.
+ */
+static ssize_t deadline_prio_aging_expire_store(struct elevator_queue *e,
+ const char *page, size_t count)
+{
+ struct deadline_data *dd = e->elevator_data;
+ int val, ret;
+
+ ret = kstrtoint(page, 0, &val);
+ if (ret < 0)
+ return ret;
+ if (val <= 0)
+ return -EINVAL;
+ dd->prio_aging_expire = msecs_to_jiffies(val);
+ return count;
+}
+
#define DD_ATTR(name) \
__ATTR(name, 0644, deadline_##name##_show, deadline_##name##_store)
--
2.34.1
next prev parent reply other threads:[~2026-08-31 11:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 11:01 [PATCH v2 0/4] block/mq-deadline: add prio_enable switch and harden prio_aging_expire Ye Bin
2026-08-31 11:01 ` Ye Bin [this message]
2026-08-31 11:01 ` [PATCH v2 2/4] block/mq-deadline: add prio_enable switch for I/O priority control Ye Bin
2026-08-31 11:01 ` [PATCH v2 3/4] block/mq-deadline: add module parameter for prio_enable Ye Bin
2026-08-31 11:01 ` [PATCH v2 4/4] docs: block: document prio_enable and prio_aging_expire in deadline-iosched Ye Bin
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=20260831110144.2648156-2-yebin@huaweicloud.com \
--to=yebin@huaweicloud.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox