Skip to content

Commit 1c48f7a

Browse files
Yaxiong Tianrostedt
authored andcommitted
tracing: Rename eval_map_wq and allow other parts of tracing use it
The eval_map_work_func() function, though queued in eval_map_wq, holds the trace_event_sem read-write lock for a long time during kernel boot. This causes blocking issues for other functions. Rename eval_map_wq to trace_init_wq and make it global, thereby allowing other parts of tracing to schedule work on this queue asynchronously and avoiding blockage of the main boot thread. Link: https://patch.msgid.link/20260204015344.162818-1-tianyaxiong@kylinos.cn Suggested-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 02b75ec commit 1c48f7a

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

kernel/trace/trace.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10785,7 +10785,7 @@ int tracing_init_dentry(void)
1078510785
extern struct trace_eval_map *__start_ftrace_eval_maps[];
1078610786
extern struct trace_eval_map *__stop_ftrace_eval_maps[];
1078710787

10788-
static struct workqueue_struct *eval_map_wq __initdata;
10788+
struct workqueue_struct *trace_init_wq __initdata;
1078910789
static struct work_struct eval_map_work __initdata;
1079010790
static struct work_struct tracerfs_init_work __initdata;
1079110791

@@ -10801,15 +10801,15 @@ static int __init trace_eval_init(void)
1080110801
{
1080210802
INIT_WORK(&eval_map_work, eval_map_work_func);
1080310803

10804-
eval_map_wq = alloc_workqueue("eval_map_wq", WQ_UNBOUND, 0);
10805-
if (!eval_map_wq) {
10806-
pr_err("Unable to allocate eval_map_wq\n");
10804+
trace_init_wq = alloc_workqueue("trace_init_wq", WQ_UNBOUND, 0);
10805+
if (!trace_init_wq) {
10806+
pr_err("Unable to allocate trace_init_wq\n");
1080710807
/* Do work here */
1080810808
eval_map_work_func(&eval_map_work);
1080910809
return -ENOMEM;
1081010810
}
1081110811

10812-
queue_work(eval_map_wq, &eval_map_work);
10812+
queue_work(trace_init_wq, &eval_map_work);
1081310813
return 0;
1081410814
}
1081510815

@@ -10818,8 +10818,8 @@ subsys_initcall(trace_eval_init);
1081810818
static int __init trace_eval_sync(void)
1081910819
{
1082010820
/* Make sure the eval map updates are finished */
10821-
if (eval_map_wq)
10822-
destroy_workqueue(eval_map_wq);
10821+
if (trace_init_wq)
10822+
destroy_workqueue(trace_init_wq);
1082310823
return 0;
1082410824
}
1082510825

@@ -10980,9 +10980,9 @@ static __init int tracer_init_tracefs(void)
1098010980
if (ret)
1098110981
return 0;
1098210982

10983-
if (eval_map_wq) {
10983+
if (trace_init_wq) {
1098410984
INIT_WORK(&tracerfs_init_work, tracer_init_tracefs_work_func);
10985-
queue_work(eval_map_wq, &tracerfs_init_work);
10985+
queue_work(trace_init_wq, &tracerfs_init_work);
1098610986
} else {
1098710987
tracer_init_tracefs_work_func(NULL);
1098810988
}

kernel/trace/trace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ extern cpumask_var_t __read_mostly tracing_buffer_mask;
769769
extern unsigned long nsecs_to_usecs(unsigned long nsecs);
770770

771771
extern unsigned long tracing_thresh;
772+
extern struct workqueue_struct *trace_init_wq __initdata;
772773

773774
/* PID filtering */
774775

0 commit comments

Comments
 (0)