On 08/16/23 16:11, Matthew Wilcox (Oracle) wrote: > We can use a bit in page[1].flags to indicate that this folio belongs > to hugetlb instead of using a value in page[1].dtors. That lets > folio_test_hugetlb() become an inline function like it should be. > We can also get rid of NULL_COMPOUND_DTOR. Not 100% sure yet, but I suspect this patch/series causes the following BUG in today's linux-next. I can do a deeper dive tomorrow. # echo 1 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages # echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages [ 352.631099] page:ffffea0007a30000 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x1e8c00 [ 352.633674] head:ffffea0007a30000 order:8 entire_mapcount:0 nr_pages_mapped:0 pincount:0 [ 352.636021] flags: 0x200000000000040(head|node=0|zone=2) [ 352.637424] page_type: 0xffffffff() [ 352.638619] raw: 0200000000000040 ffffc90003bb3d98 ffffc90003bb3d98 0000000000000000 [ 352.640689] raw: 0000000000000001 0000000000000008 00000000ffffffff 0000000000000000 [ 352.642882] page dumped because: VM_BUG_ON_PAGE(compound && compound_order(page) != order) [ 352.644671] ------------[ cut here ]------------ [ 352.645746] kernel BUG at mm/page_alloc.c:1101! [ 352.647284] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 352.649286] CPU: 2 PID: 894 Comm: bash Not tainted 6.5.0-rc7-next-20230821-dirty #178 [ 352.651245] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-1.fc37 04/01/2014 [ 352.653349] RIP: 0010:free_unref_page_prepare+0x3c4/0x3e0 [ 352.654731] Code: ff 0f 00 00 75 d4 48 8b 03 a8 40 74 cd 48 8b 43 48 a8 01 74 c5 48 8d 78 ff eb bf 48 c7 c6 10 90 22 82 48 89 df e8 fc e1 fc ff <0f> 0b 48 c7 c6 20 2e 22 82 e8 ee e1 fc ff 0f 0b 66 66 2e 0f 1f 84 [ 352.660080] RSP: 0018:ffffc90003bb3d08 EFLAGS: 00010246 [ 352.661457] RAX: 000000000000004e RBX: ffffea0007a30000 RCX: 0000000000000000 [ 352.663119] RDX: 0000000000000000 RSI: ffffffff8224cc56 RDI: 00000000ffffffff [ 352.664697] RBP: 00000000001e8c00 R08: 0000000000009ffb R09: 00000000ffffdfff [ 352.666191] R10: 00000000ffffdfff R11: ffffffff824660c0 R12: 0000000000000009 [ 352.667612] R13: 00000000001e8c00 R14: 0000000000000000 R15: 0000000000000000 [ 352.669033] FS: 00007f18fc3a0740(0000) GS:ffff888477c00000(0000) knlGS:0000000000000000 [ 352.670654] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 352.671678] CR2: 000055b1b1f16018 CR3: 0000000302e5a002 CR4: 0000000000370ee0 [ 352.672936] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 352.674215] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 352.675399] Call Trace: [ 352.675907] <TASK> [ 352.676400] ? die+0x32/0x80 [ 352.676974] ? do_trap+0xd6/0x100 [ 352.677691] ? free_unref_page_prepare+0x3c4/0x3e0 [ 352.678591] ? do_error_trap+0x6a/0x90 [ 352.679343] ? free_unref_page_prepare+0x3c4/0x3e0 [ 352.680245] ? exc_invalid_op+0x49/0x60 [ 352.680961] ? free_unref_page_prepare+0x3c4/0x3e0 [ 352.681851] ? asm_exc_invalid_op+0x16/0x20 [ 352.682607] ? free_unref_page_prepare+0x3c4/0x3e0 [ 352.683518] ? free_unref_page_prepare+0x3c4/0x3e0 [ 352.684387] free_unref_page+0x34/0x160 [ 352.685176] ? _raw_spin_lock_irq+0x19/0x40 [ 352.686641] set_max_huge_pages+0x281/0x370 [ 352.687621] nr_hugepages_store_common+0x91/0xf0 [ 352.688634] kernfs_fop_write_iter+0x108/0x1f0 [ 352.689619] vfs_write+0x207/0x400 [ 352.690423] ksys_write+0x63/0xe0 [ 352.691198] do_syscall_64+0x37/0x90 [ 352.691938] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 352.692847] RIP: 0033:0x7f18fc494e87 [ 352.693481] Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24 [ 352.696304] RSP: 002b:00007ffff7597318 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 352.697539] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f18fc494e87 [ 352.698790] RDX: 0000000000000002 RSI: 000055b1b1ed3620 RDI: 0000000000000001 [ 352.700238] RBP: 000055b1b1ed3620 R08: 000000000000000a R09: 00007f18fc52c0c0 [ 352.701662] R10: 00007f18fc52bfc0 R11: 0000000000000246 R12: 0000000000000002 [ 352.703112] R13: 00007f18fc568520 R14: 0000000000000002 R15: 00007f18fc568720 [ 352.704547] </TASK> [ 352.705101] Modules linked in: rfkill ip6table_filter ip6_tables sunrpc snd_hda_codec_generic snd_hda_intel snd_intel_dspcfg snd_hda_codec 9p snd_hwdep joydev snd_hda_core netfs snd_seq snd_seq_device snd_pcm snd_timer 9pnet_virtio snd soundcore virtio_balloon 9pnet virtio_net net_failover virtio_console virtio_blk failover crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel serio_raw virtio_pci virtio virtio_pci_legacy_dev virtio_pci_modern_dev virtio_ring fuse [ 352.713435] ---[ end trace 0000000000000000 ]--- [ 352.714725] RIP: 0010:free_unref_page_prepare+0x3c4/0x3e0 [ 352.717293] Code: ff 0f 00 00 75 d4 48 8b 03 a8 40 74 cd 48 8b 43 48 a8 01 74 c5 48 8d 78 ff eb bf 48 c7 c6 10 90 22 82 48 89 df e8 fc e1 fc ff <0f> 0b 48 c7 c6 20 2e 22 82 e8 ee e1 fc ff 0f 0b 66 66 2e 0f 1f 84 [ 352.721235] RSP: 0018:ffffc90003bb3d08 EFLAGS: 00010246 [ 352.722388] RAX: 000000000000004e RBX: ffffea0007a30000 RCX: 0000000000000000 [ 352.723909] RDX: 0000000000000000 RSI: ffffffff8224cc56 RDI: 00000000ffffffff [ 352.725408] RBP: 00000000001e8c00 R08: 0000000000009ffb R09: 00000000ffffdfff [ 352.726875] R10: 00000000ffffdfff R11: ffffffff824660c0 R12: 0000000000000009 [ 352.728352] R13: 00000000001e8c00 R14: 0000000000000000 R15: 0000000000000000 [ 352.729821] FS: 00007f18fc3a0740(0000) GS:ffff888477c00000(0000) knlGS:0000000000000000 [ 352.731511] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 352.732723] CR2: 000055b1b1f16018 CR3: 0000000302e5a002 CR4: 0000000000370ee0 [ 352.734199] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 352.735681] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 -- Mike Kravetz