Skip to contentSkip to conversation

Fix an enhance deactive_page

PATCH Superseded Minchan Kim 4 participants 11 messages May 1, 2011 – May 3, 2011 Memory management

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix an enhance deactive_page

A few days ago, Ying reported a problem.
http://marc.info/?l=linux-mm&m=130403310601663&w=2
After I and Ying dive in problem, We found deactive_page has a problem. Apparently, It's a BUG so
[1/2] is fix of the problem and [2/2] is enhancement for helping CPU.

Minchan Kim (2):
[1/2] Check PageUnevictable in lru_deactivate_fn [2/2] Filter unevictable page out in deactivate_page

 mm/swap.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

PATCH 1/2 Check PageUnevictable in lru_deactivate_fn

The lru_deactivate_fn should not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we use isolate_lru_pages as __isolate_lru_page could return -EINVAL.
It's really BUG and let's fix it.

---
 mm/swap.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
mm/swap.c +3 -0
index a83ec5a..2e9656d 100644
@@ -429,6 +429,9 @@ static void lru_deactivate_fn(struct page *page, void *arg)
 	if (!PageLRU(page))
 		return;
 
+	if (PageUnevictable(page))
+		return;
+
 	/* Some processes are using the page */
 	if (page_mapped(page))
 		return;
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#6 lore raw

PATCH 2/2 Filter unevictable page out in deactivate_page

In reply to Minchan Kim

It's pointless that deactive_page's pagevec operation about unevictable page as it's nop.
This patch removes unnecessary overhead which might be a bit problem in case that there are many unevictable page in system(ex, mprotect workload)

---
 mm/swap.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
