Message ID | 20230704111823.940331-1-linmiaohe@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1150308vqx; Tue, 4 Jul 2023 04:34:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52yXrajyNOrUyiwp9pe1IPewgtmWk77ZNlKDC6bl9kQF8cFqZvnsLGCSN72QQD69652Rd2 X-Received: by 2002:a05:6808:1295:b0:3a1:ee4b:b8ee with SMTP id a21-20020a056808129500b003a1ee4bb8eemr17727287oiw.53.1688470494561; Tue, 04 Jul 2023 04:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688470494; cv=none; d=google.com; s=arc-20160816; b=a4x7dQIV3GWOUQciJPjuklBiR7NogOg1Cu+WNzeriQzHK6aMmGHs7r6cXdcJMx7QKH 3DZC8UwNRKOMI0j85x7eEQuYLSTrbvs6JnJ4vBzHptdflnVjoaEHbAfIIziSadC4yZLH GF/SaJJ9oj59hyUaoBAZZkjlA13rK9Zo28w2PlNCVpvD3zrtLRWKCHRuxX17Wp9EgR6w gKoHpzzvwoT2Vr2TIuuzAu7W1ScF65PIwmWKJvgv+QCBLQoVMnl14isoKCfdtJwpRfo1 PT27Bhu1vqzAFVA65qzvnwTHNhXZm+GyN+Z+tHahpoPBhbs0ZijzPKe0hPVvFJyXaWLr cwdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=4PkSoJiG9MPa0AmTrsShgG7oKRkad5jcuz48t7grpJM=; fh=FobMmrDqk0Azkn+fo26GJOi636EkoTJwUmD0cLgONUY=; b=Qw+5xrOliGcwiAOdf5tTz+PayRZrn/N8AQo8zw4KcX910KBHHCYKSgbFcIkzLIaWRg cg80InUNBKQ9VDJ7Njevlhc355jPKMyaxcvJev0dzF9ZRkvZZ/0NIhiZwah5TN78F2c7 LV06InZvd5nVFE3HA86L3yOyA3POJJxx4bU4x8vGQt2t8tS99KY0LqKRRQ9ftk7N19mi tb0eEPsnXpXk30i5smHHn6cIQfxdEIZDnzH7YoD1l98t4NFP5ZPdha2Wj+ii9TAm7SfA /OqXltgDEEXgfGo+qHn+w2ntIlWjUaqLjkKkgTHmEMh6o9fVRxGXi1hqGJ5/qNN8NkYV sqTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn18-20020a17090b38d200b0026389f6c799si9224283pjb.146.2023.07.04.04.34.39; Tue, 04 Jul 2023 04:34:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbjGDLTX (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 4 Jul 2023 07:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbjGDLTU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 4 Jul 2023 07:19:20 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34FF919A4 for <linux-kernel@vger.kernel.org>; Tue, 4 Jul 2023 04:18:54 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QwKxq1tptzTm0q; Tue, 4 Jul 2023 19:17:03 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 4 Jul 2023 19:18:04 +0800 From: Miaohe Lin <linmiaohe@huawei.com> To: <akpm@linux-foundation.org> CC: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com> Subject: [PATCH] mm: page_alloc: avoid false page outside zone error info Date: Tue, 4 Jul 2023 19:18:23 +0800 Message-ID: <20230704111823.940331-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770489637373216490?= X-GMAIL-MSGID: =?utf-8?q?1770489637373216490?= |
Series |
mm: page_alloc: avoid false page outside zone error info
|
|
Commit Message
Miaohe Lin
July 4, 2023, 11:18 a.m. UTC
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(-)
Comments
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?
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.
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)
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.
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)