From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Jonathan Lemon <jlemon@flugsvamp.com>
Cc: "Daniel Borkmann" <daniel@iogearbox.net>,
"Alexei Starovoitov" <ast@kernel.org>,
netdev@vger.kernel.org, "David Miller" <davem@davemloft.net>,
"Jesper Dangaard Brouer" <brouer@redhat.com>,
"Jakub Kicinski" <jakub.kicinski@netronome.com>,
"Björn Töpel" <bjorn.topel@gmail.com>
Subject: Re: [PATCH bpf-next 0/3] xdp: Add devmap_hash map type
Date: Mon, 08 Jul 2019 17:40:56 +0200 [thread overview]
Message-ID: <87bly4zg8n.fsf@toke.dk> (raw)
In-Reply-To: <53906C87-8AF9-4048-8CA0-AE38C023AEF7@flugsvamp.com>
"Jonathan Lemon" <jlemon@flugsvamp.com> writes:
> On 5 Jul 2019, at 10:56, Toke Høiland-Jørgensen wrote:
>
>> This series adds a new map type, devmap_hash, that works like the
>> existing
>> devmap type, but using a hash-based indexing scheme. This is useful
>> for the use
>> case where a devmap is indexed by ifindex (for instance for use with
>> the routing
>> table lookup helper). For this use case, the regular devmap needs to
>> be sized
>> after the maximum ifindex number, not the number of devices in it. A
>> hash-based
>> indexing scheme makes it possible to size the map after the number of
>> devices it
>> should contain instead.
>
> This device hash map is sized at NETDEV_HASHENTRIES == 2^8 == 256. Is
> this actually smaller than an array? What ifindex values are you
> seeing?
Well, not in all cases, certainly. But machines with lots of virtual
interfaces (e.g., container hosts) can easily exceed that. Also, for a
devmap we charge the full size of max_entries * struct bpf_dtab_netdev
towards the locked memory cost on map creation. And since sizeof(struct
bpf_dtab_netdev) is 64, the size of the hashmap only corresponds to 32
entries...
But more importantly, it's a UI issue: Say you want to create a simple
program that uses the fib_lookup helper (something like the xdp_fwd
example under samples/bpf/). You know that you only want to route
between a couple of interfaces, so you naturally create a devmap that
can hold, say, 8 entries (just to be sure). This works fine on your
initial test, where the machine only has a couple of physical interfaces
brought up at boot. But then you try to run the same program on your
production server, where the interfaces you need to use just happen to
have ifindexes higher than 8, and now it breaks for no discernible
reason. Or even worse, if you remove and re-add an interface, you may no
longer be able to insert it into your map because the ifindex changed...
-Toke
next prev parent reply other threads:[~2019-07-08 15:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-05 17:56 [PATCH bpf-next 0/3] xdp: Add devmap_hash map type Toke Høiland-Jørgensen
2019-07-05 17:56 ` [PATCH bpf-next 3/3] xdp: Add devmap_hash map type for looking up devices by hashed index Toke Høiland-Jørgensen
2019-07-05 22:04 ` Y Song
2019-07-06 8:41 ` Toke Høiland-Jørgensen
2019-07-05 17:56 ` [PATCH bpf-next 1/3] include/bpf.h: Remove map_insert_ctx() stubs Toke Høiland-Jørgensen
2019-07-05 17:56 ` [PATCH bpf-next 2/3] xdp: Refactor devmap allocation code for reuse Toke Høiland-Jørgensen
2019-07-08 15:06 ` Jonathan Lemon
2019-07-08 15:19 ` Toke Høiland-Jørgensen
2019-07-08 15:10 ` [PATCH bpf-next 0/3] xdp: Add devmap_hash map type Jonathan Lemon
2019-07-08 15:40 ` Toke Høiland-Jørgensen [this message]
2019-07-08 16:50 ` Jonathan Lemon
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=87bly4zg8n.fsf@toke.dk \
--to=toke@redhat.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=jlemon@flugsvamp.com \
--cc=netdev@vger.kernel.org \
/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.