memcg: fix a race when setting memory.swappiness
Li Zefan authored

(suppose: memcg->use_hierarchy == 0 and memcg->swappiness == 60)

echo 10 > /memcg/0/swappiness   |
  mem_cgroup_swappiness_write() |
    ...                         | echo 1 > /memcg/0/use_hierarchy
                                | mkdir /mnt/0/1
                                |   sub_memcg->swappiness = 60;
    memcg->swappiness = 10;     |

In the above scenario, we end up having 2 different swappiness
values in a single hierarchy.

We should hold cgroup_lock() when cheking cgrp->children list.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
068b38c1
Name Last commit Last update
..
Kconfig Remove obsolete CONFIG_RESOURCES_64BIT
Makefile shmem: unify regular and tiny shmem
allocpercpu.c mm/allocpercpu.c: make 4 functions static
backing-dev.c Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
bootmem.c bootmem: print request details before BUG_ON(them)
bounce.c bounce: don't rely on a zeroed bio_vec list
dmapool.c dmapool: enable debugging for CONFIG_SLUB_DEBUG_ON too
fadvise.c [CVE-2009-0029] System call wrapper special cases
failslab.c SLUB: failslab support
filemap.c [CVE-2009-0029] System call wrapper special cases
filemap_xip.c badpage: remove vma from page_remove_rmap
fremap.c [CVE-2009-0029] System call wrappers part 13
highmem.c x86, pat: avoid highmem cache attribute aliasing
hugetlb.c mm: hugetlb: remove redundant `if' operation
internal.h mm: make get_user_pages() interruptible
maccess.c kgdb: fix optional arch functions and probe_kernel_*
madvise.c [CVE-2009-0029] System call wrappers part 14
memcontrol.c memcg: fix a race when setting memory.swappiness
memory.c x86 PAT: change track_pfn_vma_new to take pgprot_t pointer param
memory_hotplug.c mm: remove GFP_HIGHUSER_PAGECACHE
mempolicy.c [CVE-2009-0029] System call wrappers part 28
mempool.c spelling fixes: mm/
migrate.c [CVE-2009-0029] System call wrappers part 28
mincore.c [CVE-2009-0029] System call wrappers part 14
mlock.c [CVE-2009-0029] System call wrappers part 14
mm_init.c
mmap.c
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c
msync.c
nommu.c
oom_kill.c
page-writeback.c
page_alloc.c
page_cgroup.c
page_io.c
page_isolation.c
pagewalk.c
pdflush.c
prio_tree.c
quicklist.c
readahead.c
rmap.c
shmem.c
shmem_acl.c
slab.c
slob.c
slub.c
sparse-vmemmap.c
sparse.c
swap.c
swap_state.c
swapfile.c
thrash.c
truncate.c
util.c
vmalloc.c
vmscan.c
vmstat.c