BPF List
 help / color / mirror / Atom feed
* [PATCH bpf 0/4] Fix the unmatched unit_size of bpf_mem_cache
@ 2023-09-08 13:39 Hou Tao
  2023-09-08 13:39 ` [PATCH bpf 1/4] bpf: Adjust size_index according to the value of KMALLOC_MIN_SIZE Hou Tao
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Hou Tao @ 2023-09-08 13:39 UTC (permalink / raw)
  To: bpf
  Cc: Martin KaFai Lau, Alexei Starovoitov, Andrii Nakryiko, Song Liu,
	Hao Luo, Yonghong Song, Daniel Borkmann, KP Singh,
	Stanislav Fomichev, Jiri Olsa, John Fastabend,
	Björn Töpel, houtao1

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

-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-09-29 21:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 13:39 [PATCH bpf 0/4] Fix the unmatched unit_size of bpf_mem_cache Hou Tao
2023-09-08 13:39 ` [PATCH bpf 1/4] bpf: Adjust size_index according to the value of KMALLOC_MIN_SIZE Hou Tao
2023-09-08 13:39 ` [PATCH bpf 2/4] bpf: Don't prefill for unused bpf_mem_cache Hou Tao
2023-09-08 13:39 ` [PATCH bpf 3/4] bpf: Ensure unit_size is matched with slab cache object size Hou Tao
2023-09-14 18:14   ` Nathan Chancellor
2023-09-16  2:38     ` Hou Tao
2023-09-19 23:46       ` Nathan Chancellor
2023-09-25  8:05         ` Hou Tao
2023-09-22 18:43   ` Guenter Roeck
2023-09-29 18:51     ` Emil Renner Berthing
2023-09-29 20:23       ` Lad, Prabhakar
2023-09-29 21:00         ` Alexei Starovoitov
2023-09-08 13:39 ` [PATCH bpf 4/4] selftests/bpf: Test all valid alloc sizes for bpf mem allocator Hou Tao
2023-09-11 19:50 ` [PATCH bpf 0/4] Fix the unmatched unit_size of bpf_mem_cache 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