Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: branch: Fix inverted check on stat tracer registration

init_annotated_branch_stats() and all_annotated_branch_stats() check the
return value of register_stat_tracer() with "if (!ret)", but
register_stat_tracer() returns 0 on success and a negative errno on
failure. The inverted check causes the warning to be printed on every
successful registration, e.g.:

Warning: could not register annotated branches stats

while leaving real failures silent. The initcall also returned a
hard-coded 1 instead of the actual error.

Invert the check and propagate ret so that the warning fires on real
errors and the initcall reports the correct status.

Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: https://patch.msgid.link/20260420-tracing-v1-1-d8f4cd0d6af1@debian.org
Fixes: 002bb86d8d42 ("tracing/ftrace: separate events tracing and stats tracing engine")
Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Breno Leitao and committed by
Steven Rostedt
3b75dd76 254f4963

+4 -4
+4 -4
kernel/trace/trace_branch.c
··· 373 373 int ret; 374 374 375 375 ret = register_stat_tracer(&annotated_branch_stats); 376 - if (!ret) { 376 + if (ret) { 377 377 printk(KERN_WARNING "Warning: could not register " 378 378 "annotated branches stats\n"); 379 - return 1; 379 + return ret; 380 380 } 381 381 return 0; 382 382 } ··· 438 438 int ret; 439 439 440 440 ret = register_stat_tracer(&all_branch_stats); 441 - if (!ret) { 441 + if (ret) { 442 442 printk(KERN_WARNING "Warning: could not register " 443 443 "all branches stats\n"); 444 - return 1; 444 + return ret; 445 445 } 446 446 return 0; 447 447 }