Skip to contentSkip to conversation

mm/damon/paddr: fix pin page problem

PATCH In review Andrew Yang 3 participants 4 messages Feb 21, 2023 – Feb 22, 2023

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

PATCH 1/1 mm/damon/paddr: fix pin page problem

From: "andrew.yang" <[email protected]>

damon_get_page() would always increase page _refcount and isolate_lru_page() would increase page _refcount if the page's lru flag is set.

If a unevictable page isolated successfully, there will be two more _refcount. The one from isolate_lru_page() will be decreased in putback_lru_page(), but the other one from damon_get_page() will be left behind. This causes a pin page.

Whatever the case, the _refcount from damon_get_page() should be decreased.

---
 mm/damon/paddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/paddr.c +1 -1
index e1a4315c4be6..56d8abd08fb1 100644
@@ -223,8 +223,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r)
 			putback_lru_page(page);
 		} else {
 			list_add(&page->lru, &page_list);
-			put_page(page);
 		}
+		put_page(page);
 	}
 	applied = reclaim_pages(&page_list);
 	cond_resched();
Signature · 1 line
2.18.0
#1 lore raw
Quoted 1 line · Andrew Yang

From: "andrew.yang" <[email protected]>

Nit: I'd suggest a different subject

"mm/damon/paddr: fix missing put_page()"

Fixes ?
Cc stable ?

I think a patch from Willy is queued that converts this code into folios.

Quoted 32 lines

damon_get_page() would always increase page _refcount and isolate_lru_page() would increase page _refcount if the page's lru flag is set.

If a unevictable page isolated successfully, there will be two more _refcount. The one from isolate_lru_page() will be decreased in putback_lru_page(), but the other one from damon_get_page() will be left behind. This causes a pin page.

Whatever the case, the _refcount from damon_get_page() should be decreased.

---
  mm/damon/paddr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/paddr.c +1 -1
index e1a4315c4be6..56d8abd08fb1 100644
@@ -223,8 +223,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r)
  			putback_lru_page(page);
  		} else {
  			list_add(&page->lru, &page_list);
-			put_page(page);
  		}
+		put_page(page);
  	}
  	applied = reclaim_pages(&page_list);
  	cond_resched();
Signature · 3 lines
Thanks,

David / dhildenb
maintainer
#2 lore raw
In reply to Andrew Yang

Hi Andrew,

Quoted 6 lines · On Tue, 21 Feb 2023 17:03:13 +0800 Andrew Yang <[email protected]> wrote:

From: "andrew.yang" <[email protected]>

damon_get_page() would always increase page _refcount and isolate_lru_page() would increase page _refcount if the page's lru flag is set.

Quoted 7 lines

If a unevictable page isolated successfully, there will be two more _refcount. The one from isolate_lru_page() will be decreased in putback_lru_page(), but the other one from damon_get_page() will be left behind. This causes a pin page.

Whatever the case, the _refcount from damon_get_page() should be decreased.

Thank you for finding this issue! I think the David suggested subject[1] is better, though.

I think we could add below Fixes: and Cc: tags?

Fixes 57223ac29584 ("mm/damon/paddr: support the pageout scheme")
Cc <[email protected]> # 5.16.x
Quoted 11 lines
---
 mm/damon/paddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/paddr.c +0 -0
index e1a4315c4be6..56d8abd08fb1 100644

mm/damon/paddr.c static unsigned long damon_pa_pageout(struct damon_region *r) · line 227

Quoted 6 lines
mm/damon/paddr.c +1 -1
@@ -223,8 +223,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r)
 			putback_lru_page(page);
 		} else {
 			list_add(&page->lru, &page_list);
-			put_page(page);
 		}
+		put_page(page);

Seems your patch is not based on mm-unstable tree[2]. Could you please rebase on it?

Also, let's remove the braces for the single statements[3].

[1] https://lore.kernel.org/damon/[email protected]/
[2] https://docs.kernel.org/next/mm/damon/maintainer-profile.html#scm-trees
[3] https://docs.kernel.org/process/coding-style.html?highlight=coding+style#placing-braces-and-spaces

Thanks,
SJ

Quoted 5 lines
mm/damon/paddr.c +0 -0
 	}
 	applied = reclaim_pages(&page_list);
 	cond_resched();
Signature · 1 line
2.18.0
#3 lore raw
Quoted 59 lines · SeongJae Park

Hi Andrew,

Quoted 6 lines · On Tue, 21 Feb 2023 17:03:13 +0800 Andrew Yang < [email protected]>…

From: "andrew.yang" <[email protected]>

damon_get_page() would always increase page _refcount and isolate_lru_page() would increase page _refcount if the page's lru flag is set.

Quoted 7 lines

If a unevictable page isolated successfully, there will be two more _refcount. The one from isolate_lru_page() will be decreased in putback_lru_page(), but the other one from damon_get_page() will be left behind. This causes a pin page.

Whatever the case, the _refcount from damon_get_page() should be decreased.

Thank you for finding this issue! I think the David suggested subject[1] is
better, though.

I think we could add below Fixes: and Cc: tags?

Fixes 57223ac29584 ("mm/damon/paddr: support the pageout scheme")
Cc <[email protected]> # 5.16.x
Quoted 11 lines
---
 mm/damon/paddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/paddr.c +0 -0
index e1a4315c4be6..56d8abd08fb1 100644

mm/damon/paddr.c static unsigned long damon_pa_pageout(struct · line 228

Quoted 7 lines
mm/damon/paddr.c +1 -1
@@ -223,8 +223,8 @@ static unsigned long damon_pa_pageout(struct
 damon_region *r)
 			putback_lru_page(page);
 		} else {
 			list_add(&page->lru, &page_list);
-			put_page(page);
 		}
+		put_page(page);

Seems your patch is not based on mm-unstable tree[2]. Could you please rebase
on it?

Also, let's remove the braces for the single statements[3].

[1]
https://lore.kernel.org/damon/[email protected]/
[2]
https://urldefense.com/v3/__https://docs.kernel.org/next/mm/damon/maintainer-profile.html*scm-trees__;Iw!!CTRNKA9wMg0ARbw!jlYra3CQPXNsppOWspkAkRO2AfKJEoMyAu8_JvZ9eY5b0YQbTB6sX1Gas-ZRtrMKXfxxpi7PEe8yeg$

Quoted 13 lines

[3]
https://urldefense.com/v3/__https://docs.kernel.org/process/coding-style.html?highlight=coding*style*placing-braces-and-spaces__;KyM!!CTRNKA9wMg0ARbw!jlYra3CQPXNsppOWspkAkRO2AfKJEoMyAu8_JvZ9eY5b0YQbTB6sX1Gas-ZRtrMKXfxxpi69jIOtSQ$

Thanks,
SJ

Quoted 5 lines
mm/damon/paddr.c +0 -0
 	}
 	applied = reclaim_pages(&page_list);

cond_resched();

Signature · 1 line
2.18.0

Thanks for both of your suggestions, I will update the patch.