Skip to contentSkip to conversation

mm/swap.c: trivial mark_page_accessed() cleanup

PATCH In review [email protected] 1 participant 1 message Dec 1, 2019 Memory management

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 17/158 mm/swap.c: trivial mark_page_accessed() cleanup

From: Fengguang Wu <[email protected]>
Subject: mm/swap.c: trivial mark_page_accessed() cleanup

This avoids duplicated PageReferenced() calls. No behavior change.

---

 mm/swap.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
mm/swap.c renamed from mm/swap.c~mm-trivial-mark_page_accessed-cleanup +9 -4
@@ -373,9 +373,16 @@ static void __lru_cache_activate_page(st
 void mark_page_accessed(struct page *page)
 {
 	page = compound_head(page);
-	if (!PageActive(page) && !PageUnevictable(page) &&
-			PageReferenced(page)) {
 
+	if (!PageReferenced(page)) {
+		SetPageReferenced(page);
+	} else if (PageUnevictable(page)) {
+		/*
+		 * Unevictable pages are on the "LRU_UNEVICTABLE" list. But,
+		 * this list is never rotated or maintained, so marking an
+		 * evictable page accessed has no effect.
+		 */
+	} else if (!PageActive(page)) {
 		/*
 		 * If the page is on the LRU, queue it for activation via
 		 * activate_page_pvecs. Otherwise, assume the page is on a
@@ -389,8 +396,6 @@ void mark_page_accessed(struct page *pag
 		ClearPageReferenced(page);
 		if (page_is_file_cache(page))
 			workingset_activation(page);
-	} else if (!PageReferenced(page)) {
-		SetPageReferenced(page);
 	}
 	if (page_is_idle(page))
 		clear_page_idle(page);

_