kernel-ark/mm
Eric Paris 0bd0f9fb19 [PATCH] hugetlb: fix race in set_max_huge_pages for multiple updaters of nr_huge_pages
If there are multiple updaters to /proc/sys/vm/nr_hugepages simultaneously
it is possible for the nr_huge_pages variable to become incorrect.  There
is no locking in the set_max_huge_pages function around
alloc_fresh_huge_page which is able to update nr_huge_pages.  Two callers
to alloc_fresh_huge_page could race against each other as could a call to
alloc_fresh_huge_page and a call to update_and_free_page.  This patch just
expands the area covered by the hugetlb_lock to cover the call into
alloc_fresh_huge_page.  I'm not sure how we could say that a sysctl section
is performance critical where more specific locking would be needed.

My reproducer was to run a couple copies of the following script
simultaneously

while [ true ]; do
	echo 1000 > /proc/sys/vm/nr_hugepages
	echo 500 > /proc/sys/vm/nr_hugepages
	echo 750 > /proc/sys/vm/nr_hugepages
	echo 100 > /proc/sys/vm/nr_hugepages
	echo 0 > /proc/sys/vm/nr_hugepages
done

and then watch /proc/meminfo and eventually you will see things like

HugePages_Total:     100
HugePages_Free:      109

After applying the patch all seemed well.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: William Irwin <wli@holomorphy.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-22 09:13:43 -08:00
..
bootmem.c
fadvise.c
filemap_xip.c
filemap.c [PATCH] x86_64: Remove obsolete ARCH_HAS_ATOMIC_UNSIGNED and page_flags_t 2005-11-14 19:55:14 -08:00
filemap.h
fremap.c [PATCH] unpaged: VM_NONLINEAR VM_RESERVED 2005-11-22 09:13:42 -08:00
highmem.c
hugetlb.c [PATCH] hugetlb: fix race in set_max_huge_pages for multiple updaters of nr_huge_pages 2005-11-22 09:13:43 -08:00
internal.h
Kconfig
madvise.c [PATCH] unpaged: VM_UNPAGED 2005-11-22 09:13:42 -08:00
Makefile
memory_hotplug.c
memory.c [PATCH] unpaged: ZERO_PAGE in VM_UNPAGED 2005-11-22 09:13:42 -08:00
mempolicy.c [PATCH] unpaged: VM_UNPAGED 2005-11-22 09:13:42 -08:00
mempool.c
mincore.c
mlock.c
mmap.c [PATCH] unpaged: private write VM_RESERVED 2005-11-22 09:13:42 -08:00
mprotect.c [PATCH] unpaged: private write VM_RESERVED 2005-11-22 09:13:42 -08:00
mremap.c
msync.c [PATCH] unpaged: VM_UNPAGED 2005-11-22 09:13:42 -08:00
nommu.c
oom_kill.c
page_alloc.c [PATCH] unpaged: PG_reserved bad_page 2005-11-22 09:13:42 -08:00
page_io.c
page-writeback.c [PATCH] re-export clear_page_dirty_for_io() 2005-11-18 07:49:45 -08:00
pdflush.c
prio_tree.c
readahead.c
rmap.c [PATCH] unpaged: anon in VM_UNPAGED 2005-11-22 09:13:42 -08:00
shmem.c
slab.c [PATCH] slab: remove alloc_pages() calls 2005-11-13 18:14:12 -08:00
sparse.c
swap_state.c
swap.c [PATCH] unpaged: unifdefed PageCompound 2005-11-22 09:13:42 -08:00
swapfile.c
thrash.c
tiny-shmem.c
truncate.c
vmalloc.c
vmscan.c