From: Jens Axboe <axboe@kernel.dk>
To: linux-block@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 2/2] block: make __get_task_ioprio() easier to read
Date: Mon, 8 Jan 2024 11:59:56 -0700 [thread overview]
Message-ID: <20240108190113.1264200-3-axboe@kernel.dk> (raw)
In-Reply-To: <20240108190113.1264200-1-axboe@kernel.dk>
We don't need to do any gymnastics if we don't have an io_context
assigned at all, so just return early with our default priority.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
include/linux/ioprio.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index d6a9b5b7ed16..db1249cd9692 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -59,13 +59,13 @@ static inline int __get_task_ioprio(struct task_struct *p)
struct io_context *ioc = p->io_context;
int prio;
+ if (!ioc)
+ return IOPRIO_DEFAULT;
+
if (p != current)
lockdep_assert_held(&p->alloc_lock);
- if (ioc)
- prio = ioc->ioprio;
- else
- prio = IOPRIO_DEFAULT;
+ prio = ioc->ioprio;
if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
task_nice_ioprio(p));
--
2.43.0
next prev parent reply other threads:[~2024-01-08 19:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 18:59 [PATCHSET 0/2] Optimize get_current_ioprio() a bit Jens Axboe
2024-01-08 18:59 ` [PATCH 1/2] block: move __get_task_ioprio() into header file Jens Axboe
2024-01-08 19:24 ` Bart Van Assche
2024-01-08 19:27 ` Jens Axboe
2024-01-09 3:20 ` Chaitanya Kulkarni
2024-01-08 18:59 ` Jens Axboe [this message]
2024-01-08 19:22 ` [PATCH 2/2] block: make __get_task_ioprio() easier to read Bart Van Assche
2024-01-08 19:26 ` Jens Axboe
2024-01-09 3:23 ` Chaitanya Kulkarni
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=20240108190113.1264200-3-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@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.