Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28389555rwd; Tue, 4 Jul 2023 19:01:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77HWgK1uhECMTXOlKNfCRYuQTP4PwiFiFuUOVGtsr6u+3o7Wr9iAllY4+uWVkpaEdcP7Kk X-Received: by 2002:a05:6830:2011:b0:6b4:6c4b:b30a with SMTP id e17-20020a056830201100b006b46c4bb30amr15449923otp.12.1688522466101; Tue, 04 Jul 2023 19:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688522466; cv=none; d=google.com; s=arc-20160816; b=UWGj5ry7b6t5Te33Yjz33mbaehHtzeVDXG9gO7pjaRn6zC5iOtX72uSs2rTEc9uM7+ 4nVScsLD/F5dMGTTOFvkIS2bmh7ctT3E4W20d9YMUPRhKRNmTW3Gj/Op4+ExRH7FICZG 4jh+yBfq0i6g+x3gmEpCxkp21lYfPF+8DvXgTRgNtfETlI3Kr5q2pCnh5am4engxQvtm 9nDQENdWi37v3BSu9NCHpRe7CjBLZPxpVqJ/MH0LdVf8NtYB0N5TIXKFHRNmH7ub+k+H pvvtq+Uk8rgkyerZ6zzBKLRe4cNuWRDNHFy7gZaEqU+a3bLLe/hL8LVyxmyZXI7oRZJ6 n2Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=t6b1dd6F1PQZ2i1OUtrcnaopS/ndbeO8FOrN6Pn4+N4=; fh=47YDl5gZBIEz7XSVLB3F3oqICnpn6JuVYzq7VNSnGnw=; b=Uam3xemI29K2M0YliVLd8EpkCorLYp0RG+Kkyacb5K5nKQpsj+nu6fc2/4TH4kx8pI mO4L6EG17VPAOEeMDm3MwUHRyiP+fmkHgw8j33bDmj/3xcMX6oTJ5geWcQDJddXaKHWE NbvIDVbJTZ58Cz3tKcHnl1f5kS33VAceOELurvGYCr6fhRk258fgVNaBkDm2h7eAEchB laaqA8sf3zOTbTt/wJsO6UptnrgTxUfoov4ywLlxqUORwv6dzDfk458UFkpnNVKsC3pO ANa4Kun0KRj/qYKTdqQGo59tqqvvFDZUDnBYQzc5vlo/typANzG+SXwXjgnQrRIP98PV 4YgA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf3-20020a17090b1d8300b002612ccaaf09si510117pjb.61.2023.07.04.19.00.52; Tue, 04 Jul 2023 19:01:06 -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 S230297AbjGEBoE (ORCPT + 99 others); Tue, 4 Jul 2023 21:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjGEBoC (ORCPT ); Tue, 4 Jul 2023 21:44:02 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85199DD for ; Tue, 4 Jul 2023 18:44:01 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Qwj9d3f83zqTV4; Wed, 5 Jul 2023 09:43:33 +0800 (CST) Received: from [10.174.151.185] (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; Wed, 5 Jul 2023 09:43:58 +0800 Subject: Re: [PATCH] mm: page_alloc: avoid false page outside zone error info To: Andrew Morton CC: Matthew Wilcox , , References: <20230704111823.940331-1-linmiaohe@huawei.com> <20230704093819.48443ca7789043a640c8a07a@linux-foundation.org> From: Miaohe Lin Message-ID: Date: Wed, 5 Jul 2023 09:43:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20230704093819.48443ca7789043a640c8a07a@linux-foundation.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/7/5 0:38, Andrew Morton wrote: > On Tue, 4 Jul 2023 20:36:00 +0800 Miaohe Lin 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.