All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/5] bpf: implement variadic printk helper
@ 2021-08-21  2:58 Dave Marchevsky
  2021-08-21  2:58 ` [PATCH bpf-next 1/5] bpf: merge printk and seq_printf VARARG max macros Dave Marchevsky
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Dave Marchevsky @ 2021-08-21  2:58 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Yonghong Song, Florent Revest, netdev, linux-kselftest,
	Dave Marchevsky

This series introduces a new helper, bpf_trace_vprintk, which functions
like bpf_trace_printk but supports > 3 arguments via a pseudo-vararg u64
array. A libbpf convienience macro, bpf_vprintk, is added to support
true vararg calling style.

Helper functions and macros added during the implementation of
bpf_seq_printf and bpf_snprintf do most of the heavy lifting for
bpf_trace_vprintk. There's no novel format string wrangling here.

Usecase here is straightforward: Giving BPF program writers a more
powerful printk will ease development of BPF programs, particularly
during debugging and testing, where printk tends to be used.

Hypothetically libbpf's bpf_printk convenience macro could be modified
to use bpf_trace_vprintk under the hood. This patchset does not attempt
to do this, though, nor am I confident that it's desired.

This feature was proposed by Andrii in libbpf mirror's issue tracker
[1].

[1] https://github.com/libbpf/libbpf/issues/315

Dave Marchevsky (5):
  bpf: merge printk and seq_printf VARARG max macros
  bpf: add bpf_trace_vprintk helper
  libbpf: Add bpf_vprintk convenience macro
  bpftool: only probe trace_vprintk feature in 'full' mode
  selftests/bpf: add trace_vprintk test prog

 include/linux/bpf.h                           |  3 +
 include/uapi/linux/bpf.h                      | 23 ++++++
 kernel/bpf/core.c                             |  5 ++
 kernel/bpf/helpers.c                          |  6 +-
 kernel/trace/bpf_trace.c                      | 54 ++++++++++++-
 tools/bpf/bpftool/feature.c                   |  1 +
 tools/include/uapi/linux/bpf.h                | 23 ++++++
 tools/lib/bpf/bpf_helpers.h                   | 18 +++++
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../selftests/bpf/prog_tests/trace_vprintk.c  | 75 +++++++++++++++++++
 .../selftests/bpf/progs/trace_vprintk.c       | 25 +++++++
 tools/testing/selftests/bpf/test_bpftool.py   | 22 +++---
 12 files changed, 238 insertions(+), 20 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/trace_vprintk.c
 create mode 100644 tools/testing/selftests/bpf/progs/trace_vprintk.c

-- 
2.30.2


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-08-24 21:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-21  2:58 [PATCH bpf-next 0/5] bpf: implement variadic printk helper Dave Marchevsky
2021-08-21  2:58 ` [PATCH bpf-next 1/5] bpf: merge printk and seq_printf VARARG max macros Dave Marchevsky
2021-08-24  4:38   ` Andrii Nakryiko
2021-08-21  2:58 ` [PATCH bpf-next 2/5] bpf: add bpf_trace_vprintk helper Dave Marchevsky
2021-08-24  4:50   ` Andrii Nakryiko
2021-08-24 17:57     ` Alexei Starovoitov
2021-08-24 18:02       ` Andrii Nakryiko
2021-08-24 18:17         ` Alexei Starovoitov
2021-08-24 18:24           ` Andrii Nakryiko
2021-08-24 21:00             ` Alexei Starovoitov
2021-08-24 21:24               ` Andrii Nakryiko
2021-08-24 21:28                 ` Alexei Starovoitov
2021-08-21  2:58 ` [PATCH bpf-next 3/5] libbpf: Add bpf_vprintk convenience macro Dave Marchevsky
2021-08-24  4:54   ` Andrii Nakryiko
2021-08-21  2:58 ` [PATCH bpf-next 4/5] bpftool: only probe trace_vprintk feature in 'full' mode Dave Marchevsky
2021-08-21  2:58 ` [PATCH bpf-next 5/5] selftests/bpf: add trace_vprintk test prog Dave Marchevsky
2021-08-24  4:59   ` Andrii Nakryiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.