Re: [PATCH 0/2] bpf: htab: Reduce memory use of hash maps

"T.J. Mercier" <[email protected]>
Newsgroups org.kernel.vger.bpf,org.kernel.vger.linux-kernel
Message-ID <CABdmKX39yhgZU9ATzzjmnvCbNqO1i=2KwuroL3YDsgMN+DVp7Q@mail.gmail.com>
On Fri, Jul 24, 2026 at 7:35 AM Mykyta Yatsenko
<[email protected]> wrote:
>
> On 7/23/26 6:22 PM, T.J. Mercier wrote:
> > On Thu, Jul 23, 2026 at 7:11 AM Mykyta Yatsenko
> > <[email protected]> wrote:
> >>
> >> On 7/22/26 9:37 PM, T.J. Mercier wrote:
> >>> Memory is expensive and scarce these days. This series reduces the
> >>> memory use of BPF hash maps by eliminating the per-element overheads
> >>> below. This saves up to 50% of per-element memory use for standard and
> >>> PCPU hash maps. The memory use of LRU hash maps is unaffected.
> >>>
> >>
> >> I understand that these savings calculations do not account for the element
> >> value overhead of per-CPU maps, which make up most of the map memory
> >> consumption. Realistically we won't see any memory savings for per-CPU maps.
> >
> > Yes, I did not look at BPF_MAP_TYPE_PERCPU_ARRAY at all. 95% of the
> > memory used by all of our BPF maps comes from hashmaps affected by
> > these changes. We only have 7 BPF_MAP_TYPE_PERCPU_ARRAY maps and they
> > consume only about 12 KiB. (I know a few of those PCPU arrays are just
> > to avoid 128 / 256 byte BPF stack allocations.)
> >
> >
>
> BTW, did you look into BPF_MAP_TYPE_RHASH? It does not
> yield much memory savings compared to normal hashmap, but performance
> is better in some scenarios.
>
> Link: https://lore.kernel.org/all/[email protected]/

Thanks, I've started to take a look and asked some other coworkers to as well.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.