On 10/10/2017 21:26, Peng Hao wrote: > When freeing mmapped kvm_run several pages, the pages will have page > flags PG_dirty and PG_referenced. It will result to bad page report > when allocating pages. > I just encounter once like this; > BUG: Bad page state in process qemu-system-x86 pfn:81fc5d > page:ffffea00207f1740 count:0 mapcount:0 mapping: (null) index:0x4 > flags: 0x600000000000014(referenced|dirty) > raw: 0600000000000014 0000000000000000 0000000000000004 00000000ffffffff > raw: dead000000000100 dead000000000200 0000000000000000 0000000000000000 > page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set > bad because of flags: 0x14(referenced|dirty) > Modules linked in: kvm_intel kvm vhost_net vhost tap xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat xt_conntrack ipt_REJECT xt_tcpudp ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter openvswitch nf_defrag_ipv6 nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat intel_rapl sb_edac x86_pkg_temp_thermal intel_powerclamp coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64 mei_me crypto_simd input_leds cryptd led_class joydev shpchp mei wmi lpc_ich glue_helper mfd_core acpi_power_meter acpi_pad irqbypass ip_tables x_tables megaraid_sas [last unloaded: kvm_intel] > CPU: 7 PID: 37349 Comm: qemu-system-x86 Tainted: G W 4.13.0-rc6nfv+ #1 > Hardware name: Dell Inc. PowerEdge R720/068CDY, BIOS 2.2.2 01/16/2014 > Call Trace: > dump_stack+0x63/0x8c > bad_page+0xfe/0x11a > check_new_page_bad+0x76/0x78 > get_page_from_freelist+0x65e/0xa00 > __alloc_pages_nodemask+0xf6/0x270 > alloc_pages_vma+0x6b/0x110 > __handle_mm_fault+0x4e2/0xb20 > handle_mm_fault+0xd8/0x1f0 > __do_page_fault+0x215/0x4b0 > do_page_fault+0x32/0x90 > page_fault+0x28/0x30 > RIP: 0033:0x7f68ca7d94fc > RSP: 002b:00007ffe911a3570 EFLAGS: 00010216 > RAX: 00005599e0240a30 RBX: 00005599e023e920 RCX: 0000000000006c41 > RDX: 00007f68cab157b8 RSI: 0000000061d00000 RDI: 0000000000000003 > RBP: 00007f68cab15760 R08: 0000000000020000 R09: 0000000000002100 > R10: 000000000000006b R11: 0000000000000000 R12: 0000000000004b30 > R13: 0000000000006c40 R14: 0000000000002110 R15: 00007f68cab157b8 How did you know that this was a kvm_run page, and why is it the right thing to clear the flags? Paolo