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


Groups > linux.kernel > #1306613

Re: [PATCH 6/9] bpf: arraymap: introduce BPF_MAP_TYPE_ARRAY_PERCPU

From Alexei Starovoitov <alexei.starovoitov@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 6/9] bpf: arraymap: introduce BPF_MAP_TYPE_ARRAY_PERCPU
Date 2016-01-11 20:20 +0100
Message-ID <qPQau-6Em-33@gated-at.bofh.it> (permalink)
References <qPN2V-4pP-5@gated-at.bofh.it> <qPN2W-4pP-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jan 11, 2016 at 11:56:58PM +0800, Ming Lei wrote:
> This patch introduces percpu array map so that expensive
> atomic operations can be avoided in eBPF prog in case of
> ARRAY map.
> 
> PERCPU MAP uses the percpu version of update/lookup element
> helpers and callbacks to access element in the map, and
> the previous update/lookup element helpers and callbacks
> don't work at the same time.
> 
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>

useful stuff!

> +	if (percpu) {
> +		if (alloc_percpu_array(array, attr->max_entries,
> +				       attr->value_size)) {
> +			kvfree(array);
> +			return ERR_PTR(-ENOMEM);
> +		}
> +		array->map.pages = round_up(attr->max_entries *
> +				attr->value_size * num_possible_cpus(),
> +				PAGE_SIZE) >> PAGE_SHIFT;

I think it would be more accurate to add it to array_size instead of
doing page rounding here.

> -	array->map.pages = round_up(array_size, PAGE_SIZE) >> PAGE_SHIFT;
> +	array->map.pages += round_up(array_size, PAGE_SIZE) >> PAGE_SHIFT;

and this line wouldn't need to change...

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


Thread

[PATCH 0/9] bpf: support percpu ARRAY map Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
  [PATCH 3/9] bpf: introduce percpu verion of lookup/update in bpf_map_ops Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
  [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
    Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-11 20:10 +0100
      Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-12 06:10 +0100
        Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-12 06:50 +0100
          Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-12 12:10 +0100
            Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Martin KaFai Lau <kafai@fb.com> - 2016-01-12 20:20 +0100
              Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-13 01:40 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Martin KaFai Lau <kafai@fb.com> - 2016-01-13 03:30 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-13 04:20 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-13 06:30 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-13 16:00 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-14 02:30 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-14 03:50 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update  elem Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-14 06:10 +0100
                Re: [PATCH 5/9] bpf: syscall: add percpu version of lookup/update elem Ming Lei <tom.leiming@gmail.com> - 2016-01-14 08:20 +0100
  [PATCH 4/9] bpf: add percpu version of lookup/update element helpers Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
  [PATCH 6/9] bpf: arraymap: introduce BPF_MAP_TYPE_ARRAY_PERCPU Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
    Re: [PATCH 6/9] bpf: arraymap: introduce BPF_MAP_TYPE_ARRAY_PERCPU Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-01-11 20:20 +0100
  [PATCH 7/9] sample/bpf: introduces helpers for percpu array example Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
  [PATCH 9/9] samples/bpf: test percpu array map Ming Lei <tom.leiming@gmail.com> - 2016-01-11 17:00 +0100
    RE: [PATCH 9/9] samples/bpf: test percpu array map David Laight <David.Laight@ACULAB.COM> - 2016-01-12 16:50 +0100

csiph-web