[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW5dXr4X9O3JtOVe=K+9yXzUY=WQuSgvhNWDKbJ57bnFAg@mail.gmail.com>
Date: Wed, 24 Jul 2019 13:53:00 -0700
From: Song Liu <liu.song.a23@...il.com>
To: Brian Vazquez <brianvv@...gle.com>
Cc: Brian Vazquez <brianvv.kernel@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"David S . Miller" <davem@...emloft.net>,
Stanislav Fomichev <sdf@...gle.com>,
Willem de Bruijn <willemb@...gle.com>,
Petar Penkov <ppenkov@...gle.com>,
open list <linux-kernel@...r.kernel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next 1/6] bpf: add bpf_map_value_size and
bp_map_copy_value helper functions
On Wed, Jul 24, 2019 at 10:10 AM Brian Vazquez <brianvv@...gle.com> wrote:
>
> Move reusable code from map_lookup_elem to helper functions to avoid code
> duplication in kernel/bpf/syscall.c
>
> Suggested-by: Stanislav Fomichev <sdf@...gle.com>
> Signed-off-by: Brian Vazquez <brianvv@...gle.com>
Acked-by: Song Liu <songliubraving@...com>
Some very minor nits though.
> ---
> kernel/bpf/syscall.c | 134 +++++++++++++++++++++++--------------------
> 1 file changed, 73 insertions(+), 61 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 5d141f16f6fa9..86cdc2f7bb56e 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -126,6 +126,76 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
> return map;
> }
>
> +static u32 bpf_map_value_size(struct bpf_map *map)
> +{
> + if (map->map_type == BPF_MAP_TYPE_PERCPU_HASH ||
> + map->map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH ||
> + map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY ||
> + map->map_type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE)
> + return round_up(map->value_size, 8) * num_possible_cpus();
> + else if (IS_FD_MAP(map))
> + return sizeof(u32);
> + else
> + return map->value_size;
^ extra space after return
> +}
> +
> +static int bpf_map_copy_value(struct bpf_map *map, void *key, void *value,
> + __u64 flags)
> +{
> + void *ptr;
> + int err;
> +
> + if (bpf_map_is_dev_bound(map))
> + return bpf_map_offload_lookup_elem(map, key, value);
^ another extra space after return, did replace? :-)
Thanks,
Song
Powered by blists - more mailing lists