Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05b7b7c7 authored by Zhenhua Huang's avatar Zhenhua Huang
Browse files

mm: give up CPU when swap cache in inconsistence state



The case is for __read_swap_cache_async():
If swap cache is deleted by __delete_from_swap_cache(), but
SWAP_HAS_CACHE flag not cleared yet by swapcache_free(). eg,
when sched out in delete_from_swap_cache(), or __remove_mapping().
In the mean time, current process unfortunately is RT,
then cond_sched() may not working. Introduce using usleep(500, 1000)
to give up CPU to another task.

CRs-Fixed: 2285534
Change-Id: Icf55fc2b01d95a552d3f3651c2d78d115fd17b1f
Signed-off-by: default avatarZhenhua Huang <zhenhuah@codeaurora.org>
parent f5feb668
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/blkdev.h>
#include <linux/pagevec.h>
#include <linux/migrate.h>
#include <linux/delay.h>

#include <asm/pgtable.h>

@@ -350,8 +351,11 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
			 * busy looping, we just conditionally invoke the
			 * scheduler here, if there are some more important
			 * tasks to run.
			 *
			 * cond_resched() may not work if the process is RT.
			 * We need a usleep_range() give up CPU to another task.
			 */
			cond_resched();
			usleep_range(500, 1000);
			continue;
		}
		if (err) {		/* swp entry is obsolete ? */