Skip to contentSkip to conversation

mm: account nr_isolated_xxx in [isolate|putback]_lru_page

PATCH Hillf Danton 2 participants 2 messages Jun 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Minchan

Quoted 9 lines · On Mon, 3 Jun 2019 13:37:27 +0800 Minchan Kim wrote:
(quoted diff) +2 -0
@@ -1181,10 +1179,17 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,
 		return -ENOMEM;
 
 	if (page_count(page) == 1) {
+		bool is_lru = !__PageMovable(page);
+
 		/* page was freed from under us. So we are done. */
 		ClearPageActive(page);
 		ClearPageUnevictable(page);

Review static ICE_noinline int unmap_and_move(new_page_t get_new_page, · line 1195

Quoted 10 lines
(quoted diff) +6 -1
-		if (unlikely(__PageMovable(page))) {
+		if (likely(is_lru))
+			mod_node_page_state(page_pgdat(page),
+						NR_ISOLATED_ANON +
+						page_is_file_cache(page),
+						hpage_nr_pages(page));
+		else {
 			lock_page(page);
 			if (!PageMovable(page))
 				__ClearPageIsolated(page);

As this page will go down the path only through the MIGRATEPAGE_SUCCESS branches, with no putback ahead, the current code is, I think, doing right things for this work to keep isolated stat balanced.

Quoted 5 lines
(quoted diff) +0 -1
@@ -1210,15 +1215,6 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,
 		 * restored.
 		 */
 		list_del(&page->lru);
-

Review static ICE_noinline int unmap_and_move(new_page_t get_new_page, · line 1219

Quoted 10 lines
(quoted diff) +0 -8
-		/*
-		 * Compaction can migrate also non-LRU pages which are
-		 * not accounted to NR_ISOLATED_*. They can be recognized
-		 * as __PageMovable
-		 */
-		if (likely(!__PageMovable(page)))
-			mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON +
-					page_is_file_cache(page), -hpage_nr_pages(page));
 	}
 

BR
Hillf

#1 lore raw

Hi Hillf,

Quoted 7 lines · Hillf Danton

Hi Minchan

Quoted 3 lines · On Mon, 3 Jun 2019 13:37:27 +0800 Minchan Kim wrote:
(quoted diff) +0 -0
@@ -1181,10 +1179,17 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,
 		return -ENOMEM;
 
Quoted 12 lines

Review static ICE_noinline int unmap_and_move(new_page_t get_new_page, · line 1191

Quoted 12 lines
(quoted diff) +7 -1
 	if (page_count(page) == 1) {
+		bool is_lru = !__PageMovable(page);
+
 		/* page was freed from under us. So we are done. */
 		ClearPageActive(page);
 		ClearPageUnevictable(page);
-		if (unlikely(__PageMovable(page))) {
+		if (likely(is_lru))
+			mod_node_page_state(page_pgdat(page),
+						NR_ISOLATED_ANON +
+						page_is_file_cache(page),
+						hpage_nr_pages(page));

That should be -hpage_nr_pages(page). It's a bug.

Quoted 8 lines

Review static ICE_noinline int unmap_and_move(new_page_t get_new_page, · line 1195

Quoted 4 lines
(quoted diff) +1 -0
+		else {
 			lock_page(page);
 			if (!PageMovable(page))
 				__ClearPageIsolated(page);

As this page will go down the path only through the MIGRATEPAGE_SUCCESS branches, with no putback ahead, the current code is, I think, doing right things for this work to keep isolated stat balanced.

I guess that's the one you pointed out. Right?
Thanks for the review!

Quoted 20 lines
Quoted 6 lines
(quoted diff) +0 -1
@@ -1210,15 +1215,6 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page,
 		 * restored.
 		 */
 		list_del(&page->lru);
-

Review static ICE_noinline int unmap_and_move(new_page_t get_new_page, · line 1219

Quoted 10 lines
(quoted diff) +0 -8
-		/*
-		 * Compaction can migrate also non-LRU pages which are
-		 * not accounted to NR_ISOLATED_*. They can be recognized
-		 * as __PageMovable
-		 */
-		if (likely(!__PageMovable(page)))
-			mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON +
-					page_is_file_cache(page), -hpage_nr_pages(page));
 	}
 

BR
Hillf