linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page
@ 2014-12-09  7:51 Weijie Yang
  2014-12-09  9:24 ` Vlastimil Babka
  0 siblings, 1 reply; 3+ messages in thread
From: Weijie Yang @ 2014-12-09  7:51 UTC (permalink / raw)
  To: iamjoonsoo.kim
  Cc: 'Andrew Morton', mgorman, 'Rik van Riel',
	vbabka, 'Johannes Weiner', 'Minchan Kim',
	'Weijie Yang',
	linux-kernel, linux-mm

when we test the pages in a range is free or not, there is a little
chance we encounter some page which is not in buddy but page_count is 0.
That means that page could be in the page-freeing path but not in the
buddy freelist, such as in pcplist or wait for the zone->lock which the
tester is holding.

Back to the freepage_migratetype, we use it for a cached value for decide
which free-list the page go when freeing page. If the pageblock is isolated
the page will go to free-list[MIGRATE_ISOLATE] even if the cached type is
not MIGRATE_ISOLATE, the commit ad53f92e(fix incorrect isolation behavior
by rechecking migratetype) patch series have ensure this.

So the freepage_migratetype check for page_count==0 page in
__test_page_isolated_in_pageblock() is meaningless.
This patch removes the unnecessary freepage_migratetype check.

Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
---
 mm/page_isolation.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 6e5174d..f7c9183 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -223,8 +223,7 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
 		page = pfn_to_page(pfn);
 		if (PageBuddy(page))
 			pfn += 1 << page_order(page);
-		else if (page_count(page) == 0 &&
-			get_freepage_migratetype(page) == MIGRATE_ISOLATE)
+		else if (page_count(page) == 0)
 			pfn += 1;
 		else if (skip_hwpoisoned_pages && PageHWPoison(page)) {
 			/*
-- 
1.7.10.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	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page
  2014-12-09  7:51 [PATCH 2/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page Weijie Yang
@ 2014-12-09  9:24 ` Vlastimil Babka
  2014-12-10 14:10   ` Weijie Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2014-12-09  9:24 UTC (permalink / raw)
  To: Weijie Yang, iamjoonsoo.kim
  Cc: 'Andrew Morton', mgorman, 'Rik van Riel',
	'Johannes Weiner', 'Minchan Kim',
	'Weijie Yang',
	linux-kernel, linux-mm

On 12/09/2014 08:51 AM, Weijie Yang wrote:
> when we test the pages in a range is free or not, there is a little
> chance we encounter some page which is not in buddy but page_count is 0.
> That means that page could be in the page-freeing path but not in the
> buddy freelist, such as in pcplist

This shouldn't happen anymore IMHO. The pageblock is marked as 
MIGRATE_ISOLATE and then a lru+pcplist drain is performed. Nothing 
should be left on pcplist - anything newly freed goes directly to free 
lists. Hm, maybe it could be on lru cache, but that holds a page 
reference IIRC, so this test won't pass.

> or wait for the zone->lock which the
> tester is holding.

That could maybe happen, but is it worth testing? If yes, please add it 
in a comment to the code.

> Back to the freepage_migratetype, we use it for a cached value for decide
> which free-list the page go when freeing page. If the pageblock is isolated
> the page will go to free-list[MIGRATE_ISOLATE] even if the cached type is
> not MIGRATE_ISOLATE, the commit ad53f92e(fix incorrect isolation behavior
> by rechecking migratetype) patch series have ensure this.
>
> So the freepage_migratetype check for page_count==0 page in
> __test_page_isolated_in_pageblock() is meaningless.
> This patch removes the unnecessary freepage_migratetype check.
>
> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
> ---
>   mm/page_isolation.c |    3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index 6e5174d..f7c9183 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -223,8 +223,7 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
>   		page = pfn_to_page(pfn);
>   		if (PageBuddy(page))
>   			pfn += 1 << page_order(page);
> -		else if (page_count(page) == 0 &&
> -			get_freepage_migratetype(page) == MIGRATE_ISOLATE)
> +		else if (page_count(page) == 0)
>   			pfn += 1;
>   		else if (skip_hwpoisoned_pages && PageHWPoison(page)) {
>   			/*
>

--
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/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page
  2014-12-09  9:24 ` Vlastimil Babka
