aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRafael Aquini <aquini@redhat.com>2013-06-12 14:04:49 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-20 11:28:20 -0700
commit78ef884ebb6c02d45abefc95350f428be7390a26 (patch)
tree4b57c876160247db66c340770f66efeb3e05d7ca /include
parentbac5719cdfb081dd68b0eeef7d9796c15fc29811 (diff)
downloadkernel_samsung_smdk4412-78ef884ebb6c02d45abefc95350f428be7390a26.zip
kernel_samsung_smdk4412-78ef884ebb6c02d45abefc95350f428be7390a26.tar.gz
kernel_samsung_smdk4412-78ef884ebb6c02d45abefc95350f428be7390a26.tar.bz2
swap: avoid read_swap_cache_async() race to deadlock while waiting on discard I/O completion
commit cbab0e4eec299e9059199ebe6daf48730be46d2b upstream. read_swap_cache_async() can race against get_swap_page(), and stumble across a SWAP_HAS_CACHE entry in the swap map whose page wasn't brought into the swapcache yet. This transient swap_map state is expected to be transitory, but the actual placement of discard at scan_swap_map() inserts a wait for I/O completion thus making the thread at read_swap_cache_async() to loop around its -EEXIST case, while the other end at get_swap_page() is scheduled away at scan_swap_map(). This can leave the system deadlocked if the I/O completion happens to be waiting on the CPU waitqueue where read_swap_cache_async() is busy looping and !CONFIG_PREEMPT. This patch introduces a cond_resched() call to make the aforementioned read_swap_cache_async() busy loop condition to bail out when necessary, thus avoiding the subtle race window. Signed-off-by: Rafael Aquini <aquini@redhat.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: Hugh Dickins <hughd@google.com> Cc: Shaohua Li <shli@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions