* [PATCH] mm: page_alloc: avoid false page outside zone error info
@ 2023-07-04 11:18 Miaohe Lin
2023-07-04 12:13 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: Miaohe Lin @ 2023-07-04 11:18 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, linmiaohe
If pfn is outside zone boundaries in the first round, ret will be set
to 1. But if pfn is changed to inside the zone boundaries in zone span
seqretry path, ret is still set to 1 leading to false page outside zone
error info.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/page_alloc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7d3460c7a480..40a9f3ed25e9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -459,7 +459,7 @@ void set_pageblock_migratetype(struct page *page, int migratetype)
#ifdef CONFIG_DEBUG_VM
static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
{
- int ret = 0;
+ int ret;
unsigned seq;
unsigned long pfn = page_to_pfn(page);
unsigned long sp, start_pfn;
@@ -470,6 +470,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
sp = zone->spanned_pages;
if (!zone_spans_pfn(zone, pfn))
ret = 1;
+ else
+ ret = 0;
} while (zone_span_seqretry(zone, seq));
if (ret)
--
2.33.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: page_alloc: avoid false page outside zone error info
2023-07-04 11:18 [PATCH] mm: page_alloc: avoid false page outside zone error info Miaohe Lin
@ 2023-07-04 12:13 ` Matthew Wilcox
2023-07-04 12:36 ` Miaohe Lin
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2023-07-04 12:13 UTC (permalink / raw)
To: Miaohe Lin; +Cc: akpm, linux-mm, linux-kernel
On Tue, Jul 04, 2023 at 07:18:23PM +0800, Miaohe Lin wrote:
> @@ -470,6 +470,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
> sp = zone->spanned_pages;
> if (!zone_spans_pfn(zone, pfn))
> ret = 1;
> + else
> + ret = 0;
Surely 'ret = zone_spans_pfn(zone, pfn);' ?
Also, did you spot this by inspection or do you have a test-case or bug
report? Should this have a Fixes: tag?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: page_alloc: avoid false page outside zone error info
2023-07-04 12:13 ` Matthew Wilcox
@ 2023-07-04 12:36 ` Miaohe Lin
2023-07-04 16:38 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Miaohe Lin @ 2023-07-04 12:36 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: akpm, linux-mm, linux-kernel
On 2023/7/4 20:13, Matthew Wilcox wrote:
> On Tue, Jul 04, 2023 at 07:18:23PM +0800, Miaohe Lin wrote:
>> @@ -470,6 +470,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
>> sp = zone->spanned_pages;
>> if (!zone_spans_pfn(zone, pfn))
>> ret = 1;
>> + else
>> + ret = 0;
>
> Surely 'ret = zone_spans_pfn(zone, pfn);' ?
Do you mean 'ret = !zone_spans_pfn(zone, pfn);'? This format looks fine to me.
>
> Also, did you spot this by inspection or do you have a test-case or bug
> report? Should this have a Fixes: tag?
This is from code inspection. The race window should be really small thus hard to trigger
in real world. And yes, it seems Fixes tag is a really ancient commit:
Fixes: bdc8cb984576 ("[PATCH] memory hotplug locking: zone span seqlock")
Thanks for your comment and reply.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: page_alloc: avoid false page outside zone error info
2023-07-04 12:36 ` Miaohe Lin
@ 2023-07-04 16:38 ` Andrew Morton
2023-07-05 1:43 ` Miaohe Lin
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2023-07-04 16:38 UTC (permalink / raw)
To: Miaohe Lin; +Cc: Matthew Wilcox, linux-mm, linux-kernel
On Tue, 4 Jul 2023 20:36:00 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:
> On 2023/7/4 20:13, Matthew Wilcox wrote:
> > On Tue, Jul 04, 2023 at 07:18:23PM +0800, Miaohe Lin wrote:
> >> @@ -470,6 +470,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
> >> sp = zone->spanned_pages;
> >> if (!zone_spans_pfn(zone, pfn))
> >> ret = 1;
> >> + else
> >> + ret = 0;
> >
> > Surely 'ret = zone_spans_pfn(zone, pfn);' ?
>
> Do you mean 'ret = !zone_spans_pfn(zone, pfn);'? This format looks fine to me.
>
> >
> > Also, did you spot this by inspection or do you have a test-case or bug
> > report? Should this have a Fixes: tag?
>
> This is from code inspection. The race window should be really small thus hard to trigger
> in real world. And yes, it seems Fixes tag is a really ancient commit:
>
> Fixes: bdc8cb984576 ("[PATCH] memory hotplug locking: zone span seqlock")
>
Thanks. I updated the changelog:
: If pfn is outside zone boundaries in the first round, ret will be set to
: 1. But if pfn is changed to inside the zone boundaries in zone span
: seqretry path, ret is still set to 1 leading to false page outside zone
: error info.
:
: This is from code inspection. The race window should be really small thus
: hard to trigger in real world.
:
: Link: https://lkml.kernel.org/r/20230704111823.940331-1-linmiaohe@huawei.com
: Fixes: bdc8cb984576 ("[PATCH] memory hotplug locking: zone span seqlock")
and I made the change suggested by Matthew:
--- a/mm/page_alloc.c~mm-page_alloc-avoid-false-page-outside-zone-error-info-fix
+++ a/mm/page_alloc.c
@@ -468,10 +468,7 @@ static int page_outside_zone_boundaries(
seq = zone_span_seqbegin(zone);
start_pfn = zone->zone_start_pfn;
sp = zone->spanned_pages;
- if (!zone_spans_pfn(zone, pfn))
- ret = 1;
- else
- ret = 0;
+ ret = !zone_spans_pfn(zone, pfn);
} while (zone_span_seqretry(zone, seq));
if (ret)
_
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: page_alloc: avoid false page outside zone error info
2023-07-04 16:38 ` Andrew Morton
@ 2023-07-05 1:43 ` Miaohe Lin
0 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2023-07-05 1:43 UTC (permalink / raw)
To: Andrew Morton; +Cc: Matthew Wilcox, linux-mm, linux-kernel
On 2023/7/5 0:38, Andrew Morton wrote:
> On Tue, 4 Jul 2023 20:36:00 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:
>
>> On 2023/7/4 20:13, Matthew Wilcox wrote:
>>> On Tue, Jul 04, 2023 at 07:18:23PM +0800, Miaohe Lin wrote:
>>>> @@ -470,6 +470,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
>>>> sp = zone->spanned_pages;
>>>> if (!zone_spans_pfn(zone, pfn))
>>>> ret = 1;
>>>> + else
>>>> + ret = 0;
>>>
>>> Surely 'ret = zone_spans_pfn(zone, pfn);' ?
>>
>> Do you mean 'ret = !zone_spans_pfn(zone, pfn);'? This format looks fine to me.
>>
>>>
>>> Also, did you spot this by inspection or do you have a test-case or bug
>>> report? Should this have a Fixes: tag?
>>
>> This is from code inspection. The race window should be really small thus hard to trigger
>> in real world. And yes, it seems Fixes tag is a really ancient commit:
>>
>> Fixes: bdc8cb984576 ("[PATCH] memory hotplug locking: zone span seqlock")
>>
>
> Thanks. I updated the changelog:
>
> : If pfn is outside zone boundaries in the first round, ret will be set to
> : 1. But if pfn is changed to inside the zone boundaries in zone span
> : seqretry path, ret is still set to 1 leading to false page outside zone
> : error info.
> :
> : This is from code inspection. The race window should be really small thus
> : hard to trigger in real world.
> :
> : Link: https://lkml.kernel.org/r/20230704111823.940331-1-linmiaohe@huawei.com
> : Fixes: bdc8cb984576 ("[PATCH] memory hotplug locking: zone span seqlock")
>
> and I made the change suggested by Matthew:
>
> --- a/mm/page_alloc.c~mm-page_alloc-avoid-false-page-outside-zone-error-info-fix
> +++ a/mm/page_alloc.c
> @@ -468,10 +468,7 @@ static int page_outside_zone_boundaries(
> seq = zone_span_seqbegin(zone);
> start_pfn = zone->zone_start_pfn;
> sp = zone->spanned_pages;
> - if (!zone_spans_pfn(zone, pfn))
> - ret = 1;
> - else
> - ret = 0;
> + ret = !zone_spans_pfn(zone, pfn);
> } while (zone_span_seqretry(zone, seq));
These changes look good to me. Thanks for doing this.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-05 1:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 11:18 [PATCH] mm: page_alloc: avoid false page outside zone error info Miaohe Lin
2023-07-04 12:13 ` Matthew Wilcox
2023-07-04 12:36 ` Miaohe Lin
2023-07-04 16:38 ` Andrew Morton
2023-07-05 1:43 ` Miaohe Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox