Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 3/8] samples: bpf: Add BPF support for XDP samples helper
Date: Thu, 22 Jul 2021 20:42:50 -0700	[thread overview]
Message-ID: <CAEf4BzZEHLp=4H4RjTvFVLWaVdJTyRXRAoxNmJW+VcwbQKVSHg@mail.gmail.com> (raw)
In-Reply-To: <20210721212833.701342-4-memxor@gmail.com>

On Wed, Jul 21, 2021 at 2:28 PM Kumar Kartikeya Dwivedi
<memxor@gmail.com> wrote:
>
> These eBPF tracepoint programs export data that is consumed by the
> helpers added in the previous commit.
>
> Also add support int the Makefile to generate a vmlinux.h header that
> would be used by other bpf.c files in later commits.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---
>  samples/bpf/Makefile         |  25 ++++
>  samples/bpf/xdp_sample.bpf.c | 215 +++++++++++++++++++++++++++++++++++
>  samples/bpf/xdp_sample.bpf.h |  57 ++++++++++
>  3 files changed, 297 insertions(+)
>  create mode 100644 samples/bpf/xdp_sample.bpf.c
>  create mode 100644 samples/bpf/xdp_sample.bpf.h
>

[...]

> +
> +SEC("tp_btf/xdp_cpumap_kthread")
> +int BPF_PROG(tp_xdp_cpumap_kthread, int map_id, unsigned int processed,
> +            unsigned int drops, int sched, struct xdp_cpumap_stats *xdp_stats)
> +{
> +       // Using xdp_stats directly fails verification

nit: C++ style comment

> +       u32 cpu = bpf_get_smp_processor_id();
> +       struct datarec *rec;
> +
> +       if (cpu < MAX_CPUS) {

tip: if you invert condition and exit early, the rest of your logic
will be less nested (same in few other places)

> +               rec = &sample_data.cpumap_kthread_cnt[cpu];
> +
> +               ATOMIC_ADD_NORMW(rec->processed, processed);
> +               ATOMIC_ADD_NORMW(rec->dropped, drops);
> +               ATOMIC_ADD_NORMW(rec->xdp_pass, xdp_stats->pass);
> +               ATOMIC_ADD_NORMW(rec->xdp_drop, xdp_stats->drop);
> +               ATOMIC_ADD_NORMW(rec->xdp_redirect, xdp_stats->redirect);
> +               /* Count times kthread yielded CPU via schedule call */
> +               if (sched)
> +                       ATOMIC_INC_NORMW(rec->issue);
> +       }
> +       return 0;
> +}
> +

[...]

  reply	other threads:[~2021-07-23  3:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 21:28 [PATCH bpf-next v2 0/8] Improve XDP samples usability and output Kumar Kartikeya Dwivedi
2021-07-21 21:28 ` [PATCH bpf-next v2 1/8] samples: bpf: fix a couple of warnings Kumar Kartikeya Dwivedi
2021-07-21 21:28 ` [PATCH bpf-next v2 2/8] samples: bpf: Add common infrastructure for XDP samples Kumar Kartikeya Dwivedi
2021-07-23  3:34   ` Andrii Nakryiko
2021-07-21 21:28 ` [PATCH bpf-next v2 3/8] samples: bpf: Add BPF support for XDP samples helper Kumar Kartikeya Dwivedi
2021-07-23  3:42   ` Andrii Nakryiko [this message]
2021-07-21 21:28 ` [PATCH bpf-next v2 4/8] samples: bpf: Convert xdp_monitor to use " Kumar Kartikeya Dwivedi
2021-07-21 21:28 ` [PATCH bpf-next v2 5/8] samples: bpf: Convert xdp_redirect " Kumar Kartikeya Dwivedi
2021-07-23  3:49   ` Andrii Nakryiko
2021-07-21 21:28 ` [PATCH bpf-next v2 6/8] samples: bpf: Convert xdp_redirect_map to use XDP samples helpers Kumar Kartikeya Dwivedi
2021-07-21 21:28 ` [PATCH bpf-next v2 7/8] samples: bpf: Convert xdp_redirect_map_multi " Kumar Kartikeya Dwivedi
2021-07-21 21:28 ` [PATCH bpf-next v2 8/8] samples: bpf: Convert xdp_redirect_cpu " Kumar Kartikeya Dwivedi
2021-07-23 21:32 ` [PATCH bpf-next v2 0/8] Improve XDP samples usability and output Toke Høiland-Jørgensen

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='CAEf4BzZEHLp=4H4RjTvFVLWaVdJTyRXRAoxNmJW+VcwbQKVSHg@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    --subject='Re: [PATCH bpf-next v2 3/8] samples: bpf: Add BPF support for XDP samples helper' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).