lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 22 May 2024 15:48:29 +0800
From: Yunlong Xing <yunlong.xing@...soc.com>
To: <axboe@...nel.dk>, <yunlongxing23@...il.com>, <niuzhiguo84@...il.com>,
        <Hao_hao.Wang@...soc.com>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] loop: inherit the ioprio in loop woker thread

The loop worker thread only inherit the blkcg of original request,
but does not inherit it's ioprio. So, when a task with the high
ioprio but in root blkcg accesses the loop device, the worker
thread handle this cmd with a normal ioprio. This results in the
request of high ioprio task doesn't be prioritized.

Signed-off-by: Yunlong Xing <yunlong.xing@...soc.com>
---
 drivers/block/loop.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 28a95fd366fe..404ac113c71b 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -442,7 +442,6 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 	cmd->iocb.ki_filp = file;
 	cmd->iocb.ki_complete = lo_rw_aio_complete;
 	cmd->iocb.ki_flags = IOCB_DIRECT;
-	cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
 
 	if (rw == ITER_SOURCE)
 		ret = call_write_iter(file, &cmd->iocb, &iter);
@@ -1856,6 +1855,9 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 		break;
 	}
 
+	/* get request's ioprio */
+	cmd->iocb.ki_ioprio = rq->ioprio;
+
 	/* always use the first bio's css */
 	cmd->blkcg_css = NULL;
 	cmd->memcg_css = NULL;
@@ -1886,12 +1888,18 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
 	int ret = 0;
 	struct mem_cgroup *old_memcg = NULL;
 	const bool use_aio = cmd->use_aio;
+	int ori_ioprio = 0;
+	int cmd_ioprio = cmd->iocb.ki_ioprio;
 
 	if (write && (lo->lo_flags & LO_FLAGS_READ_ONLY)) {
 		ret = -EIO;
 		goto failed;
 	}
 
+	ori_ioprio = get_current_ioprio();
+	if (ori_ioprio != cmd_ioprio)
+		set_task_ioprio(current, cmd_ioprio);
+
 	if (cmd_blkcg_css)
 		kthread_associate_blkcg(cmd_blkcg_css);
 	if (cmd_memcg_css)
@@ -1913,6 +1921,10 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
 		set_active_memcg(old_memcg);
 		css_put(cmd_memcg_css);
 	}
+
+	if (ori_ioprio != cmd_ioprio)
+		set_task_ioprio(current, ori_ioprio);
+
  failed:
 	/* complete non-aio request */
 	if (!use_aio || ret) {
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