On 8/28/21 1:20 AM, Dave Marchevsky wrote: > The __bpf_printk convenience macro was using a 'char' fmt string holder > as it predates support for globals in libbpf. Move to more efficient > 'static const char', but provide a fallback to the old way via > BPF_NO_GLOBAL_DATA so users on old kernels can still use the macro. > > Signed-off-by: Dave Marchevsky <davemarchevsky@xxxxxx> > --- > tools/lib/bpf/bpf_helpers.h | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h > index 5f087306cdfe..a1d5ec6f285c 100644 > --- a/tools/lib/bpf/bpf_helpers.h > +++ b/tools/lib/bpf/bpf_helpers.h > @@ -216,10 +216,16 @@ enum libbpf_tristate { > ___param, sizeof(___param)); \ > }) > > +#ifdef BPF_NO_GLOBAL_DATA > +#define BPF_PRINTK_FMT_TYPE char > +#else > +#define BPF_PRINTK_FMT_TYPE static const char The reference_tracking prog test is failing as a result of this. Specifically, it fails to load bpf_sk_lookup_test0 prog, which has a bpf_printk: 47: (b4) w3 = 0 48: (18) r1 = 0x0 50: (b4) w2 = 7 51: (85) call bpf_trace_printk#6 R1 type=inv expected=fp, pkt, pkt_meta, map_key, map_value, mem, rdonly_buf, rdwr_buf Setting BPF_NO_GLOBAL_DATA in the test results in a pass > +#endif > + > /* Helper macro to print out debug messages */ > #define __bpf_printk(fmt, ...) \ > ({ \ > - char ____fmt[] = fmt; \ > + BPF_PRINTK_FMT_TYPE ____fmt[] = fmt; \ > bpf_trace_printk(____fmt, sizeof(____fmt), \ > ##__VA_ARGS__); \ > }) >