Re: [PATCH net-next 0/4] bpf: bpf_htab: Add BPF_MAP_TYPE_PERCPU_HASH
From: Ming Lei
Date: Fri Jan 08 2016 - 01:55:47 EST
On Fri, Jan 8, 2016 at 6:35 AM, Martin KaFai Lau <kafai@xxxxxx> wrote:
> This patchset adds BPF_MAP_TYPE_PERCPU_HASH map type which allows
> percpu value.
I am also thinking about using percpu variable to ebpf map, but IMO it
should be better for ARRAY map instead of HASH map, then we can
avoid the atomic op in eBPF program, see example of tracex3, sockex1
and sockex3 in sample/bpf/ of kernel tree. Also looks the ARRAY map
usage in bcc is wrong, strictly speaking.
For HASH map, it is easy to make cpu id as part of key, then the map
can be thought as percpu too, and atomic op isn't needed in eBPF program.
> BPF + kprobe is very useful in statistics collection. In particular,
> bpf is strong in doing aggregation within the kernel instead of
> outputting a lot of raw samples to the userspace.
> In some cases, bumping a counter/value of a particular key will have
> noticeable impact. For example, doing statistics collection
> on received packets and aggregating them by network
> prefix (like /64 in IPv6). Having a percpu value can help.
Given it is always related with performance, could you provide some data
about the improvement? Also you can compare this patchset with the
approach of providing cpu id as hash key.