lkml.org 
[lkml]   [2020]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 bpf-next 7/9] libbpf: add libbpf support to batch ops
On Wed, Jan 15, 2020 at 10:43 AM Brian Vazquez <brianvv@google.com> wrote:
>
> From: Yonghong Song <yhs@fb.com>
>
> Added four libbpf API functions to support map batch operations:
> . int bpf_map_delete_batch( ... )
> . int bpf_map_lookup_batch( ... )
> . int bpf_map_lookup_and_delete_batch( ... )
> . int bpf_map_update_batch( ... )
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
> tools/lib/bpf/bpf.c | 58 ++++++++++++++++++++++++++++++++++++++++
> tools/lib/bpf/bpf.h | 22 +++++++++++++++
> tools/lib/bpf/libbpf.map | 4 +++
> 3 files changed, 84 insertions(+)
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 500afe478e94a..317727d612149 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -452,6 +452,64 @@ int bpf_map_freeze(int fd)
> return sys_bpf(BPF_MAP_FREEZE, &attr, sizeof(attr));
> }
>
> +static int bpf_map_batch_common(int cmd, int fd, void *in_batch,
> + void *out_batch, void *keys, void *values,
> + __u32 *count,
> + const struct bpf_map_batch_opts *opts)
> +{
> + union bpf_attr attr = {};


this is not a big issue and I don't want to delay landing your
patches, so maybe you can follow up with another patch. But this '=
{}' part is a complete waste because you do memset below.

> + int ret;
> +
> + if (!OPTS_VALID(opts, bpf_map_batch_opts))
> + return -EINVAL;
> +
> + memset(&attr, 0, sizeof(attr));
> + attr.batch.map_fd = fd;
> + attr.batch.in_batch = ptr_to_u64(in_batch);
> + attr.batch.out_batch = ptr_to_u64(out_batch);
> + attr.batch.keys = ptr_to_u64(keys);
> + attr.batch.values = ptr_to_u64(values);
> + attr.batch.count = *count;
> + attr.batch.elem_flags = OPTS_GET(opts, elem_flags, 0);
> + attr.batch.flags = OPTS_GET(opts, flags, 0);
> +
> + ret = sys_bpf(cmd, &attr, sizeof(attr));
> + *count = attr.batch.count;
> +
> + return ret;
> +}
> +

[...]

\
 
 \ /
  Last update: 2020-01-15 21:21    [W:0.073 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site