From: chengkaitao <pilgrimtao@gmail.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
chengkaitao <chengkaitao@kylinos.cn>
Subject: [PATCH] block/mq-deadline: Replace DD_PRIO_MAX with DD_PRIO_COUNT
Date: Fri, 29 Aug 2025 09:54:44 +0800 [thread overview]
Message-ID: <20250829015444.91369-1-pilgrimtao@gmail.com> (raw)
From: chengkaitao <chengkaitao@kylinos.cn>
Remove redundant DD_PRIO_MAX and enum types, Move DD_PRIO_COUNT
into enum dd_prio{}, and similarly for DD_DIR_COUNT.
Signed-off-by: chengkaitao <chengkaitao@kylinos.cn>
---
block/mq-deadline.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index b9b7cdf1d3c9..1a031922c447 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -41,19 +41,16 @@ static const int fifo_batch = 16; /* # of sequential requests treated as o
enum dd_data_dir {
DD_READ = READ,
DD_WRITE = WRITE,
+ DD_DIR_COUNT = 2
};
-enum { DD_DIR_COUNT = 2 };
-
enum dd_prio {
- DD_RT_PRIO = 0,
- DD_BE_PRIO = 1,
- DD_IDLE_PRIO = 2,
- DD_PRIO_MAX = 2,
+ DD_RT_PRIO,
+ DD_BE_PRIO,
+ DD_IDLE_PRIO,
+ DD_PRIO_COUNT
};
-enum { DD_PRIO_COUNT = 3 };
-
/*
* I/O statistics per I/O priority. It is fine if these counters overflow.
* What matters is that these counters are at least as wide as
@@ -441,7 +438,7 @@ static struct request *dd_dispatch_prio_aged_requests(struct deadline_data *dd,
if (prio_cnt < 2)
return NULL;
- for (prio = DD_BE_PRIO; prio <= DD_PRIO_MAX; prio++) {
+ for (prio = DD_BE_PRIO; prio < DD_PRIO_COUNT; prio++) {
rq = __dd_dispatch_request(dd, &dd->per_prio[prio],
now - dd->prio_aging_expire);
if (rq)
@@ -475,7 +472,7 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
* Next, dispatch requests in priority order. Ignore lower priority
* requests if any higher priority requests are pending.
*/
- for (prio = 0; prio <= DD_PRIO_MAX; prio++) {
+ for (prio = 0; prio < DD_PRIO_COUNT; prio++) {
rq = __dd_dispatch_request(dd, &dd->per_prio[prio], now);
if (rq || dd_queued(dd, prio))
break;
@@ -530,7 +527,7 @@ static void dd_exit_sched(struct elevator_queue *e)
struct deadline_data *dd = e->elevator_data;
enum dd_prio prio;
- for (prio = 0; prio <= DD_PRIO_MAX; prio++) {
+ for (prio = 0; prio < DD_PRIO_COUNT; prio++) {
struct dd_per_prio *per_prio = &dd->per_prio[prio];
const struct io_stats_per_prio *stats = &per_prio->stats;
uint32_t queued;
@@ -565,7 +562,7 @@ static int dd_init_sched(struct request_queue *q, struct elevator_queue *eq)
eq->elevator_data = dd;
- for (prio = 0; prio <= DD_PRIO_MAX; prio++) {
+ for (prio = 0; prio < DD_PRIO_COUNT; prio++) {
struct dd_per_prio *per_prio = &dd->per_prio[prio];
INIT_LIST_HEAD(&per_prio->dispatch);
@@ -748,7 +745,7 @@ static bool dd_has_work(struct blk_mq_hw_ctx *hctx)
struct deadline_data *dd = hctx->queue->elevator->elevator_data;
enum dd_prio prio;
- for (prio = 0; prio <= DD_PRIO_MAX; prio++)
+ for (prio = 0; prio < DD_PRIO_COUNT; prio++)
if (dd_has_work_for_prio(&dd->per_prio[prio]))
return true;
--
2.39.5 (Apple Git-154)
next reply other threads:[~2025-08-29 1:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 1:54 chengkaitao [this message]
2025-08-29 4:38 ` Bart Van Assche
2025-08-29 6:19 ` Tao pilgrim
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=20250829015444.91369-1-pilgrimtao@gmail.com \
--to=pilgrimtao@gmail.com \
--cc=axboe@kernel.dk \
--cc=chengkaitao@kylinos.cn \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®