Re: [PATCH v3] io_uring: Statistics of the true utilization of sq threads.

From: Jens Axboe
Date: Wed Nov 15 2023 - 08:51:24 EST


On 11/15/23 5:18 AM, Xiaobing Li wrote:
> v3:
> 1.Since the sq thread has a while(1) structure, during this process,
> there may be a lot of time that is not processing IO but does not
> exceed the timeout period, therefore, the sqpoll thread will keep
> running and will keep occupying the CPU. Obviously, the CPU is wasted at
> this time;Our goal is to count the part of the time that the sqpoll
> thread actually processes IO, so as to reflect the part of the CPU it
> uses to process IO, which can be used to help improve the actual
> utilization of the CPU in the future.
>
> 2."work_time" in the code represents the sum of the jiffies count of the
> sq thread actually processing IO, that is, how many milliseconds it
> actually takes to process IO. "total_time" represents the total time
> that the sq thread has elapsed from the beginning of the loop to the
> current time point, that is, how many milliseconds it has spent in
> total.
> The output "SqBusy" represents the percentage of time utilization that
> the sq thread actually uses to process IO.
>
> 3.The task_pid value in the io_sq_data structure should be assigned
> after the sq thread is created, otherwise the pid of its parent
> process will be recorded.
>
> 4.After many tests, we do not need to obtain ctx->uring_lock in advance
> when obtaining ctx->sq_data. We can avoid null pointer references by
> judging that ctx is not null.

This is mixed in with my patch, please just base it on top of the v4
I'll send out now rather than integrate it. And then you'd need that rcu
free patch as well on top of that, then your changes as a separate
patch.

--
Jens Axboe