[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAYibXiHRg3C3tk=wbiHdaUgJD6AfJf7gX3w0gTJ2nsJ=DnY4g@mail.gmail.com>
Date: Mon, 7 Nov 2022 16:30:08 -0800
From: "Hao Xiang ." <hao.xiang@...edance.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: "Ho-Ren (Jack) Chuang" <horenchuang@...edance.com>,
Alexei Starovoitov <ast@...nel.org>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Jiri Olsa <olsajiri@...il.com>,
Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
John Fastabend <john.fastabend@...il.com>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Quentin Monnet <quentin@...valent.com>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Tom Rix <trix@...hat.com>,
Joanne Koong <joannelkoong@...il.com>,
Kui-Feng Lee <kuifeng@...com>,
Lorenzo Bianconi <lorenzo@...nel.org>,
Maxim Mikityanskiy <maximmi@...dia.com>,
Punit Agrawal <punit.agrawal@...edance.com>,
Yifei Ma <yifeima@...edance.com>,
Xiaoning Ding <xiaoning.ding@...edance.com>,
bpf <bpf@...r.kernel.org>, Ho-Ren Chuang <horenc@...edu>,
LKML <linux-kernel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
clang-built-linux <llvm@...ts.linux.dev>
Subject: Re: [External] Re: [PATCH bpf-next v1 0/4] Add BPF htab map's used
size for monitoring
Hi Alexei,
We understand the concern on added performance overhead. We had some
discussion about this while working on the patch and decided to give
it a try (my bad).
Adding some more context. We are leveraging the BPF_OBJ_GET_INFO_BY_FD
syscall to trace CPU usage per prog and memory usage per map. We would
like to use this patch to add an interface for map types to return its
internal "count". For instance, we are thinking of having the below
map types to report the "count" and those won't add overhead to the
hot path.
1. ringbuf to return its "count" by calculating the distance between
producer_pos and consumer_pos
2. queue and stack to return its "count" from the head's position
3. dev map hash to returns its "count" from items
There are other map types, similar to the hashtab pre-allocation case,
will introduce overhead in the hot path in order to count the stats. I
think we can find alternative solutions for those (eg, iterate the map
and count, count only if bpf_stats_enabled switch is on, etc). There
are cases where this can't be done at the application level because
applications don't see the internal stats in order to do the right
counting.
We can remove the counting for the pre-allocated case in this patch.
Please let us know what you think.
Thanks, Hao
On Sat, Nov 5, 2022 at 9:20 AM Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Fri, Nov 4, 2022 at 7:52 PM Ho-Ren (Jack) Chuang
> <horenchuang@...edance.com> wrote:
> >
> > Hello everyone,
> >
> > We have prepared patches to address an issue from a previous discussion.
> > The previous discussion email thread is here: https://lore.kernel.org/all/CAADnVQLBt0snxv4bKwg1WKQ9wDFbaDCtZ03v1-LjOTYtsKPckQ@mail.gmail.com/
>
> Rephrasing what was said earlier.
> We're not keeping the count of elements in a preallocated hash map
> and we are not going to add one.
> The bpf prog needs to do the accounting on its own if it needs
> this kind of statistics.
> Keeping the count for non-prealloc is already significant performance
> overhead. We don't trade performance for stats.
Powered by blists - more mailing lists