mm/swap.c +9 -0
index 2e9656d..b707694 100644
@@ -511,6 +511,15 @@ static void drain_cpu_pagevecs(int cpu)
  */
 void deactivate_page(struct page *page)
 {
+
+	/*
+	 * In workload which system has many unevictable page(ex, mprotect),
+	 * unevictalge page deactivation for accelerating reclaim
+	 * is pointless.
+	 */
+	if (PageUnevictable(page))
+		return;
+
 	if (likely(get_page_unless_zero(page))) {
 		struct pagevec *pvec = &get_cpu_var(lru_deactivate_pvecs);
 
Signature · 8 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn

In reply to Minchan Kim
Quoted 27 lines · Minchan Kim

The lru_deactivate_fn should not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we use isolate_lru_pages as __isolate_lru_page could return -EINVAL.
It's really BUG and let's fix it.

---
 mm/swap.c |    3 +++

 1 files changed, 3 insertions(+), 0 deletions(-)
mm/swap.c +3 -1
index a83ec5a..2e9656d 100644
@@ -429,6 +429,9 @@ static void lru_deactivate_fn(struct page *page, void *arg)
        if (!PageLRU(page))
                return;
 
+       if (PageUnevictable(page))
+               return;
+
        /* Some processes are using the page */
        if (page_mapped(page))
                return;
--
Quoted 1 line

1.7.1

Thanks Minchan for the fix, and i haven't been able to reproducing the issue after applying the patch.

--Ying

Quoted 1 line

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn

Quoted 21 lines · Ying Han
Quoted 20 lines · Minchan Kim

The lru_deactivate_fn should not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we use isolate_lru_pages as __isolate_lru_page could return -EINVAL.
It's really BUG and let's fix it.

---
 mm/swap.c |    3 +++

 1 files changed, 3 insertions(+), 0 deletions(-)
mm/swap.c +0 -0
index a83ec5a..2e9656d 100644
@@ -429,6 +429,9 @@ static void lru_deactivate_fn(struct page *page, void *arg)
        if (!PageLRU(page))
                return;
 
Quoted 11 lines
Quoted 8 lines
mm/swap.c +3 -1
+       if (PageUnevictable(page))
+               return;
+
        /* Some processes are using the page */
        if (page_mapped(page))
                return;
--

1.7.1

Thanks Minchan for the fix, and i haven't been able to reproducing the issue after applying the patch.

Thanks for the help, Ying.

Signature · 2 lines
Kind regards,
Minchan Kim
Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn

In reply to Minchan Kim
Quoted 17 lines

The lru_deactivate_fn should not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we use isolate_lru_pages as __isolate_lru_page could return -EINVAL.
It's really BUG and let's fix it.

---
 mm/swap.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
mm/swap.c +0 -0
index a83ec5a..2e9656d 100644

mm/swap.c static void lru_deactivate_fn(struct page *page, void *arg) · line 434

Quoted 6 lines
mm/swap.c +3 -0
@@ -429,6 +429,9 @@ static void lru_deactivate_fn(struct page *page, void *arg)
 	if (!PageLRU(page))
 		return;
 
+	if (PageUnevictable(page))
+		return;
+

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] Filter unevictable page out in deactivate_page

In reply to Minchan Kim
Quoted 17 lines

It's pointless that deactive_page's pagevec operation about unevictable page as it's nop.
This patch removes unnecessary overhead which might be a bit problem in case that there are many unevictable page in system(ex, mprotect workload)

---
 mm/swap.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
mm/swap.c +0 -0
index 2e9656d..b707694 100644
@@ -511,6 +511,15 @@ static void drain_cpu_pagevecs(int cpu)
  */
 void deactivate_page(struct page *page)

mm/swap.c static void drain_cpu_pagevecs(int cpu) · line 522

Quoted 10 lines
mm/swap.c +9 -0
 {
+
+	/*
+	 * In workload which system has many unevictable page(ex, mprotect),
+	 * unevictalge page deactivation for accelerating reclaim
+	 * is pointless.
+	 */
+	if (PageUnevictable(page))
+		return;
+

btw, I think we should check PageLRU too.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Reviewed-by on v1 1/2
#5 lore raw

Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn

In reply to Minchan Kim
Quoted 8 lines · Minchan Kim

The lru_deactivate_fn should not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we use isolate_lru_pages as __isolate_lru_page could return -EINVAL.
It's really BUG and let's fix it.

Signature · 8 lines
All rights reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw

Re: [PATCH 2/2] Filter unevictable page out in deactivate_page

In reply to Minchan Kim
Quoted 15 lines · Minchan Kim

It's pointless that deactive_page's pagevec operation about unevictable page as it's nop.
This patch removes unnecessary overhead which might be a bit problem in case that there are many unevictable page in system(ex, mprotect workload)

---
  mm/swap.c |    9 +++++++++
  1 files changed, 9 insertions(+), 0 deletions(-)
mm/swap.c +0 -0
index 2e9656d..b707694 100644

mm/swap.c static void drain_cpu_pagevecs(int cpu) · line 517

Quoted 7 lines
mm/swap.c +4 -0
@@ -511,6 +511,15 @@ static void drain_cpu_pagevecs(int cpu)
   */
  void deactivate_page(struct page *page)
  {
+
+	/*
+	 * In workload which system has many unevictable page(ex, mprotect),
+	 * unevictalge page deactivation for accelerating reclaim

Typo.

Quoted 8 lines
mm/swap.c +5 -0
+	 * is pointless.
+	 */
+	if (PageUnevictable(page))
+		return;
+
  	if (likely(get_page_unless_zero(page))) {
  		struct pagevec *pvec =&get_cpu_var(lru_deactivate_pvecs);
 
Signature · 8 lines
All rights reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#8 lore raw

Re: [PATCH 2/2] Filter unevictable page out in deactivate_page

In reply to KOSAKI Motohiro

Hi KOSAKI,

Quoted 21 lines · KOSAKI Motohiro
Quoted 21 lines

It's pointless that deactive_page's pagevec operation about unevictable page as it's nop.
This patch removes unnecessary overhead which might be a bit problem in case that there are many unevictable page in system(ex, mprotect workload)

---
 mm/swap.c |    9 +++++++++

 1 files changed, 9 insertions(+), 0 deletions(-)
mm/swap.c +3 -0
index 2e9656d..b707694 100644
@@ -511,6 +511,15 @@ static void drain_cpu_pagevecs(int cpu)
   */
  void deactivate_page(struct page *page)
  {
+
+     /*
+      * In workload which system has many unevictable page(ex, mprotect),
Quoted 9 lines

mm/swap.c static void drain_cpu_pagevecs(int cpu) · line 522

Quoted 6 lines
mm/swap.c +6 -0
+      * unevictalge page deactivation for accelerating reclaim
+      * is pointless.
+      */
+     if (PageUnevictable(page))
+             return;
+

Thanks!

Quoted 3 lines

btw, I think we should check PageLRU too.

Yes. I remember you advised it when we push this patch but I didn't. That's because I think most of pages in such context would be LRU as they are cached pages.
So IMO, PageLRU checking in deactivate_page couldn't help much.

Signature · 9 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#10 lore raw

Re: [PATCH 2/2] Filter unevictable page out in deactivate_page

In reply to Rik van Riel

Hi Rik,

Quoted 13 lines · Rik van Riel
Quoted 12 lines · Minchan Kim

It's pointless that deactive_page's pagevec operation about unevictable page as it's nop.
This patch removes unnecessary overhead which might be a bit problem in case that there are many unevictable page in system(ex, mprotect workload)

---
 mm/swap.c |    9 +++++++++

 1 files changed, 9 insertions(+), 0 deletions(-)
Quoted 15 lines

mm/swap.c static void drain_cpu_pagevecs(int cpu) · line 518

Quoted 13 lines
mm/swap.c +4 -0
index 2e9656d..b707694 100644
@@ -511,6 +511,15 @@ static void drain_cpu_pagevecs(int cpu)
   */
  void deactivate_page(struct page *page)
  {
+
+       /*
+        * In workload which system has many unevictable page(ex,
 mprotect),
+        * unevictalge page deactivation for accelerating reclaim

Typo.

My bad. I will resend after work.
Thanks.

Signature · 9 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>