Skip to content
  • Oscar Salvador's avatar
    mm, page_alloc: fix has_unmovable_pages for HugePages · 17e2e7d7
    Oscar Salvador authored
    While playing with gigantic hugepages and memory_hotplug, I triggered
    the following #PF when "cat memoryX/removable":
    
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
      #PF error: [normal kernel read fault]
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      CPU: 1 PID: 1481 Comm: cat Tainted: G            E     4.20.0-rc6-mm1-1-default+ #18
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      RIP: 0010:has_unmovable_pages+0x154/0x210
      Call Trace:
       is_mem_section_removable+0x7d/0x100
       removable_show+0x90/0xb0
       dev_attr_show+0x1c/0x50
       sysfs_kf_seq_show+0xca/0x1b0
       seq_read+0x133/0x380
       __vfs_read+0x26/0x180
       vfs_read+0x89/0x140
       ksys_read+0x42/0x90
       do_syscall_64+0x5b/0x180
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    The reason is we do not pass the Head to page_hstate(), and so, the call
    to compound_order() in page_hstate() returns 0, so we end up checking
    all ...
    17e2e7d7