Skip to content
  • Mel Gorman's avatar
    mm: mempolicy: Convert shared_policy mutex to spinlock · 42288fe3
    Mel Gorman authored
    Sasha was fuzzing with trinity and reported the following problem:
    
      BUG: sleeping function called from invalid context at kernel/mutex.c:269
      in_atomic(): 1, irqs_disabled(): 0, pid: 6361, name: trinity-main
      2 locks held by trinity-main/6361:
       #0:  (&mm->mmap_sem){++++++}, at: [<ffffffff810aa314>] __do_page_fault+0x1e4/0x4f0
       #1:  (&(&mm->page_table_lock)->rlock){+.+...}, at: [<ffffffff8122f017>] handle_pte_fault+0x3f7/0x6a0
      Pid: 6361, comm: trinity-main Tainted: G        W
      3.7.0-rc2-next-20121024-sasha-00001-gd95ef01-dirty #74
      Call Trace:
        __might_sleep+0x1c3/0x1e0
        mutex_lock_nested+0x29/0x50
        mpol_shared_policy_lookup+0x2e/0x90
        shmem_get_policy+0x2e/0x30
        get_vma_policy+0x5a/0xa0
        mpol_misplaced+0x41/0x1d0
        handle_pte_fault+0x465/0x6a0
    
    This was triggered by a different version of automatic NUMA balancing
    but in theory the current version is vunerable to the same problem.
    
    do_numa_page
      -> numa_migrate_prep
       ...
    42288fe3