Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1307986

Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate percpu value of a key

From Eric Dumazet <eric.dumazet@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate percpu value of a key
Date 2016-01-13 03:30 +0100
Message-ID <qQjma-1rE-1@gated-at.bofh.it> (permalink)
References <qQ2v0-6Gt-3@gated-at.bofh.it> <qQ2v0-6Gt-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 2016-01-12 at 00:20 -0800, Martin KaFai Lau wrote:
> Add map_lookup_percpu_elem() syscall to lookup value
> of a particular CPU.

...

> +static int map_lookup_percpu_elem(union bpf_attr *attr)
> +{
> +	void __user *ukey = u64_to_ptr(attr->key);
> +	void __user *uvalue = u64_to_ptr(attr->value);
> +	u32 __user ucpu = attr->cpu;
> +	int ufd = attr->map_fd;
> +	struct percpu_map_value_info value_info;
> +	struct bpf_map *map;
> +	void *key, *value;
> +	struct fd f;
> +	int err;
> +
> +	if (CHECK_ATTR(BPF_MAP_LOOKUP_PERCPU_ELEM) ||
> +	    ucpu >= num_possible_cpus())
> +		return -EINVAL;

Arg, a num_possible_cpus() wrong call.

You probably want to use    (ucpu >= nr_cpu_ids)

hint : You can have hosts with 2 possibles cpus, CPU0 and CPU2

So the userland loop in your changelog is wrong.

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate percpu value of a key Martin KaFai Lau <kafai@fb.com> - 2016-01-12 09:30 +0100
  Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate  percpu value of a key Eric Dumazet <eric.dumazet@gmail.com> - 2016-01-13 03:30 +0100
  Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate  percpu value of a key Ming Lei <tom.leiming@gmail.com> - 2016-01-13 03:50 +0100
    Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate  percpu value of a key Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-13 06:30 +0100
      Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate  percpu value of a key Ming Lei <tom.leiming@gmail.com> - 2016-01-13 16:50 +0100
        Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate  percpu value of a key Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-14 02:30 +0100
          Re: [PATCH v2 net-next 3/4] bpf: bpf_htab: Add syscall to iterate  percpu value of a key Ming Lei <tom.leiming@gmail.com> - 2016-01-14 04:30 +0100

csiph-web