[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQ+OShaA37-=B4-GWTQQ8p4yPw3TgYLPTkbHMJLYhr48kg@mail.gmail.com>
Date: Thu, 6 Mar 2025 22:36:26 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: arthur@...hurfabre.com
Cc: Network Development <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Jakub Sitnicki <jakub@...udflare.com>, Jesper Dangaard Brouer <hawk@...nel.org>, Yan Zhai <yan@...udflare.com>,
jbrandeburg@...udflare.com, Toke Høiland-Jørgensen <thoiland@...hat.com>,
lbiancon@...hat.com, Arthur Fabre <afabre@...udflare.com>
Subject: Re: [PATCH RFC bpf-next 01/20] trait: limited KV store for packet metadata
On Wed, Mar 5, 2025 at 6:33 AM <arthur@...hurfabre.com> wrote:
>
> +struct __trait_hdr {
> + /* Values are stored ordered by key, immediately after the header.
> + *
> + * The size of each value set is stored in the header as two bits:
> + * - 00: Not set.
> + * - 01: 2 bytes.
> + * - 10: 4 bytes.
> + * - 11: 8 bytes.
...
> + * - hweight(low) + hweight(high)<<1 is offset.
the comment doesn't match the code
> + */
> + u64 high;
> + u64 low;
...
> +static __always_inline int __trait_total_length(struct __trait_hdr h)
> +{
> + return (hweight64(h.low) << 1) + (hweight64(h.high) << 2)
> + // For size 8, we only get 4+2=6. Add another 2 in.
> + + (hweight64(h.high & h.low) << 1);
> +}
This is really cool idea, but 2 byte size doesn't feel that useful.
How about:
- 00: Not set.
- 01: 4 bytes.
- 10: 8 bytes.
- 11: 16 bytes.
4 byte may be useful for ipv4, 16 for ipv6, and 8 is just a good number.
And compute the same way with 3 popcount with extra +1 to shifts.
Powered by blists - more mailing lists