linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: page_isolation: check pfn validity before access
@ 2014-11-06  8:08 Weijie Yang
  2014-11-06 12:31 ` Michal Nazarewicz
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Weijie Yang @ 2014-11-06  8:08 UTC (permalink / raw)
  To: kamezawa.hiroyu, 'Minchan Kim'
  Cc: 'Andrew Morton', mgorman, mina86, 'linux-kernel',
	'Linux-MM', 'Weijie Yang'

In the undo path of start_isolate_page_range(), we need to check
the pfn validity before access its page, or it will trigger an
addressing exception if there is hole in the zone.

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

diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index d1473b2..3ddc8b3 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -137,8 +137,11 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
 undo:
 	for (pfn = start_pfn;
 	     pfn < undo_pfn;
-	     pfn += pageblock_nr_pages)
-		unset_migratetype_isolate(pfn_to_page(pfn), migratetype);
+	     pfn += pageblock_nr_pages) {
+		page = __first_valid_page(pfn, pageblock_nr_pages);
+		if (page)
+			unset_migratetype_isolate(page, migratetype);
+	}
 
 	return -EBUSY;
 }
-- 
1.7.0.4



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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-06  8:08 [PATCH 1/2] mm: page_isolation: check pfn validity before access Weijie Yang
@ 2014-11-06 12:31 ` Michal Nazarewicz
  2014-11-11 22:23 ` Andrew Morton
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Michal Nazarewicz @ 2014-11-06 12:31 UTC (permalink / raw)
  To: Weijie Yang, kamezawa.hiroyu, 'Minchan Kim'
  Cc: 'Andrew Morton', mgorman, 'linux-kernel',
	'Linux-MM', 'Weijie Yang'

On Thu, Nov 06 2014, Weijie Yang <weijie.yang@samsung.com> wrote:
> In the undo path of start_isolate_page_range(), we need to check
> the pfn validity before access its page, or it will trigger an
> addressing exception if there is hole in the zone.
>
> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  mm/page_isolation.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index d1473b2..3ddc8b3 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -137,8 +137,11 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
>  undo:
>  	for (pfn = start_pfn;
>  	     pfn < undo_pfn;
> -	     pfn += pageblock_nr_pages)
> -		unset_migratetype_isolate(pfn_to_page(pfn), migratetype);
> +	     pfn += pageblock_nr_pages) {
> +		page = __first_valid_page(pfn, pageblock_nr_pages);
> +		if (page)
> +			unset_migratetype_isolate(page, migratetype);
> +	}
>  
>  	return -EBUSY;
>  }
> -- 
> 1.7.0.4
>
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-06  8:08 [PATCH 1/2] mm: page_isolation: check pfn validity before access Weijie Yang
  2014-11-06 12:31 ` Michal Nazarewicz
@ 2014-11-11 22:23 ` Andrew Morton
  2014-11-12  2:10   ` Weijie Yang
  2014-11-12  2:02 ` Yasuaki Ishimatsu
  2014-11-12 19:34 ` Michal Hocko
  3 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2014-11-11 22:23 UTC (permalink / raw)
  To: Weijie Yang
  Cc: kamezawa.hiroyu, 'Minchan Kim',
	mgorman, mina86, 'linux-kernel', 'Linux-MM',
	'Weijie Yang'

On Thu, 06 Nov 2014 16:08:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote:

> In the undo path of start_isolate_page_range(), we need to check
> the pfn validity before access its page, or it will trigger an
> addressing exception if there is hole in the zone.
> 

There is not enough information in the chagnelog for me to decide how
to handle the patch.  3.19?  3.18? 3.18+stable?

When fixing bugs, please remember to fully explain the end-user impact
of the bug.  Under what circumstances does it occur?



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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-06  8:08 [PATCH 1/2] mm: page_isolation: check pfn validity before access Weijie Yang
  2014-11-06 12:31 ` Michal Nazarewicz
  2014-11-11 22:23 ` Andrew Morton
@ 2014-11-12  2:02 ` Yasuaki Ishimatsu
  2014-11-12 19:34 ` Michal Hocko
  3 siblings, 0 replies; 8+ messages in thread
From: Yasuaki Ishimatsu @ 2014-11-12  2:02 UTC (permalink / raw)
  To: Weijie Yang
  Cc: kamezawa.hiroyu, 'Minchan Kim', 'Andrew Morton',
	mgorman, mina86, 'linux-kernel', 'Linux-MM',
	'Weijie Yang'

(2014/11/06 17:08), Weijie Yang wrote:
> In the undo path of start_isolate_page_range(), we need to check
> the pfn validity before access its page, or it will trigger an
> addressing exception if there is hole in the zone.
>
> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
> ---

Looks good to me.

Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

