Subject: Re: [PATCH net-next 2/2] ebpf: add helper for obtaining current processor id

From: Alexei Starovoitov <[email-masked]>
Date: Fri, 13 Mar 2015 10:06:59 -0700

On 3/13/15 6:22 AM, Daniel Borkmann wrote:
> This patch adds the possibility to obtain raw_smp_processor_id() in
> eBPF. Currently, this is only possible in classic BPF where commit
> da2033c28226 ("filter: add SKF_AD_RXHASH and SKF_AD_CPU") has added
> facilities for this.
>
> Single threaded packet socket applications (f.e. tcpdump, netsniff-ng)
> e.g. writing to pcap files and making use of eBPF can use this helper
> function to spread flows after RPS dispatch to several instances. It
> would also allow to track per CPU statistics (or data) with eBPF maps.

I'm not sure whether classic extension is still used by Eric as it was
envisioned in that old commit, but I do like addition of it for eBPF,
since it allows a poor men's per-cpu data structures via maps :)

> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index 4efc41f..9080cf5 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -166,6 +166,7 @@ enum bpf_func_id {
>   	BPF_FUNC_map_update_elem, /* int map_update_elem(&map, &key, &value, flags) */
>   	BPF_FUNC_map_delete_elem, /* int map_delete_elem(&map, &key) */
>   	BPF_FUNC_random,	  /* prandom() as u32 or u64 */
> +	BPF_FUNC_cpu_id,	  /* raw_smp_processor_id() */

same comment as in other patch:
could you rename it to BPF_FUNC_get_smp_processor_id ?