All of lore.kernel.org
 help / color / mirror / Atom feed
* Per CPU map not being transferred to user space
@ 2022-11-30 13:58 Chris Ward
  2022-11-30 15:32 ` Chris Ward
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Ward @ 2022-11-30 13:58 UTC (permalink / raw)
  To: bpf

I have a test case similar to code in xdp-project/xdp-tutorial/ which
maintains a statistic map in a per-cpu array, and user-space code
which displays the statistics periodically.

When I run this, the user space code always displays zeros. I have
instrumented my eBPF kernel code with bpf_trace_printk and it appears
to be putting the correct values into the map. The user code is
iterating over all possible CPUs, but is always finding zeros in the
per-cpu array slots.

Can anybody tell me what is going wrong ?

My test case is here
https://github.com/tjcw/bpf-examples/tree/tjcw-integration-1.2-ebpftrace/AF_XDP-filter
; af_xdp_kern.c is the eBPF code, af_xdp_user.c is the userspace code
which drives the eBPF code, and filter-xdp_stats.c is the code which
should display the statistics. It all builds with 'make' in that
directory, and there is a run script which I use with
tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter/netperf-namespace$
sudo FILTER=af_xdp_kern ./run.sh
to run the user code and eBPF code with data being transferred between
2 network namespaces on the machine.
While it is running,
tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter$ sudo
./filter-xdp_stats
should display statistics, but in fact displays zeros.

My test case is coded to the '1.0' BPF interface, where the code in
xdp-tutorial is coded to the pre-release BPF interface.

Thanks for all the help you can give !

Chris Ward, IBM

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

* Re: Per CPU map not being transferred to user space
  2022-11-30 13:58 Per CPU map not being transferred to user space Chris Ward
@ 2022-11-30 15:32 ` Chris Ward
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Ward @ 2022-11-30 15:32 UTC (permalink / raw)
  To: bpf

I think I found the problem. It is necessary to run the statistics
display application in the same network namespace where the user level
filter and the eBPF kernel code are running; I think even in the same
'ip netns exec' instance.

On Wed, 30 Nov 2022 at 13:58, Chris Ward <tjcw01@gmail.com> wrote:
>
> I have a test case similar to code in xdp-project/xdp-tutorial/ which
> maintains a statistic map in a per-cpu array, and user-space code
> which displays the statistics periodically.
>
> When I run this, the user space code always displays zeros. I have
> instrumented my eBPF kernel code with bpf_trace_printk and it appears
> to be putting the correct values into the map. The user code is
> iterating over all possible CPUs, but is always finding zeros in the
> per-cpu array slots.
>
> Can anybody tell me what is going wrong ?
>
> My test case is here
> https://github.com/tjcw/bpf-examples/tree/tjcw-integration-1.2-ebpftrace/AF_XDP-filter
> ; af_xdp_kern.c is the eBPF code, af_xdp_user.c is the userspace code
> which drives the eBPF code, and filter-xdp_stats.c is the code which
> should display the statistics. It all builds with 'make' in that
> directory, and there is a run script which I use with
> tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter/netperf-namespace$
> sudo FILTER=af_xdp_kern ./run.sh
> to run the user code and eBPF code with data being transferred between
> 2 network namespaces on the machine.
> While it is running,
> tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter$ sudo
> ./filter-xdp_stats
> should display statistics, but in fact displays zeros.
>
> My test case is coded to the '1.0' BPF interface, where the code in
> xdp-tutorial is coded to the pre-release BPF interface.
>
> Thanks for all the help you can give !
>
> Chris Ward, IBM

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

end of thread, other threads:[~2022-11-30 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 13:58 Per CPU map not being transferred to user space Chris Ward
2022-11-30 15:32 ` Chris Ward

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.