Open hygoni opened 3 years ago
I'm testing this with enabling SLAB_LOCKLESS_CACHE on every slab cache except boot cache.
But I get kernel panic: [ 0.000000] traps: PANIC: double fault, error_code: 0xffffffff8e7e06f0 [ 0.000000] BUG: unable to handle page fault for address: fffffe000000a000 [ 0.000000] #PF: supervisor read access in kernel mode [ 0.000000] #PF: error_code(0x0000) - not-present page [ 0.000000] PGD 23fff2067 P4D 23fff2067 PUD 23fff1067 PMD 23ffef067 PTE 0 [ 0.000000] Oops: 0000 [#1] SMP PTI [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.15.0-rc2+ #3 [ 0.000000] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1 04/4 [ 0.000000] RIP: 0010:die_header+0x19/0x6e [ 0.000000] Code: e8 0c 7f 00 00 c7 43 50 00 00 00 00 e9 4b 5f 4e ff 8b 05 c7 10 14 0 [ 0.000000] RSP: 0000:fffffe0000009ee8 EFLAGS: 00010046 [ 0.000000] RAX: 0000000000000000 RBX: ffffffff8f815cde RCX: 0000000000000002 [ 0.000000] RDX: ffffffff8e7e06f0 RSI: fffffe000000a000 RDI: ffffffff9027e780 [ 0.000000] RBP: fffffe0000009f60 R08: ffffffff8fa55580 R09: 6666666666666666 [ 0.000000] R10: ffffffff8f815cde R11: 203a65646f635f72 R12: ffffffff8e7e06f0 [ 0.000000] R13: ffffffff8e7e06f0 R14: 0000000000000000 R15: 0000000000000000 [ 0.000000] FS: 0000000000000000(0000) GS:ffff8b1977c00000(0000) knlGS:0000000000000 [ 0.000000] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 0.000000] CR2: fffffe000000a000 CR3: 0000000229e0c000 CR4: 00000000000006b0 [ 0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 0.000000] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 0.000000] Call Trace: [ 0.000000] <#DF> [ 0.000000] __die+0x12/0x24 [ 0.000000] die+0x25/0x40 [ 0.000000] ? kmem_cache_alloc_bulk+0xc0/0x220 [ 0.000000] exc_double_fault+0x119/0x130 [ 0.000000] asm_exc_double_fault+0x1e/0x40 [ 0.000000] WARNING: stack recursion on stack type 5 [ 0.000000] WARNING: can't access registers at asm_exc_double_fault+0x1e/0x40 [ 0.000000] ? vunmap+0x220/0x220 [ 0.000000] ? kmem_cache_alloc_cached+0x7a/0xa0 [ 0.000000] </#DF> [ 0.000000] ? vunmap+0x220/0x220 [ 0.000000] ? kmem_cache_alloc_cached+0x7a/0xa0 [ 0.000000] ? vmalloc_init+0x137/0x19b [ 0.000000] ? start_kernel+0x3b6/0x677 [ 0.000000] ? secondary_startup_64_no_verify+0xc2/0xcb [ 0.000000] Modules linked in: [ 0.000000] CR2: fffffe000000a000 [ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x21/0x40 wit0 [ 0.000000] ---[ end trace 99145c9ed6df72af ]--- [ 0.000000] RIP: 0010:die_header+0x19/0x6e [ 0.000000] Code: e8 0c 7f 00 00 c7 43 50 00 00 00 00 e9 4b 5f 4e ff 8b 05 c7 10 14 0 [ 0.000000] RSP: 0000:fffffe0000009ee8 EFLAGS: 00010046 [ 0.000000] RAX: 0000000000000000 RBX: ffffffff8f815cde RCX: 0000000000000002 [ 0.000000] RDX: ffffffff8e7e06f0 RSI: fffffe000000a000 RDI: ffffffff9027e780 [ 0.000000] RBP: fffffe0000009f60 R08: ffffffff8fa55580 R09: 6666666666666666 [ 0.000000] R10: ffffffff8f815cde R11: 203a65646f635f72 R12: ffffffff8e7e06f0 [ 0.000000] R13: ffffffff8e7e06f0 R14: 0000000000000000 R15: 0000000000000000 [ 0.000000] FS: 0000000000000000(0000) GS:ffff8b1977c00000(0000) knlGS:0000000000000 [ 0.000000] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 0.000000] CR2: fffffe000000a000 CR3: 0000000229e0c000 CR4: 00000000000006b0 [ 0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 0.000000] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 0.000000] Kernel panic - not syncing: Fatal exception in interrupt
It was due to I called kmem_cache_alloc_cached even with GFP_KERNEL.
XD. That is fixed now.
Wait, why does it matter? The crash is because I called kmem_cache_alloc_bulk with GFP_KERNEL.
Seems I made wrong fix :<
Things are good now
As Jens mentioned, there's no reason that kmemcache{alloc,free}_cached should be separate API.
it seems better that kmem_cache_alloc calls _cached version when the cache is available. Some calling contexts should be considered to that. and test is needed.