aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/export-to-postgresql.py
diff options
context:
space:
mode:
authorVladimir Davydov <[email protected]>2015-06-24 16:56:56 -0700
committerLinus Torvalds <[email protected]>2015-06-24 17:49:42 -0700
commit414e2fb8ce5a999571c21eb2ca4d66e53ddce800 (patch)
tree6b0ad9177128cffd87951166bd3d3e7355f1d636 /tools/perf/scripts/python/export-to-postgresql.py
parent2491ffee9e66edc2a6ff5ddb49118377257c0014 (diff)
rmap: fix theoretical race between do_wp_page and shrink_active_list
As noted by Paul the compiler is free to store a temporary result in a variable on stack, heap or global unless it is explicitly marked as volatile, see: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4455.html#sample-optimizations This can result in a race between do_wp_page() and shrink_active_list() as follows. In do_wp_page() we can call page_move_anon_rmap(), which sets page->mapping as follows: anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; page->mapping = (struct address_space *) anon_vma; The page in question may be on an LRU list, because nowhere in do_wp_page() we remove it from the list, neither do we take any LRU related locks. Although the page is locked, shrink_active_list() can still call page_referenced() on it concurrently, because the latter does not require an anonymous page to be locked: CPU0 CPU1 ---- ---- do_wp_page shrink_active_list lock_page page_referenced PageAnon->yes, so skip trylock_page page_move_anon_rmap page->mapping = anon_vma rmap_walk PageAnon->no rmap_walk_file BUG page->mapping += PAGE_MAPPING_ANON This patch fixes this race by explicitly forbidding the compiler to split page->mapping store in page_move_anon_rmap() with the aid of WRITE_ONCE. [[email protected]: tweak comment, per Minchan] Signed-off-by: Vladimir Davydov <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Hugh Dickins <[email protected]> Acked-by: Minchan Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/export-to-postgresql.py')
0 files changed, 0 insertions, 0 deletions