>   mm/page_isolation.c |    7 +++++--
>   1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index d1473b2..3ddc8b3 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -137,8 +137,11 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
>   undo:
>   	for (pfn = start_pfn;
>   	     pfn < undo_pfn;
> -	     pfn += pageblock_nr_pages)
> -		unset_migratetype_isolate(pfn_to_page(pfn), migratetype);
> +	     pfn += pageblock_nr_pages) {
> +		page = __first_valid_page(pfn, pageblock_nr_pages);
> +		if (page)
> +			unset_migratetype_isolate(page, migratetype);
> +	}
>
>   	return -EBUSY;
>   }
>



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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-11 22:23 ` Andrew Morton
@ 2014-11-12  2:10   ` Weijie Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Weijie Yang @ 2014-11-12  2:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Weijie Yang, kamezawa.hiroyu, Minchan Kim, mgorman, mina86,
	linux-kernel, Linux-MM, isimatu.yasuaki

On Wed, Nov 12, 2014 at 6:23 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Thu, 06 Nov 2014 16:08:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote:
>
>> In the undo path of start_isolate_page_range(), we need to check
>> the pfn validity before access its page, or it will trigger an
>> addressing exception if there is hole in the zone.
>>
>
> There is not enough information in the chagnelog for me to decide how
> to handle the patch.  3.19?  3.18? 3.18+stable?
>
> When fixing bugs, please remember to fully explain the end-user impact
> of the bug.  Under what circumstances does it occur?

I'm sorry to disturb you. This issue is found by code-review not a test-trigger.
In "CONFIG_HOLES_IN_ZONE" environment, there is a certain chance that
it would casue an addressing exception when start_isolate_page_range() fails,
this could affect CMA, hugepage and memory-hotplug function.

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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-06  8:08 [PATCH 1/2] mm: page_isolation: check pfn validity before access Weijie Yang
                   ` (2 preceding siblings ...)
  2014-11-12  2:02 ` Yasuaki Ishimatsu
@ 2014-11-12 19:34 ` Michal Hocko
  2014-11-13  1:46   ` Weijie Yang
  3 siblings, 1 reply; 8+ messages in thread
From: Michal Hocko @ 2014-11-12 19:34 UTC (permalink / raw)
  To: Weijie Yang
  Cc: kamezawa.hiroyu, 'Minchan Kim', 'Andrew Morton',
	mgorman, mina86, 'linux-kernel', 'Linux-MM',
	'Weijie Yang'

On Thu 06-11-14 16:08:02, Weijie Yang wrote:
> In the undo path of start_isolate_page_range(), we need to check
> the pfn validity before access its page, or it will trigger an
> addressing exception if there is hole in the zone.

This looks a bit fishy to me. I am not familiar with the code much but
at least __offline_pages zone = page_zone(pfn_to_page(start_pfn)) so it
would blow up before we got here. Same applies to the other caller
alloc_contig_range. So either both need a fix and then
start_isolate_page_range doesn't need more checks or this is all
unnecessary.

Please do not make this code more obfuscated than it is already...

> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
> ---
>  mm/page_isolation.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> index d1473b2..3ddc8b3 100644
> --- a/mm/page_isolation.c
> +++ b/mm/page_isolation.c
> @@ -137,8 +137,11 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
>  undo:
>  	for (pfn = start_pfn;
>  	     pfn < undo_pfn;
> -	     pfn += pageblock_nr_pages)
> -		unset_migratetype_isolate(pfn_to_page(pfn), migratetype);
> +	     pfn += pageblock_nr_pages) {
> +		page = __first_valid_page(pfn, pageblock_nr_pages);
> +		if (page)
> +			unset_migratetype_isolate(page, migratetype);
> +	}
>  
>  	return -EBUSY;
>  }
> -- 
> 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>

