mbox series

[bpf,v3,0/9] Fixes for LPM trie

Message ID 20241206110622.1161752-1-houtao@huaweicloud.com (mailing list archive)
Headers show
Series Fixes for LPM trie | expand

Message

Hou Tao Dec. 6, 2024, 11:06 a.m. UTC
From: Hou Tao <houtao1@huawei.com>

Hi,

This patch set fixes several issues for LPM trie. These issues were
found during adding new test cases or were reported by syzbot.

The patch set is structured as follows:

Patch #1~#2 are clean-ups for lpm_trie_update_elem().
Patch #3 handles BPF_EXIST and BPF_NOEXIST correctly for LPM trie.
Patch #4 fixes the accounting of n_entries when doing in-place update.
Patch #5 fixes the exact match condition in trie_get_next_key() and it
may skip keys when the passed key is not found in the map.
Patch #6~#7 switch from kmalloc() to bpf memory allocator for LPM trie
to fix several lock order warnings reported by syzbot. It also enables
raw_spinlock_t for LPM trie again. After these changes, the LPM trie will
be closer to being usable in any context (though the reentrance check of
trie->lock is still missing, but it is on my todo list).
Patch #8: move test_lpm_map to map_tests to make it run regularly.
Patch #9: add test cases for the issues fixed by patch #3~#5.

Please see individual patches for more details. Comments are always
welcome.

Change Log:
v3:
  * patch #2: remove the unnecessary NULL-init for im_node
  * patch #6: alloc the leaf node before disabling IRQ to low
    the possibility of -ENOMEM when leaf_size is large; Free
    these nodes outside the trie lock (Suggested by Alexei)
  * collect review and ack tags (Thanks for Toke & Daniel)

v2: https://lore.kernel.org/bpf/20241127004641.1118269-1-houtao@huaweicloud.com/
  * collect review tags (Thanks for Toke)
  * drop "Add bpf_mem_cache_is_mergeable() helper" patch
  * patch #3~#4: add fix tag
  * patch #4: rename the helper to trie_check_add_elem() and increase
    n_entries in it.
  * patch #6: use one bpf mem allocator and update commit message to
    clarify that using bpf mem allocator is more appropriate.
  * patch #7: update commit message to add the possible max running time
    for update operation.
  * patch #9: update commit message to specify the purpose of these test
    cases.

v1: https://lore.kernel.org/bpf/20241118010808.2243555-1-houtao@huaweicloud.com/

Hou Tao (9):
  bpf: Remove unnecessary check when updating LPM trie
  bpf: Remove unnecessary kfree(im_node) in lpm_trie_update_elem
  bpf: Handle BPF_EXIST and BPF_NOEXIST for LPM trie
  bpf: Handle in-place update for full LPM trie correctly
  bpf: Fix exact match conditions in trie_get_next_key()
  bpf: Switch to bpf mem allocator for LPM trie
  bpf: Use raw_spinlock_t for LPM trie
  selftests/bpf: Move test_lpm_map.c to map_tests
  selftests/bpf: Add more test cases for LPM trie

 kernel/bpf/lpm_trie.c                         | 133 +++---
 tools/testing/selftests/bpf/.gitignore        |   1 -
 tools/testing/selftests/bpf/Makefile          |   2 +-
 .../lpm_trie_map_basic_ops.c}                 | 405 +++++++++++++++++-
 4 files changed, 484 insertions(+), 57 deletions(-)
 rename tools/testing/selftests/bpf/{test_lpm_map.c => map_tests/lpm_trie_map_basic_ops.c} (65%)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 6, 2024, 5:40 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Fri,  6 Dec 2024 19:06:13 +0800 you wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> Hi,
> 
> This patch set fixes several issues for LPM trie. These issues were
> found during adding new test cases or were reported by syzbot.
> 
> [...]

Here is the summary with links:
  - [bpf,v3,1/9] bpf: Remove unnecessary check when updating LPM trie
    https://git.kernel.org/bpf/bpf/c/156c977c539e
  - [bpf,v3,2/9] bpf: Remove unnecessary kfree(im_node) in lpm_trie_update_elem
    https://git.kernel.org/bpf/bpf/c/3d5611b4d7ef
  - [bpf,v3,3/9] bpf: Handle BPF_EXIST and BPF_NOEXIST for LPM trie
    https://git.kernel.org/bpf/bpf/c/eae6a075e953
  - [bpf,v3,4/9] bpf: Handle in-place update for full LPM trie correctly
    https://git.kernel.org/bpf/bpf/c/532d6b36b2bf
  - [bpf,v3,5/9] bpf: Fix exact match conditions in trie_get_next_key()
    https://git.kernel.org/bpf/bpf/c/27abc7b3fa2e
  - [bpf,v3,6/9] bpf: Switch to bpf mem allocator for LPM trie
    https://git.kernel.org/bpf/bpf/c/3d8dc43eb2a3
  - [bpf,v3,7/9] bpf: Use raw_spinlock_t for LPM trie
    https://git.kernel.org/bpf/bpf/c/6a5c63d43c02
  - [bpf,v3,8/9] selftests/bpf: Move test_lpm_map.c to map_tests
    https://git.kernel.org/bpf/bpf/c/3e18f5f1e5a1
  - [bpf,v3,9/9] selftests/bpf: Add more test cases for LPM trie
    https://git.kernel.org/bpf/bpf/c/04d4ce91b0be

You are awesome, thank you!