[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALOAHbCXVNXk4WUCRGCDsezzTfieDcLT=Jt00m4UX4zdw=RtsQ@mail.gmail.com>
Date: Sun, 27 Aug 2023 10:48:44 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: Rong Tao <rtoax@...mail.com>
Cc: olsajiri@...il.com, andrii@...nel.org, daniel@...earbox.net,
sdf@...gle.com, Rong Tao <rongtao@...tc.cn>,
Alexei Starovoitov <ast@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
Shuah Khan <shuah@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Ilya Leoshkevich <iii@...ux.ibm.com>,
Daniel Müller <deso@...teo.net>,
Manu Bretelle <chantr4@...il.com>,
Xu Kuohai <xukuohai@...wei.com>,
Ross Zwisler <zwisler@...gle.com>,
Eduard Zingerman <eddyz87@...il.com>,
"open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)"
<bpf@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>,
"moderated list:ARM/STM32 ARCHITECTURE"
<linux-stm32@...md-mailman.stormreply.com>,
"moderated list:ARM/STM32 ARCHITECTURE"
<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH bpf-next v8] selftests/bpf: trace_helpers.c: optimize
kallsyms cache
On Sat, Aug 26, 2023 at 10:46 PM Rong Tao <rtoax@...mail.com> wrote:
>
> From: Rong Tao <rongtao@...tc.cn>
>
> Static ksyms often have problems because the number of symbols exceeds the
> MAX_SYMS limit. Like changing the MAX_SYMS from 300000 to 400000 in
> commit e76a014334a6("selftests/bpf: Bump and validate MAX_SYMS") solves
> the problem somewhat, but it's not the perfect way.
>
> This commit uses dynamic memory allocation, which completely solves the
> problem caused by the limitation of the number of kallsyms.
>
> Acked-by: Stanislav Fomichev <sdf@...gle.com>
> Signed-off-by: Rong Tao <rongtao@...tc.cn>
> ---
> v8: Resolves inter-thread contention for ksyms global variables.
> v7: https://lore.kernel.org/lkml/tencent_BD6E19C00BF565CD5C36A9A0BD828CFA210A@qq.com/
> Fix __must_check macro.
> v6: https://lore.kernel.org/lkml/tencent_4A09A36F883A06EA428A593497642AF8AF08@qq.com/
> Apply libbpf_ensure_mem()
> v5: https://lore.kernel.org/lkml/tencent_0E9E1A1C0981678D5E7EA9E4BDBA8EE2200A@qq.com/
> Release the allocated memory once the load_kallsyms_refresh() upon error
> given it's dynamically allocated.
> v4: https://lore.kernel.org/lkml/tencent_59C74613113F0C728524B2A82FE5540A5E09@qq.com/
> Make sure most cases we don't need the realloc() path to begin with,
> and check strdup() return value.
> v3: https://lore.kernel.org/lkml/tencent_50B4B2622FE7546A5FF9464310650C008509@qq.com/
> Do not use structs and judge ksyms__add_symbol function return value.
> v2: https://lore.kernel.org/lkml/tencent_B655EE5E5D463110D70CD2846AB3262EED09@qq.com/
> Do the usual len/capacity scheme here to amortize the cost of realloc, and
> don't free symbols.
> v1: https://lore.kernel.org/lkml/tencent_AB461510B10CD484E0B2F62E3754165F2909@qq.com/
> ---
> samples/bpf/Makefile | 4 +
> samples/bpf/offwaketime_user.c | 7 +-
> samples/bpf/sampleip_user.c | 9 +-
> samples/bpf/spintest_user.c | 7 +-
> samples/bpf/task_fd_query_user.c | 13 +-
> samples/bpf/trace_event_user.c | 7 +-
> .../selftests/bpf/prog_tests/bpf_cookie.c | 7 +-
> .../selftests/bpf/prog_tests/fill_link_info.c | 9 +-
> .../bpf/prog_tests/get_stack_raw_tp.c | 10 +-
> .../bpf/prog_tests/kprobe_multi_test.c | 13 +-
> .../prog_tests/kprobe_multi_testmod_test.c | 13 +-
> tools/testing/selftests/bpf/trace_helpers.c | 116 ++++++++++++------
> tools/testing/selftests/bpf/trace_helpers.h | 10 +-
> 13 files changed, 154 insertions(+), 71 deletions(-)
I think we'd better split it into two patches: one for samples/bpf/
and another for tools/testing/selftests/bpf.
BTW, why can't we just load it once for all ? IOW, load the kallsyms
before we start each individual test, and free it after all tests
finish.
--
Regards
Yafang
Powered by blists - more mailing lists