Jens Axboe <axboe@xxxxxxxxx> 于2024年5月23日周四 21:04写道: > > On 5/23/24 12:04 AM, yunlong xing wrote: > > Bart Van Assche <bvanassche@xxxxxxx> ?2024?5?23??? 02:12??? > >> > >> On 5/22/24 10:57, Jens Axboe wrote: > >>> On 5/22/24 11:38 AM, Bart Van Assche wrote: > >>>> On 5/22/24 00:48, Yunlong Xing wrote: > >>>>> @@ -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) { > >>>> > >>>> Does adding this call in the hot path have a measurable performance impact? > >>> > >>> It's loop, I would not be concerned with overhead. But it does look pretty > >>> bogus to modify the task ioprio from here. > >> > >> Hi Jens, > >> > >> Maybe Yunlong uses that call to pass the I/O priority to the I/O submitter? > >> > >> I think that it is easy to pass the I/O priority to the kiocb submitted by > >> lo_rw_aio() without calling set_task_ioprio(). > >> > >> lo_read_simple() and lo_write_simple() however call vfs_iter_read() / > >> vfs_iter_write(). This results in a call of do_iter_readv_writev() and > >> init_sync_kiocb(). The latter function calls get_current_ioprio(). This is > >> probably why the set_task_ioprio() call has been added? > > > > Yeah that's why I call set_task_ioprio. I want to the loop kwoker > > task?submit I/O to the real disk device?can pass the iopriority of the > > loop device request? both lo_rw_aio() and > > lo_read_simple()/lo_write_simple(). > > And that's a totally backwards and suboptimal way to do it. The task > priority is only used as a last resort lower down, if the IO itself > hasn't been appropriately marked. > > Like I said, it's back to the drawing board on this patch, there's no > way it's acceptable in its current form. > > -- > Jens Axboe > Thanks for your advice. So, you can't accept pass the ioprio by set_task_ioprio? If only the method of lo_rw_aio() counld you accept? I don't want to submit this part of the modifications separately. I just want to know, this is ok to you or not? @@ -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;