-- 
Michal Hocko
SUSE Labs

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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-12 19:34 ` Michal Hocko
@ 2014-11-13  1:46   ` Weijie Yang
  2014-11-13 13:10     ` Michal Hocko
  0 siblings, 1 reply; 8+ messages in thread
From: Weijie Yang @ 2014-11-13  1:46 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Weijie Yang, kamezawa.hiroyu, Minchan Kim, Andrew Morton,
	mgorman, mina86, linux-kernel, Linux-MM

On Thu, Nov 13, 2014 at 3:34 AM, Michal Hocko <mhocko@suse.cz> wrote:
> On Thu 06-11-14 16:08:02, Weijie Yang wrote:
>> In the undo path of start_isolate_page_range(), we need to check
>> the pfn validity before access its page, or it will trigger an
>> addressing exception if there is hole in the zone.
>
> This looks a bit fishy to me. I am not familiar with the code much but
> at least __offline_pages zone = page_zone(pfn_to_page(start_pfn)) so it
> would blow up before we got here. Same applies to the other caller
> alloc_contig_range. So either both need a fix and then
> start_isolate_page_range doesn't need more checks or this is all
> unnecessary.

Thanks for your suggestion.
If start_isolate_page_range()'s user can ensure there isn't hole in
the [start_pfn, end_pfn) range, we can remove the checks. But if we
cann't, I think it's better reserve these "unnecessary" code.
That's really obfuscated : (

> Please do not make this code more obfuscated than it is already...
>
>> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
>> ---
>>  mm/page_isolation.c |    7 +++++--
>>  1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
>> index d1473b2..3ddc8b3 100644
>> --- a/mm/page_isolation.c
>> +++ b/mm/page_isolation.c
>> @@ -137,8 +137,11 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
>>  undo:
>>       for (pfn = start_pfn;
>>            pfn < undo_pfn;
>> -          pfn += pageblock_nr_pages)
>> -             unset_migratetype_isolate(pfn_to_page(pfn), migratetype);
>> +          pfn += pageblock_nr_pages) {
>> +             page = __first_valid_page(pfn, pageblock_nr_pages);
>> +             if (page)
>> +                     unset_migratetype_isolate(page, migratetype);
>> +     }
>>
>>       return -EBUSY;
>>  }
>> --
>> 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>
>
> --
> Michal Hocko
> SUSE Labs

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

* Re: [PATCH 1/2] mm: page_isolation: check pfn validity before access
  2014-11-13  1:46   ` Weijie Yang
@ 2014-11-13 13:10     ` Michal Hocko
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2014-11-13 13:10 UTC (permalink / raw)
  To: Weijie Yang
  Cc: Weijie Yang, kamezawa.hiroyu, Minchan Kim, Andrew Morton,
	mgorman, mina86, linux-kernel, Linux-MM

On Thu 13-11-14 09:46:34, Weijie Yang wrote:
> On Thu, Nov 13, 2014 at 3:34 AM, Michal Hocko <mhocko@suse.cz> wrote:
> > On Thu 06-11-14 16:08:02, Weijie Yang wrote:
> >> In the undo path of start_isolate_page_range(), we need to check
> >> the pfn validity before access its page, or it will trigger an
> >> addressing exception if there is hole in the zone.
> >
> > This looks a bit fishy to me. I am not familiar with the code much but
> > at least __offline_pages zone = page_zone(pfn_to_page(start_pfn)) so it
> > would blow up before we got here. Same applies to the other caller
> > alloc_contig_range. So either both need a fix and then
> > start_isolate_page_range doesn't need more checks or this is all
> > unnecessary.
> 
> Thanks for your suggestion.
> If start_isolate_page_range()'s user can ensure there isn't hole in
> the [start_pfn, end_pfn) range, we can remove the checks. But if we
> cann't, I think it's better reserve these "unnecessary" code.

I am not sure I understand you correctly but my point was that we do not
need check at start_isolate_page_range level but rather than in the
caller (or do not rely on pfn_to_page at that level). 

> That's really obfuscated : (
> 
> > Please do not make this code more obfuscated than it is already...
> >
> >> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
> >> ---
> >>  mm/page_isolation.c |    7 +++++--
> >>  1 files changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> >> index d1473b2..3ddc8b3 100644
> >> --- a/mm/page_isolation.c
> >> +++ b/mm/page_isolation.c
> >> @@ -137,8 +137,11 @@ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
> >>  undo:
> >>       for (pfn = start_pfn;
> >>            pfn < undo_pfn;
> >> -          pfn += pageblock_nr_pages)
> >> -             unset_migratetype_isolate(pfn_to_page(pfn), migratetype);
> >> +          pfn += pageblock_nr_pages) {
> >> +             page = __first_valid_page(pfn, pageblock_nr_pages);
> >> +             if (page)
> >> +                     unset_migratetype_isolate(page, migratetype);
> >> +     }
> >>
> >>       return -EBUSY;
> >>  }
> >> --
> >> 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>
> >
> > --
> > Michal Hocko
> > SUSE Labs

-- 
Michal Hocko
SUSE Labs

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

end of thread, other threads:[~2014-11-13 13:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-06  8:08 [PATCH 1/2] mm: page_isolation: check pfn validity before access Weijie Yang
2014-11-06 12:31 ` Michal Nazarewicz
2014-11-11 22:23 ` Andrew Morton
2014-11-12  2:10   ` Weijie Yang
2014-11-12  2:02 ` Yasuaki Ishimatsu
2014-11-12 19:34 ` Michal Hocko
2014-11-13  1:46   ` Weijie Yang
2014-11-13 13:10     ` Michal Hocko

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).