提交 e181f2f8 编写于 作者: P Pavel Begunkov 提交者: Joseph Qi

io_uring: get rid of delayed mm check

to #26323588

commit 1cb1edb2f5ba8a3e8d47ded391007c6fe3ac0ad7 upstream.

Fail fast if can't grab mm, so past that requests always have an mm
when required. This allows us to remove req->user altogether.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 93ba78fd
...@@ -553,7 +553,6 @@ struct io_kiocb { ...@@ -553,7 +553,6 @@ struct io_kiocb {
* llist_node is only used for poll deferred completions * llist_node is only used for poll deferred completions
*/ */
struct llist_node llist_node; struct llist_node llist_node;
bool has_user;
bool in_async; bool in_async;
bool needs_fixed_file; bool needs_fixed_file;
u8 opcode; u8 opcode;
...@@ -2053,9 +2052,6 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req, ...@@ -2053,9 +2052,6 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
return iorw->size; return iorw->size;
} }
if (!req->has_user)
return -EFAULT;
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (req->ctx->compat) if (req->ctx->compat)
return compat_import_iovec(rw, buf, sqe_len, UIO_FASTIOV, return compat_import_iovec(rw, buf, sqe_len, UIO_FASTIOV,
...@@ -4443,7 +4439,6 @@ static void io_wq_submit_work(struct io_wq_work **workptr) ...@@ -4443,7 +4439,6 @@ static void io_wq_submit_work(struct io_wq_work **workptr)
} }
if (!ret) { if (!ret) {
req->has_user = (work->flags & IO_WQ_WORK_HAS_MM) != 0;
req->in_async = true; req->in_async = true;
do { do {
ret = io_issue_sqe(req, NULL, &nxt, false); ret = io_issue_sqe(req, NULL, &nxt, false);
...@@ -4947,6 +4942,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr, ...@@ -4947,6 +4942,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
const struct io_uring_sqe *sqe; const struct io_uring_sqe *sqe;
struct io_kiocb *req; struct io_kiocb *req;
int err;
req = io_get_req(ctx, statep); req = io_get_req(ctx, statep);
if (unlikely(!req)) { if (unlikely(!req)) {
...@@ -4963,20 +4959,23 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr, ...@@ -4963,20 +4959,23 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
submitted++; submitted++;
if (unlikely(req->opcode >= IORING_OP_LAST)) { if (unlikely(req->opcode >= IORING_OP_LAST)) {
io_cqring_add_event(req, -EINVAL); err = -EINVAL;
fail_req:
io_cqring_add_event(req, err);
io_double_put_req(req); io_double_put_req(req);
break; break;
} }
if (io_op_defs[req->opcode].needs_mm && !*mm) { if (io_op_defs[req->opcode].needs_mm && !*mm) {
mm_fault = mm_fault || !mmget_not_zero(ctx->sqo_mm); mm_fault = mm_fault || !mmget_not_zero(ctx->sqo_mm);
if (!mm_fault) { if (unlikely(mm_fault)) {
use_mm(ctx->sqo_mm); err = -EFAULT;
*mm = ctx->sqo_mm; goto fail_req;
} }
use_mm(ctx->sqo_mm);
*mm = ctx->sqo_mm;
} }
req->has_user = *mm != NULL;
req->in_async = async; req->in_async = async;
req->needs_fixed_file = async; req->needs_fixed_file = async;
trace_io_uring_submit_sqe(ctx, req->opcode, req->user_data, trace_io_uring_submit_sqe(ctx, req->opcode, req->user_data,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册