* [RESEND][PATCH bpf-next] bpf: Check map->record at the beginning of check_and_free_fields()
@ 2025-03-15 15:09 Hou Tao
2025-03-15 15:26 ` Kumar Kartikeya Dwivedi
2025-03-15 19:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Hou Tao @ 2025-03-15 15:09 UTC (permalink / raw)
To: bpf
Cc: Martin KaFai Lau, Alexei Starovoitov, Andrii Nakryiko,
Eduard Zingerman, Song Liu, Hao Luo, Yonghong Song,
Daniel Borkmann, KP Singh, Stanislav Fomichev, Jiri Olsa,
John Fastabend, houtao1
From: Hou Tao <houtao1@huawei.com>
When there are no special fields in the map value, there is no need to
invoke bpf_obj_free_fields(). Therefore, checking the validity of
map->record in advance.
After the change, the benchmark result of the per-cpu update case in
map_perf_test increased by 40% under a 16-CPU VM.
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
kernel/bpf/hashtab.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index c308300fc72f6..877298133fdae 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -787,6 +787,9 @@ static int htab_lru_map_gen_lookup(struct bpf_map *map,
static void check_and_free_fields(struct bpf_htab *htab,
struct htab_elem *elem)
{
+ if (IS_ERR_OR_NULL(htab->map.record))
+ return;
+
if (htab_is_percpu(htab)) {
void __percpu *pptr = htab_elem_get_ptr(elem, htab->map.key_size);
int cpu;
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RESEND][PATCH bpf-next] bpf: Check map->record at the beginning of check_and_free_fields()
2025-03-15 15:09 [RESEND][PATCH bpf-next] bpf: Check map->record at the beginning of check_and_free_fields() Hou Tao
@ 2025-03-15 15:26 ` Kumar Kartikeya Dwivedi
2025-03-15 19:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2025-03-15 15:26 UTC (permalink / raw)
To: Hou Tao
Cc: bpf, Martin KaFai Lau, Alexei Starovoitov, Andrii Nakryiko,
Eduard Zingerman, Song Liu, Hao Luo, Yonghong Song,
Daniel Borkmann, KP Singh, Stanislav Fomichev, Jiri Olsa,
John Fastabend, houtao1
On Sat, 15 Mar 2025 at 15:57, Hou Tao <houtao@huaweicloud.com> wrote:
>
> From: Hou Tao <houtao1@huawei.com>
>
> When there are no special fields in the map value, there is no need to
> invoke bpf_obj_free_fields(). Therefore, checking the validity of
> map->record in advance.
>
> After the change, the benchmark result of the per-cpu update case in
> map_perf_test increased by 40% under a 16-CPU VM.
>
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RESEND][PATCH bpf-next] bpf: Check map->record at the beginning of check_and_free_fields()
2025-03-15 15:09 [RESEND][PATCH bpf-next] bpf: Check map->record at the beginning of check_and_free_fields() Hou Tao
2025-03-15 15:26 ` Kumar Kartikeya Dwivedi
@ 2025-03-15 19:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-15 19:10 UTC (permalink / raw)
To: Hou Tao
Cc: bpf, martin.lau, alexei.starovoitov, andrii, eddyz87, song,
haoluo, yonghong.song, daniel, kpsingh, sdf, jolsa,
john.fastabend, houtao1
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Sat, 15 Mar 2025 23:09:30 +0800 you wrote:
> From: Hou Tao <houtao1@huawei.com>
>
> When there are no special fields in the map value, there is no need to
> invoke bpf_obj_free_fields(). Therefore, checking the validity of
> map->record in advance.
>
> After the change, the benchmark result of the per-cpu update case in
> map_perf_test increased by 40% under a 16-CPU VM.
>
> [...]
Here is the summary with links:
- [RESEND,bpf-next] bpf: Check map->record at the beginning of check_and_free_fields()
https://git.kernel.org/bpf/bpf-next/c/bb2243f4328b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-15 19:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 15:09 [RESEND][PATCH bpf-next] bpf: Check map->record at the beginning of check_and_free_fields() Hou Tao
2025-03-15 15:26 ` Kumar Kartikeya Dwivedi
2025-03-15 19:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox