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

Commit 81332eca authored by Vinayak Menon's avatar Vinayak Menon
Browse files

mm: vmscan: lock page on swap error in pageout



A workaround was added ealier to move a page to active
list if swapping to devices like zram fails. But this
can result in try_to_free_swap being called from
shrink_page_list, without a properly locked page.
Lock the page when we indicate to activate a page
in pageout().
Add a check to ensure that error is on swap, and
clear the error flag before moving the page to
active list.

CRs-fixed: 760049
Change-Id: I77a8bbd6ed13efdec943298fe9448412feeac176
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent e1b54da6
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -507,9 +507,19 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
		if (!PageWriteback(page)) {
			/* synchronous write or broken a_ops? */
			ClearPageReclaim(page);
			if (PageError(page))
			if (PageError(page) && PageSwapCache(page)) {
				ClearPageError(page);
				/*
				 * We lock the page here because it is required
				 * to free the swp space later in
				 * shrink_page_list. But the page may be
				 * unclocked by functions like
				 * handle_write_error.
				 */
				__set_page_locked(page);
				return PAGE_ACTIVATE;
			}
		}
		trace_mm_vmscan_writepage(page, trace_reclaim_flags(page));
		inc_zone_page_state(page, NR_VMSCAN_WRITE);
		return PAGE_SUCCESS;