• Minchan Kim's avatar
    vmscan: add barrier to prevent evictable page in unevictable list · 21ee9f39
    Minchan Kim authored
    When a race between putback_lru_page() and shmem_lock with lock=0 happens,
    progrom execution order is as follows, but clear_bit in processor #1 could
    be reordered right before spin_unlock of processor #1.  Then, the page
    would be stranded on the unevictable list.
    
    spin_lock
    SetPageLRU
    spin_unlock
                                    clear_bit(AS_UNEVICTABLE)
                                    spin_lock
                                    if PageLRU()
                                            if !test_bit(AS_UNEVICTABLE)
                                            	move evictable list
    smp_mb
    if !test_bit(AS_UNEVICTABLE)
            move evictable list
                                    spin_unlock
    
    But, pagevec_lookup() in scan_mapping_unevictable_pages() has
    rcu_read_[un]lock() so it could protect reordering before reaching
    test_bit(AS_UNEVICTABLE) on processor #1 so this problem never happens.
    But it's a unexpected side effect and we should solve this problem
    properly.
    
    This patch adds a barrier after mapping_clear_unevictable.
    
    I didn't meet this problem but just found during review.
    Signed-off-by: default avatarMinchan Kim <minchan.kim@gmail.com>
    Acked-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Cc: Mel Gorman <mel@csn.ul.ie>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
    Acked-by: default avatarJohannes Weiner <jweiner@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    21ee9f39
Name
Last commit
Last update
..
Kconfig Loading commit data...
Kconfig.debug Loading commit data...
Makefile Loading commit data...
backing-dev.c Loading commit data...
bootmem.c Loading commit data...
bounce.c Loading commit data...
cleancache.c Loading commit data...
compaction.c Loading commit data...
debug-pagealloc.c Loading commit data...
dmapool.c Loading commit data...
fadvise.c Loading commit data...
failslab.c Loading commit data...
filemap.c Loading commit data...
filemap_xip.c Loading commit data...
fremap.c Loading commit data...
highmem.c Loading commit data...
huge_memory.c Loading commit data...
hugetlb.c Loading commit data...
hwpoison-inject.c Loading commit data...
init-mm.c Loading commit data...
internal.h Loading commit data...
kmemcheck.c Loading commit data...
kmemleak-test.c Loading commit data...
kmemleak.c Loading commit data...
ksm.c Loading commit data...
maccess.c Loading commit data...
madvise.c Loading commit data...
memblock.c Loading commit data...
memcontrol.c Loading commit data...
memory-failure.c Loading commit data...
memory.c Loading commit data...
memory_hotplug.c Loading commit data...
mempolicy.c Loading commit data...
mempool.c Loading commit data...
migrate.c Loading commit data...
mincore.c Loading commit data...
mlock.c Loading commit data...
mm_init.c Loading commit data...
mmap.c Loading commit data...
mmu_context.c Loading commit data...
mmu_notifier.c Loading commit data...
mmzone.c Loading commit data...
mprotect.c Loading commit data...
mremap.c Loading commit data...
msync.c Loading commit data...
nobootmem.c Loading commit data...
nommu.c Loading commit data...
oom_kill.c Loading commit data...
page-writeback.c Loading commit data...
page_alloc.c Loading commit data...
page_cgroup.c Loading commit data...
page_io.c Loading commit data...
page_isolation.c Loading commit data...
pagewalk.c Loading commit data...
percpu-km.c Loading commit data...
percpu-vm.c Loading commit data...
percpu.c Loading commit data...
pgtable-generic.c Loading commit data...
prio_tree.c Loading commit data...
process_vm_access.c Loading commit data...
quicklist.c Loading commit data...
readahead.c Loading commit data...
rmap.c Loading commit data...
shmem.c Loading commit data...
slab.c Loading commit data...
slob.c Loading commit data...
slub.c Loading commit data...
sparse-vmemmap.c Loading commit data...
sparse.c Loading commit data...
swap.c Loading commit data...
swap_state.c Loading commit data...
swapfile.c Loading commit data...
thrash.c Loading commit data...
truncate.c Loading commit data...
util.c Loading commit data...
vmalloc.c Loading commit data...
vmscan.c Loading commit data...
vmstat.c Loading commit data...