All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: "Daniel Borkmann" <daniel@iogearbox.net>,
	"Alexei Starovoitov" <ast@kernel.org>,
	netdev@vger.kernel.org, "David Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <jakub.kicinski@netronome.com>,
	"Björn Töpel" <bjorn.topel@gmail.com>,
	"Yonghong Song" <yhs@fb.com>,
	brouer@redhat.com
Subject: Re: [PATCH bpf-next v5 3/6] xdp: Add devmap_hash map type for looking up devices by hashed index
Date: Mon, 29 Jul 2019 18:16:12 +0200	[thread overview]
Message-ID: <20190729181612.7bdbe16a@carbon> (raw)
In-Reply-To: <156415721483.13581.2247227362994997536.stgit@alrua-x1>

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

> From: Toke Høiland-Jørgensen <toke@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 <toke@redhat.com>
> Acked-by: Yonghong Song <yhs@fb.com>

Acked-by: Jesper Dangaard Brouer <brouer@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	other threads:[~2019-07-29 16:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 16:06 [PATCH bpf-next v5 0/6] xdp: Add devmap_hash map type Toke Høiland-Jørgensen
2019-07-26 16:06 ` [PATCH bpf-next v5 1/6] include/bpf.h: Remove map_insert_ctx() stubs Toke Høiland-Jørgensen
2019-07-29 15:42   ` Jesper Dangaard Brouer
2019-07-26 16:06 ` [PATCH bpf-next v5 2/6] xdp: Refactor devmap allocation code for reuse Toke Høiland-Jørgensen
2019-07-29 16:02   ` Jesper Dangaard Brouer
2019-07-26 16:06 ` [PATCH bpf-next v5 3/6] xdp: Add devmap_hash map type for looking up devices by hashed index Toke Høiland-Jørgensen
2019-07-29 16:16   ` Jesper Dangaard Brouer [this message]
2019-07-26 16:06 ` [PATCH bpf-next v5 4/6] tools/include/uapi: Add devmap_hash BPF map type Toke Høiland-Jørgensen
2019-07-29 16:16   ` Jesper Dangaard Brouer
2019-07-26 16:06 ` [PATCH bpf-next v5 5/6] tools/libbpf_probes: Add new devmap_hash type Toke Høiland-Jørgensen
2019-07-29 16:17   ` Jesper Dangaard Brouer
2019-07-26 16:06 ` [PATCH bpf-next v5 6/6] tools: Add definitions for devmap_hash map type Toke Høiland-Jørgensen
2019-07-29 16:17   ` Jesper Dangaard Brouer
2019-07-27  2:26 ` [PATCH bpf-next v5 0/6] xdp: Add " Alexei Starovoitov
2019-07-29 20:57   ` Alexei Starovoitov
2019-08-08 19:30   ` Toke Høiland-Jørgensen
2019-08-08 19:57     ` Y Song
2019-08-08 20:05       ` Jesper Dangaard Brouer
2019-08-09 18:45         ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190729181612.7bdbe16a@carbon \
    --to=brouer@redhat.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.