Skip to content
  • Michal Hocko's avatar
    memory_hotplug: cond_resched in __remove_pages · dd33ad7b
    Michal Hocko authored
    We have received a bug report that unbinding a large pmem (>1TB) can
    result in a soft lockup:
    
      NMI watchdog: BUG: soft lockup - CPU#9 stuck for 23s! [ndctl:4365]
      [...]
      Supported: Yes
      CPU: 9 PID: 4365 Comm: ndctl Not tainted 4.12.14-94.40-default #1 SLE12-SP4
      Hardware name: Intel Corporation S2600WFD/S2600WFD, BIOS SE5C620.86B.01.00.0833.051120182255 05/11/2018
      task: ffff9cce7d4410c0 task.stack: ffffbe9eb1bc4000
      RIP: 0010:__put_page+0x62/0x80
      Call Trace:
       devm_memremap_pages_release+0x152/0x260
       release_nodes+0x18d/0x1d0
       device_release_driver_internal+0x160/0x210
       unbind_store+0xb3/0xe0
       kernfs_fop_write+0x102/0x180
       __vfs_write+0x26/0x150
       vfs_write+0xad/0x1a0
       SyS_write+0x42/0x90
       do_syscall_64+0x74/0x150
       entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      RIP: 0033:0x7fd13166b3d0
    
    It has been reported on an older (4.12) kernel but the current upstream
    code doesn't cond_resched in the hot remove code at all and the given
    range to remove might be really large.  Fix the issue by calling
    cond_resched once per memory section.
    
    Link: http://lkml.kernel.org/r/20181031125840.23982-1-mhocko@kernel.org
    
    
    Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
    Acked-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
    Cc: Dan Williams <dan.j.williams@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    dd33ad7b