Skip to content

Commit 9c1cc2e

Browse files
yhuang-inteltorvalds
authored andcommitted
mm, swap: fix comment in __read_swap_cache_async
Commit cbab0e4 ("swap: avoid read_swap_cache_async() race to deadlock while waiting on discard I/O completion") fixed a deadlock in read_swap_cache_async(). Because at that time, in swap allocation path, a swap entry may be set as SWAP_HAS_CACHE, then wait for discarding to complete before the page for the swap entry is added to the swap cache. But in commit 815c2c5 ("swap: make swap discard async"), the discarding for swap become asynchronous, waiting for discarding to complete will be done before the swap entry is set as SWAP_HAS_CACHE. So the comments in code is incorrect now. This patch fixes the comments. The cond_resched() added in the commit cbab0e4 is not necessary now too. But if we added some sleep in swap allocation path in the future, there may be some hard to debug/reproduce deadlock bug. So it is kept. Link: http://lkml.kernel.org/r/20170317064635.12792-1-ying.huang@intel.com Signed-off-by: "Huang, Ying" <ying.huang@intel.com> Acked-by: Rafael Aquini <aquini@redhat.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>
1 parent 83612a9 commit 9c1cc2e

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

‎mm/swap_state.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
360360
/*
361361
* We might race against get_swap_page() and stumble
362362
* across a SWAP_HAS_CACHE swap_map entry whose page
363-
* has not been brought into the swapcache yet, while
364-
* the other end is scheduled away waiting on discard
365-
* I/O completion at scan_swap_map().
366-
*
367-
* In order to avoid turning this transitory state
368-
* into a permanent loop around this -EEXIST case
369-
* if !CONFIG_PREEMPT and the I/O completion happens
370-
* to be waiting on the CPU waitqueue where we are now
371-
* busy looping, we just conditionally invoke the
372-
* scheduler here, if there are some more important
373-
* tasks to run.
363+
* has not been brought into the swapcache yet.
374364
*/
375365
cond_resched();
376366
continue;

0 commit comments

Comments
 (0)