Fix an enhance deactive_page
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>
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
@@ -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>
Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn
Quoted 27 lines · Minchan Kim
The
lru_deactivate_fnshould not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we useisolate_lru_pagesas__isolate_lru_pagecould return-EINVAL.
It's really BUG and let's fix it.Reported-by Ying Han <[email protected]>Tested-by Ying Han <[email protected]>Signed-off-by Minchan Kim <[email protected]>---
mm/swap.c | 3 +++1 files changed, 3 insertions(+), 0 deletions(-)mm/swap.c +3
-1@@ -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>
Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn
Quoted 21 lines · Ying Han
Quoted 20 lines · Minchan Kim
The
lru_deactivate_fnshould not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we useisolate_lru_pagesas__isolate_lru_pagecould return-EINVAL.
It's really BUG and let's fix it.Reported-by Ying Han <[email protected]>Tested-by Ying Han <[email protected]>Signed-off-by Minchan Kim <[email protected]>---
mm/swap.c | 3 +++1 files changed, 3 insertions(+), 0 deletions(-)mm/swap.c +0
-0@@ -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
Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn
In reply to Minchan KimQuoted 17 lines
The
lru_deactivate_fnshould not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we useisolate_lru_pagesas__isolate_lru_pagecould return-EINVAL.
It's really BUG and let's fix it.Reported-by Ying Han <[email protected]>Tested-by Ying Han <[email protected]>Signed-off-by Minchan Kim <[email protected]>--- mm/swap.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)mm/swap.c +0
-0
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>
Re: [PATCH 1/2] Check PageUnevictable in lru_deactivate_fn
In reply to Minchan KimQuoted 8 lines · Minchan Kim
The
lru_deactivate_fnshould not move page which in on unevictable lru into inactive list. Otherwise, we can meet BUG when we useisolate_lru_pagesas__isolate_lru_pagecould return-EINVAL.
It's really BUG and let's fix it.Reported-by Ying Han<[email protected]>Tested-by Ying Han<[email protected]>Signed-off-by Minchan Kim<[email protected]>
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>
PATCH 2/2 Filter unevictable page out in deactivate_page
In reply to Minchan KimIt'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
@@ -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>
Re: [PATCH 2/2] Filter unevictable page out in deactivate_page
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 insystem(ex, mprotect workload)Signed-off-by Minchan Kim <[email protected]>--- mm/swap.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)mm/swap.c +0
-0@@ -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>
Re: [PATCH 2/2] Filter unevictable page out in deactivate_page
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 insystem(ex, mprotect workload)Signed-off-by Minchan Kim <[email protected]>---
mm/swap.c | 9 +++++++++1 files changed, 9 insertions(+), 0 deletions(-)mm/swap.c +3
-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),
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; +Reviewed-by KOSAKI Motohiro <[email protected]>
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>
Re: [PATCH 2/2] Filter unevictable page out in deactivate_page
In reply to Minchan KimQuoted 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 insystem(ex, mprotect workload)Signed-off-by Minchan Kim<[email protected]>--- mm/swap.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)mm/swap.c +0
-0
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>
Re: [PATCH 2/2] Filter unevictable page out in deactivate_page
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 insystem(ex, mprotect workload)Signed-off-by Minchan Kim<[email protected]>---
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@@ -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>