Hi, On 9/13/2023 12:59 PM, Stephen Rothwell wrote: > Hi all, > > On Wed, 13 Sep 2023 13:34:36 +1000 Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> wrote: >> Today's linux-next boot tests (powerpc pseries_le_defconfig) produced >> this warning: >> >> ------------[ cut here ]------------ >> bpf_mem_cache[0]: unexpected object size 16, expect 96 >> WARNING: CPU: 0 PID: 1 at kernel/bpf/memalloc.c:500 bpf_mem_alloc_init+0x410/0x440 >> Modules linked in: >> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.6.0-rc1-04964-g2e08ed1d459f #1 >> Hardware name: IBM pSeries (emulated by qemu) POWER8 (raw) 0x4d0200 0xf000004 of:SLOF,HEAD pSeries >> NIP: c0000000003c0890 LR: c0000000003c088c CTR: 0000000000000000 >> REGS: c000000004783890 TRAP: 0700 Not tainted (6.6.0-rc1-04964-g2e08ed1d459f) >> MSR: 8000000002029033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 24000280 XER: 00000000 >> CFAR: c00000000014cfa0 IRQMASK: 0 >> GPR00: c0000000003c088c c000000004783b30 c000000001578c00 0000000000000036 >> GPR04: 0000000000000000 c000000002667e18 0000000000000001 0000000000000000 >> GPR08: c000000002667ce0 0000000000000001 0000000000000000 0000000044000280 >> GPR12: 0000000000000000 c000000002b00000 c000000000011188 0000000000000060 >> GPR16: c0000000011f9a30 c000000002920f68 c0000000021fac40 c0000000021fac40 >> GPR20: c000000002a3ed88 c000000002921560 c0000000014867f0 c00000000291ccd8 >> GPR24: 0000000000000000 0000000000000000 0000000000000000 0000000000000010 >> GPR28: c0000000011f9a30 0000000000000000 000000000000000b c00000007fc9ac40 >> NIP [c0000000003c0890] bpf_mem_alloc_init+0x410/0x440 >> LR [c0000000003c088c] bpf_mem_alloc_init+0x40c/0x440 >> Call Trace: >> [c000000004783b30] [c0000000003c088c] bpf_mem_alloc_init+0x40c/0x440 (unreliable) >> [c000000004783c20] [c00000000203d0c0] bpf_global_ma_init+0x5c/0x9c >> [c000000004783c50] [c000000000010bc0] do_one_initcall+0x80/0x300 >> [c000000004783d20] [c000000002004978] kernel_init_freeable+0x30c/0x3b4 >> [c000000004783df0] [c0000000000111b0] kernel_init+0x30/0x1a0 >> [c000000004783e50] [c00000000000debc] ret_from_kernel_user_thread+0x14/0x1c >> --- interrupt: 0 at 0x0 >> NIP: 0000000000000000 LR: 0000000000000000 CTR: 0000000000000000 >> REGS: c000000004783e80 TRAP: 0000 Not tainted (6.6.0-rc1-04964-g2e08ed1d459f) >> MSR: 0000000000000000 <> CR: 00000000 XER: 00000000 >> CFAR: 0000000000000000 IRQMASK: 0 >> GPR00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR04: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR12: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> GPR28: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 >> NIP [0000000000000000] 0x0 >> LR [0000000000000000] 0x0 >> --- interrupt: 0 >> Code: 3b000000 4bfffcbc 78650020 3c62ffe7 39200001 3d420130 7cc607b4 7ba40020 386382f0 992a1e24 4bd8c631 60000000 <0fe00000> 4bffff40 ea410080 3860fff4 >> ---[ end trace 0000000000000000 ]--- >> >> Presumably related to commit >> >> 41a5db8d8161 ("bpf: Add support for non-fix-size percpu mem allocation") >> >> (or other commist in that series) from the bpf-next tree. > Actually it looks like it is some interaction between that commit a > commits in the bpf tree. Yes. The warning is due to the checking added in commit c93047255202 ("bpf: Ensure unit_size is matched with slab cache object size"). Considering that bpf-next has not merged the patch-set yet, should I post a patch to bpf tree to fix it ? A fix patch is attached which can fix the warning in my local setup. > >
>From 395d19f1ac747070fce43356cea336b4430afed2 Mon Sep 17 00:00:00 2001 From: Hou Tao <houtao1@xxxxxxxxxx> Date: Wed, 13 Sep 2023 15:33:13 +0800 Subject: [PATCH] bpf: Skip unit_size checking for global per-cpu allocator For global per-cpu allocator, the size of free object in free list doesn't match with unit_size and now there is no way to get the size of per-cpu pointer saved in free object, so just skip the checking. Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> --- kernel/bpf/memalloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c index aad558cdc70f..0ad175277f89 100644 --- a/kernel/bpf/memalloc.c +++ b/kernel/bpf/memalloc.c @@ -491,6 +491,13 @@ static int check_obj_size(struct bpf_mem_cache *c, unsigned int idx) struct llist_node *first; unsigned int obj_size; + /* For per-cpu allocator, the size of free objects in free list doesn't + * match with unit_size and now there is no way to get the size of + * per-cpu pointer saved in free object, so just skip the checking. + */ + if (c->percpu_size) + return 0; + first = c->free_llist.first; if (!first) return 0; -- 2.29.2