Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27931443rwd; Tue, 4 Jul 2023 09:53:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlEOESL+ClWH7KizaS4ZRw/TD3LrckBCm2zy8dYPN/xipllU2DeuHhDFBbaHkyE0i6zjhwpi X-Received: by 2002:a05:6808:15:b0:3a3:9ee4:f694 with SMTP id u21-20020a056808001500b003a39ee4f694mr9025027oic.13.1688489599126; Tue, 04 Jul 2023 09:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688489599; cv=none; d=google.com; s=arc-20160816; b=t5whiFEp+6KPY7iQtMMRoOb3TEFdvCH/Xe+dgc73cKKtjJlJDPXqxQ4H6WUD/y+dVe +G4UYQ16MRiwQuLYsa/CqUTP4EQNydJZNLeXhPmHpsaCZbP3OsQpKt7I9O+elzs7fJS8 XGGfhqdgH3aVaDtUJzhUE6p9HdKi+mF2u6qj8ks0xYBTlgDAGAXZAPWIWvBxxuVoF/Kp 3M0QKmyDP7c4JKJ5dGS2zUXMszs8RP5iPZ/6/55I0D/frA1SRXqMqUdHb6lGwAlPxMgK 7af0Xxu27JDGkckOktirR/DAa8/SiD97UCFD4BtmDjJKigAOvnYD/2m12PsvjXnARL0G qfZw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/WnAuEgRCaaPEPZ+bjL0ALr+SMsvPhJtmOIOcNmTsvQ=; fh=vLgVAXqsxcfH2kvpnd1sy9boS3Rj8HvJyDHW5CFkzYQ=; b=ESHhNBBNjQY4XhK866ZOmptvUI2wpQnuZ73VQKmIQ3aFQfflUXR2A3gdntNFKh3ybN DCarOxkVUjV4onFifsQZPOup4zW7p4u7aqOzKTpTbY+kSk0I7e/xQIJfYx/Qm3qHYpaH 6vAvAH7UJnzHUSflGZm4Qb646bjKfuufTBJKP3t27Xue434hrrP7JiD3KaB9/6BPbRSN QD90rzviEGUL9pNuAYyoxZKRig1fd5bWC4xE1V/SNy91lwqeUpzOCM3QHU27xSNQLPnU o3ouACituBkbxO1iTuUV4Jgv13zKSuwpRf36Zj9TRoGJluxhJOgKvW6WM2CyNn8MqRhS eppg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=hCn4l+cv; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t27-20020a056a00139b00b0068219eb279bsi13056734pfg.245.2023.07.04.09.53.04; Tue, 04 Jul 2023 09:53:19 -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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=hCn4l+cv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbjGDQiY (ORCPT + 99 others); Tue, 4 Jul 2023 12:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjGDQiW (ORCPT ); Tue, 4 Jul 2023 12:38:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B68CF for ; Tue, 4 Jul 2023 09:38:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DD06761301 for ; Tue, 4 Jul 2023 16:38:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 228A7C433C7; Tue, 4 Jul 2023 16:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1688488700; bh=SRt5OSq7UcsVoo2ymLntkRLL6RnihDX9GuA6gQcoxW4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hCn4l+cvagF7z1989a+b2iGQ7nKLnYNN3obSQ3+2Pb16X0nXchttRXUOH4aGXYRqJ OBIrBTZ64N/CaA+xbpsgiU/Kjx0M0iWUXJfFOKitdB643jwRA+G/EZZ4nd5vJJuGDZ p6J6r9IA7cNQ0i1LRZY+PFWae32zplgxotUDLMlw= Date: Tue, 4 Jul 2023 09:38:19 -0700 From: Andrew Morton To: Miaohe Lin Cc: Matthew Wilcox , , Subject: Re: [PATCH] mm: page_alloc: avoid false page outside zone error info Message-Id: <20230704093819.48443ca7789043a640c8a07a@linux-foundation.org> In-Reply-To: References: <20230704111823.940331-1-linmiaohe@huawei.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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)); if (ret) _