linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] mm: page_isolation: fix zone_freepage accounting
@ 2014-11-06  8:09 Weijie Yang
  2014-11-06  8:49 ` Joonsoo Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Weijie Yang @ 2014-11-06  8:09 UTC (permalink / raw)
  To: kamezawa.hiroyu, 'Minchan Kim'
  Cc: 'Andrew Morton', mgorman, mina86, 'linux-kernel',
	'Linux-MM', 'Weijie Yang'

If race between isolatation and allocation happens, we could need to move
some freepages to MIGRATE_ISOLATE in __test_page_isolated_in_pageblock().
The current code ignores the zone_freepage accounting after the move,
which cause the zone NR_FREE_PAGES and NR_FREE_CMA_PAGES statistics incorrect.

This patch fixes this rare issue.

Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
---
 mm/page_isolation.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 3ddc8b3..15b51de 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -193,12 +193,15 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
 			 * is MIGRATE_ISOLATE. Catch it and move the page into
 			 * MIGRATE_ISOLATE list.
 			 */
-			if (get_freepage_migratetype(page) != MIGRATE_ISOLATE) {
+			int migratetype = get_freepage_migratetype(page);
+			if (migratetype != MIGRATE_ISOLATE) {
 				struct page *end_page;
 
 				end_page = page + (1 << page_order(page)) - 1;
 				move_freepages(page_zone(page), page, end_page,
 						MIGRATE_ISOLATE);
+				__mod_zone_freepage_state(zone,
+					-(1 << page_order(page)), migratetype);
 			}
 			pfn += 1 << page_order(page);
 		}
-- 
1.7.0.4


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] mm: page_isolation: fix zone_freepage accounting
  2014-11-06  8:09 [PATCH 2/2] mm: page_isolation: fix zone_freepage accounting Weijie Yang
@ 2014-11-06  8:49 ` Joonsoo Kim
  2014-11-07  2:47   ` Weijie Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Joonsoo Kim @ 2014-11-06  8:49 UTC (permalink / raw)
  To: Weijie Yang
  Cc: kamezawa.hiroyu, 'Minchan Kim', 'Andrew Morton',
	mgorman, mina86, 'linux-kernel', 'Linux-MM',
	'Weijie Yang'

On Thu, Nov 06, 2014 at 04:09:08PM +0800, Weijie Yang wrote:
> If race between isolatation and allocation happens, we could need to move
> some freepages to MIGRATE_ISOLATE in __test_page_isolated_in_pageblock().
> The current code ignores the zone_freepage accounting after the move,
> which cause the zone NR_FREE_PAGES and NR_FREE_CMA_PAGES statistics incorrect.
> 
> This patch fixes this rare issue.

Hello,

After "fix freepage count problems in memory isolation" merged, this race
should not happen. I have to remove it in that patchset, but, I
forgot to remove it. Please remove this race handling code completely and
tag with stable. If we don't remove it, there is errornous situation
because get_freepage_migratetype() could return invalid migratetype
although the page is on the correct buddy list. So, we regard
no race situation as race one.

Thanks.

> 
> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
> ---
>  mm/page_isolation.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index 3ddc8b3..15b51de 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -193,12 +193,15 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
>  			 * is MIGRATE_ISOLATE. Catch it and move the page into
>  			 * MIGRATE_ISOLATE list.
>  			 */
> -			if (get_freepage_migratetype(page) != MIGRATE_ISOLATE) {
> +			int migratetype = get_freepage_migratetype(page);
> +			if (migratetype != MIGRATE_ISOLATE) {
>  				struct page *end_page;
>  
>  				end_page = page + (1 << page_order(page)) - 1;
>  				move_freepages(page_zone(page), page, end_page,
>  						MIGRATE_ISOLATE);
> +				__mod_zone_freepage_state(zone,
> +					-(1 << page_order(page)), migratetype);
>  			}
>  			pfn += 1 << page_order(page);
>  		}
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] mm: page_isolation: fix zone_freepage accounting
  2014-11-06  8:49 ` Joonsoo Kim
@ 2014-11-07  2:47   ` Weijie Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Weijie Yang @ 2014-11-07  2:47 UTC (permalink / raw)
  To: Joonsoo Kim
  Cc: Weijie Yang, kamezawa.hiroyu, Minchan Kim, Andrew Morton, mgorman,
	mina86, linux-kernel, Linux-MM

On Thu, Nov 6, 2014 at 4:49 PM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> On Thu, Nov 06, 2014 at 04:09:08PM +0800, Weijie Yang wrote:
>> If race between isolatation and allocation happens, we could need to move
>> some freepages to MIGRATE_ISOLATE in __test_page_isolated_in_pageblock().
>> The current code ignores the zone_freepage accounting after the move,
>> which cause the zone NR_FREE_PAGES and NR_FREE_CMA_PAGES statistics incorrect.
>>
>> This patch fixes this rare issue.
>
> Hello,
>
> After "fix freepage count problems in memory isolation" merged, this race
> should not happen. I have to remove it in that patchset, but, I
> forgot to remove it. Please remove this race handling code completely and
> tag with stable. If we don't remove it, there is errornous situation
> because get_freepage_migratetype() could return invalid migratetype
> although the page is on the correct buddy list. So, we regard
> no race situation as race one.

Thanks for your remind, I will read your patch.

> Thanks.
>
>>
>> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
>> ---
>>  mm/page_isolation.c |    5 ++++-
>>  1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
>> index 3ddc8b3..15b51de 100644
>> --- a/mm/page_isolation.c
>> +++ b/mm/page_isolation.c
>> @@ -193,12 +193,15 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
>>                        * is MIGRATE_ISOLATE. Catch it and move the page into
>>                        * MIGRATE_ISOLATE list.
>>                        */
>> -                     if (get_freepage_migratetype(page) != MIGRATE_ISOLATE) {
>> +                     int migratetype = get_freepage_migratetype(page);
>> +                     if (migratetype != MIGRATE_ISOLATE) {
>>                               struct page *end_page;
>>
>>                               end_page = page + (1 << page_order(page)) - 1;
>>                               move_freepages(page_zone(page), page, end_page,
>>                                               MIGRATE_ISOLATE);
>> +                             __mod_zone_freepage_state(zone,
>> +                                     -(1 << page_order(page)), migratetype);
>>                       }
>>                       pfn += 1 << page_order(page);
>>               }
>> --
>> 1.7.0.4
>>
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majordomo@kvack.org.  For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-07  2:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06  8:09 [PATCH 2/2] mm: page_isolation: fix zone_freepage accounting Weijie Yang
2014-11-06  8:49 ` Joonsoo Kim
2014-11-07  2:47   ` Weijie Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).