Re: [PATCH bpf-next 2/5] libbpf: Allow the number of hashes in bloom filter maps to be configurable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 31, 2021 at 3:51 PM Joanne Koong <joannekoong@xxxxxx> wrote:
>
> This patch adds the libbpf infrastructure that will allow the user to
> specify the number of hash functions to use for the bloom filter map.
>
> Signed-off-by: Joanne Koong <joannekoong@xxxxxx>
> ---
>  tools/lib/bpf/bpf.c             |  2 ++
>  tools/lib/bpf/bpf.h             |  1 +
>  tools/lib/bpf/libbpf.c          | 32 +++++++++++++++++++++++++++++++-
>  tools/lib/bpf/libbpf.h          |  3 +++
>  tools/lib/bpf/libbpf.map        |  2 ++
>  tools/lib/bpf/libbpf_internal.h |  4 +++-
>  6 files changed, 42 insertions(+), 2 deletions(-)
>

[...]

>  __u32 bpf_map__key_size(const struct bpf_map *map)
>  {
>         return map->def.key_size;
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index f177d897c5f7..497b84772be8 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -538,6 +538,9 @@ LIBBPF_API __u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
>  /* get/set map if_index */
>  LIBBPF_API __u32 bpf_map__ifindex(const struct bpf_map *map);
>  LIBBPF_API int bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex);
> +/* get/set nr_hashes. used for bloom filter maps */
> +LIBBPF_API __u32 bpf_map__nr_hashes(const struct bpf_map *map);
> +LIBBPF_API int bpf_map__set_nr_hashes(struct bpf_map *map, __u32 nr_hashes);
>
>  typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
>  LIBBPF_API int bpf_map__set_priv(struct bpf_map *map, void *priv,
> diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
> index bbc53bb25f68..372c2478274f 100644
> --- a/tools/lib/bpf/libbpf.map
> +++ b/tools/lib/bpf/libbpf.map
> @@ -385,4 +385,6 @@ LIBBPF_0.5.0 {
>                 btf__load_vmlinux_btf;
>                 btf_dump__dump_type_data;
>                 libbpf_set_strict_mode;
> +               bpf_map__nr_hashes;
> +               bpf_map__set_nr_hashes;

I'd really like to avoid this very niche and specific set of APIs. As
I mentioned on first patch, I think nr_hash can be easily passed
through map_flags property.

>  } LIBBPF_0.4.0;
> diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> index 533b0211f40a..501ae042980d 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -171,8 +171,9 @@ enum map_def_parts {
>         MAP_DEF_NUMA_NODE       = 0x080,
>         MAP_DEF_PINNING         = 0x100,
>         MAP_DEF_INNER_MAP       = 0x200,
> +       MAP_DEF_NR_HASHES       = 0x400,
>
> -       MAP_DEF_ALL             = 0x3ff, /* combination of all above */
> +       MAP_DEF_ALL             = 0x7ff, /* combination of all above */
>  };
>
>  struct btf_map_def {
> @@ -186,6 +187,7 @@ struct btf_map_def {
>         __u32 map_flags;
>         __u32 numa_node;
>         __u32 pinning;
> +       __u32 nr_hashes; /* used for bloom filter maps */

we can't extend btf_map_def, it's fixed indefinitely

>  };
>
>  int parse_btf_map_def(const char *map_name, struct btf *btf,
> --
> 2.30.2
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux