memcg: change oom_info_lock to mutex
Michal Hocko authored
Kirill has reported the following:

  Task in /test killed as a result of limit of /test
  memory: usage 10240kB, limit 10240kB, failcnt 51
  memory+swap: usage 10240kB, limit 10240kB, failcnt 0
  kmem: usage 0kB, limit 18014398509481983kB, failcnt 0
  Memory cgroup stats for /test:

  BUG: sleeping function called from invalid context at kernel/cpu.c:68
  in_atomic(): 1, irqs_disabled(): 0, pid: 66, name: memcg_test
  2 locks held by memcg_test/66:
   #0:  (memcg_oom_lock#2){+.+...}, at: [<ffffffff81131014>] pagefault_out_of_memory+0x14/0x90
   #1:  (oom_info_lock){+.+...}, at: [<ffffffff81197b2a>] mem_cgroup_print_oom_info+0x2a/0x390
  CPU: 2 PID: 66 Comm: memcg_test Not tainted 3.14.0-rc1-dirty #745
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Bochs 01/01/2011
  Call Trace:
    __might_sleep+0x16a/0x210
    get_online_cpus+0x1c/0x60
    mem_cgroup_read_stat+0x27/0xb0
    mem_cgroup_print_oom_info+0x260/0x390
    dump_header+0x88/0x251
    ? trace_hardirqs_on+0xd/0x10
    oom_kill_process+0x258/0x3d0
    mem_cgroup_oom_synchronize+0x656/0x6c0
    ? mem_cgroup_charge_common+0xd0/0xd0
    pagefault_out_of_memory+0x14/0x90
    mm_fault_error+0x91/0x189
    __do_page_fault+0x48e/0x580
    do_page_fault+0xe/0x10
    page_fault+0x22/0x30

which complains that mem_cgroup_read_stat cannot be called from an atomic
context but mem_cgroup_print_oom_info takes a spinlock.  Change
oom_info_lock to a mutex.

This was introduced by 947b3dd1

 ("memcg, oom: lock
mem_cgroup_print_oom_info").
Signed-off-by: default avatarMichal Hocko <mhocko@suse.cz>
Reported-by: default avatar"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
08088cb9
Name Last commit Last update
..
Kconfig zsmalloc: move it under mm
Kconfig.debug mm: more intensive memory corruption debugging
Makefile zsmalloc: move it under mm
backing-dev.c mm/backing-dev.c: check user buffer length before copying data to the related user buffer
balloon_compaction.c mm: print more details for bad_page()
bootmem.c mm/bootmem.c: remove unused local `map'
bounce.c block: Convert bio_for_each_segment() to bvec_iter
cleancache.c mm: dump page when hitting a VM_BUG_ON using VM_BUG_ON_PAGE
compaction.c mm: improve documentation of page_order
debug-pagealloc.c mm, x86: Remove debug_pagealloc_enabled
dmapool.c dmapool: make DMAPOOL_DEBUG detect corruption of free marker
fadvise.c teach SYSCALL_DEFINE<n> how to deal with long long/unsigned long long
failslab.c switch debugfs to umode_t
filemap.c fix O_SYNC|O_APPEND syncing the wrong range on write()
filemap_xip.c seqcount: Add lockdep functionality to seqcount/seqlock structures
fremap.c mm: fix use-after-free in sys_remap_file_pages
frontswap.c frontswap: fix incorrect zeroing and allocation size for frontswap_map
highmem.c Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
huge_memory.c mm, thp: fix infinite loop on memcg OOM
hugetlb.c mm: dump page when hitting a VM_BUG_ON using VM_BUG_ON_PAGE
hugetlb_cgroup.c mm: dump page when hitting a VM_BUG_ON using VM_BUG_ON_PAGE
hwpoison-inject.c mm/hwpoison: add '#' to hwpoison_inject
init-mm.c atomic: use <linux/atomic.h>
internal.h mm/page-writeback.c: do not count anon pages as dirtyable memory
interval_tree.c mm: add CONFIG_DEBUG_VM_RB build option
kmemcheck.c
kmemleak-test.c
kmemleak.c
ksm.c
list_lru.c
maccess.c
madvise.c
memblock.c
memcontrol.c
memory-failure.c
memory.c
memory_hotplug.c
mempolicy.c
mempool.c
migrate.c
mincore.c
mlock.c
mm_init.c
mmap.c
mmu_context.c
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c
msync.c
nobootmem.c
nommu.c
oom_kill.c
page-writeback.c
page_alloc.c
page_cgroup.c
page_io.c
page_isolation.c
pagewalk.c
percpu-km.c
percpu-vm.c
percpu.c
pgtable-generic.c
process_vm_access.c
quicklist.c
readahead.c
rmap.c
shmem.c
slab.c
slab.h
slab_common.c
slob.c
slub.c
sparse-vmemmap.c
sparse.c
swap.c
swap_state.c
swapfile.c
truncate.c
util.c
vmalloc.c
vmpressure.c
vmscan.c
vmstat.c
zbud.c
zsmalloc.c
zswap.c