On Fri, 26 Jul 2019 18:06:55 +0200
Toke Høiland-Jørgensen <t...@redhat.com> wrote:

> From: Toke Høiland-Jørgensen <t...@redhat.com>
> 
> A common pattern when using xdp_redirect_map() is to create a device map
> where the lookup key is simply ifindex. Because device maps are arrays,
> this leaves holes in the map, and the map has to be sized to fit the
> largest ifindex, regardless of how many devices actually are actually
> needed in the map.
> 
> This patch adds a second type of device map where the key is looked up
> using a hashmap, instead of being used as an array index. This allows maps
> to be densely packed, so they can be smaller.
> 
> Signed-off-by: Toke Høiland-Jørgensen <t...@redhat.com>
> Acked-by: Yonghong Song <y...@fb.com>

Acked-by: Jesper Dangaard Brouer <bro...@redhat.com>

[...]
> +static inline struct hlist_head *dev_map_index_hash(struct bpf_dtab *dtab,
> +                                                 int idx)
> +{
> +     return &dtab->dev_index_head[idx & (dtab->n_buckets - 1)];
> +}

I was about to complain about, that you are not using a pre-calculated
MASK value, instead of doing the -1 operation each time.  But I looked
at the ASM code, and the LEA operation used does the -1 operation in
the same instruction, so I guess this makes no performance difference.

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

Reply via email to