@ 2014-12-10 14:10   ` Weijie Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Weijie Yang @ 2014-12-10 14:10 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Weijie Yang, Joonsoo Kim, Andrew Morton, Mel Gorman,
	Rik van Riel, Johannes Weiner, Minchan Kim, Linux-Kernel,
	Linux-MM

On Tue, Dec 9, 2014 at 5:24 PM, Vlastimil Babka <vbabka@suse.cz> wrote:
> On 12/09/2014 08:51 AM, Weijie Yang wrote:
>>
>> when we test the pages in a range is free or not, there is a little
>> chance we encounter some page which is not in buddy but page_count is 0.
>> That means that page could be in the page-freeing path but not in the
>> buddy freelist, such as in pcplist
>
>
> This shouldn't happen anymore IMHO. The pageblock is marked as
> MIGRATE_ISOLATE and then a lru+pcplist drain is performed. Nothing should be
> left on pcplist - anything newly freed goes directly to free lists. Hm,
> maybe it could be on lru cache, but that holds a page reference IIRC, so
> this test won't pass.

Yes, you are right. I made a mistake, this shouldn't happen.
I will remove this description in next version. Thanks.

>> or wait for the zone->lock which the
>> tester is holding.
>
>
> That could maybe happen, but is it worth testing? If yes, please add it in a
> comment to the code.

This could happen even though the chance is very tiny.
As for cma_alloc, the test makes no difference.
However, as for offline_page, the test makes sense. If we leave the test and
pass it when page_count is zero, it could trigger the BUG_ON(!PageBuddy(page))
in the __offline_isolated_pages() if the page hasn't finish its free journey.

>From the literal meaning of this test_pages_isolated() function, I think it is
better get a definite result and not leave some middle status even if
they are rare.

So, Let's remove the whole test branch
(page_count(page) == 0 && get_freepage_migratetype(page) == MIGRATE_ISOLATE)

Thanks for your remind and suggestion.

>
>> Back to the freepage_migratetype, we use it for a cached value for decide
>> which free-list the page go when freeing page. If the pageblock is
>> isolated
>> the page will go to free-list[MIGRATE_ISOLATE] even if the cached type is
>> not MIGRATE_ISOLATE, the commit ad53f92e(fix incorrect isolation behavior
>> by rechecking migratetype) patch series have ensure this.
>>
>> So the freepage_migratetype check for page_count==0 page in
>> __test_page_isolated_in_pageblock() is meaningless.
>> This patch removes the unnecessary freepage_migratetype check.
>>
>> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
>> ---
>>   mm/page_isolation.c |    3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
>> index 6e5174d..f7c9183 100644
>> --- a/mm/page_isolation.c
>> +++ b/mm/page_isolation.c
>> @@ -223,8 +223,7 @@ __test_page_isolated_in_pageblock(unsigned long pfn,
>> unsigned long end_pfn,
>>                 page = pfn_to_page(pfn);
>>                 if (PageBuddy(page))
>>                         pfn += 1 << page_order(page);
>> -               else if (page_count(page) == 0 &&
>> -                       get_freepage_migratetype(page) == MIGRATE_ISOLATE)
>> +               else if (page_count(page) == 0)
>>                         pfn += 1;
>>                 else if (skip_hwpoisoned_pages && PageHWPoison(page)) {
>>                         /*
>>
>

--
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-12-10 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-09  7:51 [PATCH 2/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page Weijie Yang
2014-12-09  9:24 ` Vlastimil Babka
2014-12-10 14:10   ` Weijie Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox