mbox series

[bpf,0/4] Fix the unmatched unit_size of bpf_mem_cache

Message ID 20230908133923.2675053-1-houtao@huaweicloud.com (mailing list archive)
Headers show
Series Fix the unmatched unit_size of bpf_mem_cache | expand

Message

Hou Tao Sept. 8, 2023, 1:39 p.m. UTC
From: Hou Tao <houtao1@huawei.com>

Hi,

The patchset aims to fix the reported warning [0] when the unit_size of
bpf_mem_cache is mismatched with the object size of underly slab-cache.

Patch #1 fixes the warning by adjusting size_index according to the
value of KMALLOC_MIN_SIZE, so bpf_mem_cache with unit_size which is
smaller than KMALLOC_MIN_SIZE or is not aligned with KMALLOC_MIN_SIZE
will be redirected to bpf_mem_cache with bigger unit_size. Patch #2
doesn't do prefill for these redirected bpf_mem_cache to save memory.
Patch #3 adds further error check in bpf_mem_alloc_init() to ensure the
unit_size and object_size are always matched and to prevent potential
issues due to the mismatch.

Please see individual patches for more details. And comments are always
welcome.

[0]: https://lore.kernel.org/bpf/87jztjmmy4.fsf@all.your.base.are.belong.to.us

Hou Tao (4):
  bpf: Adjust size_index according to the value of KMALLOC_MIN_SIZE
  bpf: Don't prefill for unused bpf_mem_cache
  bpf: Ensure unit_size is matched with slab cache object size
  selftests/bpf: Test all valid alloc sizes for bpf mem allocator

 kernel/bpf/memalloc.c                         |  87 ++++++++++++-
 .../selftests/bpf/prog_tests/test_bpf_ma.c    |  50 +++++++
 .../testing/selftests/bpf/progs/test_bpf_ma.c | 123 ++++++++++++++++++
 3 files changed, 256 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/test_bpf_ma.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_bpf_ma.c

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 11, 2023, 7:50 p.m. UTC | #1
Hello:

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

On Fri,  8 Sep 2023 21:39:19 +0800 you wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> Hi,
> 
> The patchset aims to fix the reported warning [0] when the unit_size of
> bpf_mem_cache is mismatched with the object size of underly slab-cache.
> 
> [...]

Here is the summary with links:
  - [bpf,1/4] bpf: Adjust size_index according to the value of KMALLOC_MIN_SIZE
    https://git.kernel.org/bpf/bpf/c/d52b59315bf5
  - [bpf,2/4] bpf: Don't prefill for unused bpf_mem_cache
    https://git.kernel.org/bpf/bpf/c/b1d53958b693
  - [bpf,3/4] bpf: Ensure unit_size is matched with slab cache object size
    https://git.kernel.org/bpf/bpf/c/c93047255202
  - [bpf,4/4] selftests/bpf: Test all valid alloc sizes for bpf mem allocator
    https://git.kernel.org/bpf/bpf/c/f0a42ab5890f

You are awesome, thank you!