All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florent Revest <revest@chromium.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	KP Singh <kpsingh@kernel.org>,
	Brendan Jackman <jackmanb@google.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf v2] libbpf: Move BPF_SEQ_PRINTF and BPF_SNPRINTF to bpf_helpers.h
Date: Wed, 26 May 2021 18:36:27 +0200	[thread overview]
Message-ID: <CABRcYm+PJpZZr1oWi1g-Y9hzH547ofRoWvFHU=AdegWUKT26og@mail.gmail.com> (raw)
In-Reply-To: <CAEf4BzaHDa5Kujq4S_=0tPvok_ELABp=rwnv_YB4PQvvdy=UnA@mail.gmail.com>

On Wed, May 26, 2021 at 6:34 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Tue, May 25, 2021 at 1:18 PM Florent Revest <revest@chromium.org> wrote:
> >
> > These macros are convenient wrappers around the bpf_seq_printf and
> > bpf_snprintf helpers. They are currently provided by bpf_tracing.h which
> > targets low level tracing primitives. bpf_helpers.h is a better fit.
> >
> > The __bpf_narg and __bpf_apply macros are needed in both files so
> > provided twice and guarded by ifndefs.
> >
> > Reported-by: Andrii Nakryiko <andrii@kernel.org>
> > Signed-off-by: Florent Revest <revest@chromium.org>
> > ---
> >  kernel/bpf/preload/iterators/iterators.bpf.c  |  1 -
> >  tools/lib/bpf/bpf_helpers.h                   | 70 +++++++++++++++++++
> >  tools/lib/bpf/bpf_tracing.h                   | 62 +++-------------
> >  .../bpf/progs/bpf_iter_bpf_hash_map.c         |  1 -
> >  .../selftests/bpf/progs/bpf_iter_bpf_map.c    |  1 -
> >  .../selftests/bpf/progs/bpf_iter_ipv6_route.c |  1 -
> >  .../selftests/bpf/progs/bpf_iter_netlink.c    |  1 -
> >  .../selftests/bpf/progs/bpf_iter_task.c       |  1 -
> >  .../selftests/bpf/progs/bpf_iter_task_btf.c   |  1 -
> >  .../selftests/bpf/progs/bpf_iter_task_file.c  |  1 -
> >  .../selftests/bpf/progs/bpf_iter_task_stack.c |  1 -
> >  .../selftests/bpf/progs/bpf_iter_task_vma.c   |  1 -
> >  .../selftests/bpf/progs/bpf_iter_tcp4.c       |  1 -
> >  .../selftests/bpf/progs/bpf_iter_tcp6.c       |  1 -
> >  .../selftests/bpf/progs/bpf_iter_udp4.c       |  1 -
> >  .../selftests/bpf/progs/bpf_iter_udp6.c       |  1 -
> >  .../selftests/bpf/progs/test_snprintf.c       |  1 -
> >  17 files changed, 80 insertions(+), 67 deletions(-)
> >
> > diff --git a/kernel/bpf/preload/iterators/iterators.bpf.c b/kernel/bpf/preload/iterators/iterators.bpf.c
> > index 52aa7b38e8b8..03af863314ea 100644
> > --- a/kernel/bpf/preload/iterators/iterators.bpf.c
> > +++ b/kernel/bpf/preload/iterators/iterators.bpf.c
> > @@ -2,7 +2,6 @@
> >  /* Copyright (c) 2020 Facebook */
> >  #include <linux/bpf.h>
> >  #include <bpf/bpf_helpers.h>
> > -#include <bpf/bpf_tracing.h>
> >  #include <bpf/bpf_core_read.h>
> >
> >  #pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
> > diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> > index 9720dc0b4605..68d992b30f26 100644
> > --- a/tools/lib/bpf/bpf_helpers.h
> > +++ b/tools/lib/bpf/bpf_helpers.h
> > @@ -158,4 +158,74 @@ enum libbpf_tristate {
> >  #define __kconfig __attribute__((section(".kconfig")))
> >  #define __ksym __attribute__((section(".ksyms")))
> >
> > +#ifndef ___bpf_concat
> > +#define ___bpf_concat(a, b) a ## b
> > +#endif
> > +#ifndef ___bpf_apply
> > +#define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
> > +#endif
> > +#ifndef ___bpf_nth
> > +#define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, N, ...) N
> > +#endif
> > +#ifndef ___bpf_narg
> > +#define ___bpf_narg(...) \
> > +       ___bpf_nth(_, ##__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
> > +#endif
> > +#ifndef ___bpf_empty
> > +#define ___bpf_empty(...) \
> > +       ___bpf_nth(_, ##__VA_ARGS__, N, N, N, N, N, N, N, N, N, N, 0)
> > +#endif
>
> ___bpf_empty doesn't seem to be used, let's remove it for now?
> Otherwise it looks good.

Yes it's never been used, I thought it was introduced "just in case"
so I kept it around but then I'll remove it from both bpf_helpers.h
and bpf_tracing.h

  reply	other threads:[~2021-05-26 16:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 20:18 [PATCH bpf v2] libbpf: Move BPF_SEQ_PRINTF and BPF_SNPRINTF to bpf_helpers.h Florent Revest
2021-05-26  6:35 ` Daniel Borkmann
2021-05-26 15:01   ` Florent Revest
2021-05-26 16:35     ` Andrii Nakryiko
2021-05-26 16:37       ` Florent Revest
2021-05-26 16:34 ` Andrii Nakryiko
2021-05-26 16:36   ` Florent Revest [this message]
2021-05-26 17:01     ` Andrii Nakryiko

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='CABRcYm+PJpZZr1oWi1g-Y9hzH547ofRoWvFHU=AdegWUKT26og@mail.gmail.com' \
    --to=revest@chromium.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jackmanb@google.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.