On Wed, Jul 21, 2021 at 2:28 PM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> 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@xxxxxxxxx> > --- > 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; > +} > + [...]