diff options
author | Hou Tao <houtao1@huawei.com> | 2023-09-28 13:15:58 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-09-30 19:39:28 +0300 |
commit | 9077fc228f09c9f975c498c55f5d2e882cd0da59 (patch) | |
tree | 0c0d572e4a039931672948678ebb10bd833e9db4 /tools | |
parent | d1a783daa443d34e2f39811573ac9cbb5e5b78f3 (diff) | |
download | linux-9077fc228f09c9f975c498c55f5d2e882cd0da59.tar.xz |
bpf: Use kmalloc_size_roundup() to adjust size_index
Commit d52b59315bf5 ("bpf: Adjust size_index according to the value of
KMALLOC_MIN_SIZE") uses KMALLOC_MIN_SIZE to adjust size_index, but as
reported by Nathan, the adjustment is not enough, because
__kmalloc_minalign() also decides the minimal alignment of slab object
as shown in new_kmalloc_cache() and its value may be greater than
KMALLOC_MIN_SIZE (e.g., 64 bytes vs 8 bytes under a riscv QEMU VM).
Instead of invoking __kmalloc_minalign() in bpf subsystem to find the
maximal alignment, just using kmalloc_size_roundup() directly to get the
corresponding slab object size for each allocation size. If these two
sizes are unmatched, adjust size_index to select a bpf_mem_cache with
unit_size equal to the object_size of the underlying slab cache for the
allocation size.
Fixes: 822fb26bdb55 ("bpf: Add a hint to allocated objects.")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/bpf/20230914181407.GA1000274@dev-arch.thelio-3990X/
Signed-off-by: Hou Tao <houtao1@huawei.com>
Tested-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Link: https://lore.kernel.org/r/20230928101558.2594068-1-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions