From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Barret Rhoden <brho@google.com>,
Matt Bobrowski <mattbobrowski@google.com>,
kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v1 09/11] libbpf: Add bpf_stream_printk() macro
Date: Thu, 08 May 2025 16:31:43 -0700 [thread overview]
Message-ID: <82fa97637f995a1a004221b8d4e869e775a5f008.camel@gmail.com> (raw)
In-Reply-To: <20250507171720.1958296-10-memxor@gmail.com>
On Wed, 2025-05-07 at 10:17 -0700, Kumar Kartikeya Dwivedi wrote:
[...]
> diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> index a50773d4616e..1a748c21e358 100644
> --- a/tools/lib/bpf/bpf_helpers.h
> +++ b/tools/lib/bpf/bpf_helpers.h
[...]
> /* Use __bpf_printk when bpf_printk call has 3 or fewer fmt args
> - * Otherwise use __bpf_vprintk
> + * Otherwise use __bpf_vprintk. Virtualize choices so stream printk
> + * can override it to bpf_stream_vprintk.
> */
> -#define ___bpf_pick_printk(...) \
> - ___bpf_nth(_, ##__VA_ARGS__, __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, \
> - __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, \
> - __bpf_vprintk, __bpf_vprintk, __bpf_printk /*3*/, __bpf_printk /*2*/,\
> - __bpf_printk /*1*/, __bpf_printk /*0*/)
> +#define ___bpf_pick_printk(choice, choice_3, ...) \
> + ___bpf_nth(_, ##__VA_ARGS__, choice, choice, choice, \
> + choice, choice, choice, choice, \
> + choice, choice, choice_3 /*3*/, choice_3 /*2*/, \
> + choice_3 /*1*/, choice_3 /*0*/)
>
> /* Helper macro to print out debug messages */
> -#define bpf_printk(fmt, args...) ___bpf_pick_printk(args)(fmt, ##args)
> +#define __bpf_trace_printk(fmt, args...) \
> + ___bpf_pick_printk(__bpf_vprintk, __bpf_printk, args)(fmt, ##args)
> +#define __bpf_stream_printk(stream, fmt, args...) \
> + ___bpf_pick_printk(__bpf_stream_vprintk, __bpf_stream_vprintk, args)(stream, fmt, ##args)
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
These two parameters are identical,
why is ___bpf_pick_printk is necessary in such case?
> +
> +#define bpf_stream_printk(stream, fmt, args...) __bpf_stream_printk(stream, fmt, ##args)
> +
> +#define bpf_printk(arg, args...) __bpf_trace_printk(arg, ##args)
>
> struct bpf_iter_num;
>
next prev parent reply other threads:[~2025-05-08 23:31 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 17:17 [PATCH bpf-next v1 00/11] BPF Standard Streams Kumar Kartikeya Dwivedi
2025-05-07 17:17 ` [PATCH bpf-next v1 01/11] bpf: Introduce bpf_dynptr_from_mem_slice Kumar Kartikeya Dwivedi
2025-05-09 17:19 ` Eduard Zingerman
2025-05-09 21:11 ` Andrii Nakryiko
2025-05-07 17:17 ` [PATCH bpf-next v1 02/11] bpf: Introduce BPF standard streams Kumar Kartikeya Dwivedi
2025-05-08 23:54 ` Eduard Zingerman
2025-05-09 0:10 ` Kumar Kartikeya Dwivedi
2025-05-07 17:17 ` [PATCH bpf-next v1 03/11] bpf: Add function to extract program source info Kumar Kartikeya Dwivedi
2025-05-08 10:30 ` kernel test robot
2025-05-08 20:15 ` Eduard Zingerman
2025-05-08 23:32 ` Kumar Kartikeya Dwivedi
2025-05-09 21:17 ` Andrii Nakryiko
2025-05-07 17:17 ` [PATCH bpf-next v1 04/11] bpf: Add function to find program from stack trace Kumar Kartikeya Dwivedi
2025-05-08 23:07 ` Eduard Zingerman
2025-05-08 23:29 ` Kumar Kartikeya Dwivedi
2025-05-07 17:17 ` [PATCH bpf-next v1 05/11] bpf: Add dump_stack() analogue to print to BPF stderr Kumar Kartikeya Dwivedi
2025-05-08 22:38 ` Eduard Zingerman
2025-05-08 23:29 ` Kumar Kartikeya Dwivedi
2025-05-07 17:17 ` [PATCH bpf-next v1 06/11] bpf: Report may_goto timeout " Kumar Kartikeya Dwivedi
2025-05-08 12:53 ` kernel test robot
2025-05-09 6:22 ` Eduard Zingerman
2025-05-09 9:19 ` Alan Maguire
2025-05-07 17:17 ` [PATCH bpf-next v1 07/11] bpf: Report rqspinlock deadlocks/timeout " Kumar Kartikeya Dwivedi
2025-05-07 17:17 ` [PATCH bpf-next v1 08/11] bpf: Report arena faults " Kumar Kartikeya Dwivedi
2025-05-09 19:28 ` Eduard Zingerman
2025-05-09 20:01 ` Kumar Kartikeya Dwivedi
2025-05-09 20:07 ` Eduard Zingerman
2025-05-09 20:10 ` Kumar Kartikeya Dwivedi
2025-05-09 20:17 ` Eduard Zingerman
2025-05-07 17:17 ` [PATCH bpf-next v1 09/11] libbpf: Add bpf_stream_printk() macro Kumar Kartikeya Dwivedi
2025-05-08 23:31 ` Eduard Zingerman [this message]
2025-05-08 23:33 ` Kumar Kartikeya Dwivedi
2025-05-09 6:16 ` Eduard Zingerman
2025-05-09 21:28 ` Andrii Nakryiko
2025-05-08 23:41 ` Alexei Starovoitov
2025-05-08 23:48 ` Kumar Kartikeya Dwivedi
2025-05-08 23:50 ` Kumar Kartikeya Dwivedi
2025-05-09 21:26 ` Andrii Nakryiko
2025-05-07 17:17 ` [PATCH bpf-next v1 10/11] bpftool: Add support for dumping streams Kumar Kartikeya Dwivedi
2025-05-08 10:41 ` Quentin Monnet
2025-05-08 23:41 ` Kumar Kartikeya Dwivedi
2025-05-09 6:21 ` Eduard Zingerman
2025-05-09 17:31 ` Alexei Starovoitov
2025-05-09 18:31 ` Eduard Zingerman
2025-05-09 18:48 ` Alexei Starovoitov
2025-05-09 19:37 ` Eduard Zingerman
2025-05-09 19:50 ` Kumar Kartikeya Dwivedi
2025-05-09 21:33 ` Andrii Nakryiko
2025-05-12 20:51 ` Kumar Kartikeya Dwivedi
2025-05-12 21:35 ` Andrii Nakryiko
2025-05-12 21:50 ` Alexei Starovoitov
2025-05-12 21:56 ` Kumar Kartikeya Dwivedi
2025-05-12 22:07 ` Alexei Starovoitov
2025-05-07 17:17 ` [PATCH bpf-next v1 11/11] selftests/bpf: Add tests for prog streams Kumar Kartikeya Dwivedi
2025-05-09 17:18 ` Eduard Zingerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=82fa97637f995a1a004221b8d4e869e775a5f008.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brho@google.com \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=mattbobrowski@google.com \
--cc=memxor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.