Jens,

Can you give me an acked-by on this patch and I can take the series through
my tree.

Or perhaps this doesn't even need to test the trace_async_init flag and can
always do the work queue? Does blk_trace ever do tracing at boot up? That
is, before user space starts?

Thanks,

-- Steve


On Wed, 28 Jan 2026 20:55:54 +0800
Yaxiong Tian <[email protected]> wrote:

> The init_blk_tracer() function causes significant boot delay as it
> waits for the trace_event_sem lock held by trace_event_update_all().
> Specifically, its child function register_trace_event() requires
> this lock, which is occupied for an extended period during boot.
> 
> To resolve this, when the trace_async_init parameter is enabled, the
> execution of primary init_blk_tracer() is moved to the trace_init_wq
> workqueue, allowing it to run asynchronously. and prevent blocking
> the main boot thread.
> 
> Signed-off-by: Yaxiong Tian <[email protected]>
> ---
>  kernel/trace/blktrace.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index d031c8d80be4..56c7270ec447 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -1832,7 +1832,9 @@ static struct trace_event trace_blk_event = {
>       .funcs          = &trace_blk_event_funcs,
>  };
>  
> -static int __init init_blk_tracer(void)
> +static struct work_struct blktrace_works __initdata;
> +
> +static int __init __init_blk_tracer(void)
>  {
>       if (!register_trace_event(&trace_blk_event)) {
>               pr_warn("Warning: could not register block events\n");
> @@ -1852,6 +1854,25 @@ static int __init init_blk_tracer(void)
>       return 0;
>  }
>  
> +static void __init blktrace_works_func(struct work_struct *work)
> +{
> +     __init_blk_tracer();
> +}
> +
> +static int __init init_blk_tracer(void)
> +{
> +     int ret = 0;
> +
> +     if (trace_init_wq && trace_async_init) {
> +             INIT_WORK(&blktrace_works, blktrace_works_func);
> +             queue_work(trace_init_wq, &blktrace_works);
> +     } else {
> +             ret = __init_blk_tracer();
> +     }
> +
> +     return ret;
> +}
> +
>  device_initcall(init_blk_tracer);
>  
>  static int blk_trace_remove_queue(struct request_queue *q)


Reply via email to