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 v4 3/6] xdp: Add devmap_hash map type for looking up devices by hashed index
Date: Thu, 25 Jul 2019 10:07:17 +0200 [thread overview]
Message-ID: <20190725100717.0c4e8265@carbon> (raw)
In-Reply-To: <156379636866.12332.6546616116016146789.stgit@alrua-x1>
On Mon, 22 Jul 2019 13:52:48 +0200
Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> +static inline struct hlist_head *dev_map_index_hash(struct bpf_dtab *dtab,
> + int idx)
> +{
> + return &dtab->dev_index_head[idx & (NETDEV_HASHENTRIES - 1)];
> +}
It is good for performance that our "hash" function is simply an AND
operation on the idx. We want to keep it this way.
I don't like that you are using NETDEV_HASHENTRIES, because the BPF map
infrastructure already have a way to specify the map size (struct
bpf_map_def .max_entries). BUT for performance reasons, to keep the
AND operation, we would need to round up the hash-array size to nearest
power of 2 (or reject if user didn't specify a power of 2, if we want
to "expose" this limit to users).
> +struct bpf_dtab_netdev *__dev_map_hash_lookup_elem(struct bpf_map *map, u32 key)
> +{
> + struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
> + struct hlist_head *head = dev_map_index_hash(dtab, key);
> + struct bpf_dtab_netdev *dev;
> +
> + hlist_for_each_entry_rcu(dev, head, index_hlist)
> + if (dev->idx == key)
> + return dev;
> +
> + return NULL;
> +}
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2019-07-25 8:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-22 11:52 [PATCH bpf-next v4 0/6] xdp: Add devmap_hash map type Toke Høiland-Jørgensen
2019-07-22 11:52 ` [PATCH bpf-next v4 2/6] xdp: Refactor devmap allocation code for reuse Toke Høiland-Jørgensen
2019-07-22 11:52 ` [PATCH bpf-next v4 1/6] include/bpf.h: Remove map_insert_ctx() stubs Toke Høiland-Jørgensen
2019-07-22 11:52 ` [PATCH bpf-next v4 3/6] xdp: Add devmap_hash map type for looking up devices by hashed index Toke Høiland-Jørgensen
2019-07-25 8:07 ` Jesper Dangaard Brouer [this message]
2019-07-25 10:32 ` Toke Høiland-Jørgensen
2019-07-25 11:37 ` Jesper Dangaard Brouer
2019-07-25 15:05 ` Toke Høiland-Jørgensen
2019-07-22 11:52 ` [PATCH bpf-next v4 4/6] tools/include/uapi: Add devmap_hash BPF map type Toke Høiland-Jørgensen
2019-07-22 11:52 ` [PATCH bpf-next v4 6/6] tools: Add definitions for devmap_hash " Toke Høiland-Jørgensen
2019-07-22 11:52 ` [PATCH bpf-next v4 5/6] tools/libbpf_probes: Add new devmap_hash type 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=20190725100717.0c4e8265@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).