On Tue, Feb 3, 2026, at 15:58, Andy Shevchenko wrote:
> On Tue, Feb 03, 2026 at 08:12:57PM +0800, kernel test robot wrote:
>
>> kernel test robot noticed the following build warnings:
>
> Yeah, you need to go for the full stack of these calls and mark the
> bottom one with __diag() to avoid these warnings. That's my understanding
> and what BPF people required. Chasing this one-by-one would produce
> unneeded churn.
>From what I can tell, I can just move the printf attribute
to the __ftrace_vbprintk() definition to make this bit work.
I'll send an updated patch:
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -197,6 +197,7 @@ struct notifier_block module_trace_bprintk_format_nb = {
.notifier_call = module_trace_bprintk_format_notify,
};
+__printf(2, 3)
int __trace_bprintk(unsigned long ip, const char *fmt, ...)
{
int ret;
There are unrelated warnings for BPF that I managed to
shut up the same way, doing
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index b54ec0e945aa..45d026fc4e8a 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -1046,6 +1046,7 @@ int bpf_bprintf_prepare(const char *fmt, u32 fmt_size,
const u64 *raw_args,
return err;
}
+__printf(3, 0)
BPF_CALL_5(bpf_snprintf, char *, str, u32, str_size, char *, fmt,
const void *, args, u32, data_len)
{
diff --git a/kernel/bpf/stream.c b/kernel/bpf/stream.c
index 24730df55e69..816fd7fba3d2 100644
--- a/kernel/bpf/stream.c
+++ b/kernel/bpf/stream.c
@@ -212,6 +212,7 @@ __bpf_kfunc_start_defs();
* Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the
* enum in headers.
*/
+__printf(2, 0)
__bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const
void *args,
u32 len__sz, struct bpf_prog_aux *aux)
{
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index eadaef8592a3..2d3de71ab86a 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -359,6 +359,7 @@ static const struct bpf_func_proto
bpf_probe_write_user_proto = {
#define MAX_TRACE_PRINTK_VARARGS 3
#define BPF_TRACE_PRINTK_SIZE 1024
+__printf(1, 0)
BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
u64, arg2, u64, arg3)
{
@@ -412,6 +413,7 @@ const struct bpf_func_proto
*bpf_get_trace_printk_proto(void)
return &bpf_trace_printk_proto;
}
+__printf(1, 0)
BPF_CALL_4(bpf_trace_vprintk, char *, fmt, u32, fmt_size, const void *, args,
u32, data_len)
{
@@ -455,6 +457,7 @@ const struct bpf_func_proto
*bpf_get_trace_vprintk_proto(void)
return &bpf_trace_vprintk_proto;
}
+__printf(2, 0)
BPF_CALL_5(bpf_seq_printf, struct seq_file *, m, char *, fmt, u32, fmt_size,
const void *, args, u32, data_len)
{
Since those functions have no callers, the annotation on the
print functions does nothing.
With those added, and a couple of drivers fixed to use the
correct printf attributes, the only remaining one I see is
in samples/trace_events/trace-events-sample.h:
In file included from /home/arnd/arm-soc/include/trace/define_trace.h:132,
from
/home/arnd/arm-soc/samples/trace_events/trace-events-sample.h:640,
from
/home/arnd/arm-soc/samples/trace_events/trace-events-sample.c:12:
/home/arnd/arm-soc/samples/trace_events/./trace-events-sample.h: In function
'trace_event_get_offsets_foo_bar':
/home/arnd/arm-soc/include/trace/stages/stage5_get_offsets.h:33:31: error:
function 'trace_event_get_offsets_foo_bar' might be a candidate for
'gnu_printf' format attribute [-Werror=suggest-attribute=format]
33 | { (void)sizeof(struct _test_no_array_##item *); }
| ^~~~~~~~~~~~~~~
/home/arnd/arm-soc/include/trace/trace_events.h:285:9: note: in definition of
macro 'DECLARE_EVENT_CLASS'
285 | tstruct;
\
| ^~~~~~~
/home/arnd/arm-soc/include/trace/trace_events.h:43:30: note: in expansion of
macro 'PARAMS'
43 | PARAMS(tstruct), \
| ^~~~~~
/home/arnd/arm-soc/samples/trace_events/./trace-events-sample.h:291:1: note: in
expansion of macro 'TRACE_EVENT'
291 | TRACE_EVENT(foo_bar,
| ^~~~~~~~~~~
/home/arnd/arm-soc/samples/trace_events/./trace-events-sample.h:299:9: note: in
expansion of macro 'TP_STRUCT__entry'
299 | TP_STRUCT__entry(
| ^~~~~~~~~~~~~~~~
/home/arnd/arm-soc/samples/trace_events/./trace-events-sample.h:301:17: note:
in expansion of macro '__field'
301 | __field( int, bar )
| ^~~~~~~
/home/arnd/arm-soc/samples/trace_events/./trace-events-sample.h: In function
'do_trace_event_raw_event_foo_bar':
I don't think this is related, but I also don't see an obvious
workaround other than forcing the warning off around that
definition.
Arnd