Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp396062rdb; Thu, 5 Oct 2023 08:58:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfiXtal6vKWeQyAfOwcUFaaVEjiVYEQsHkQu+BumF6agyEIl+cDZvXSTdcdKqMTWQgGZG0 X-Received: by 2002:a17:902:8212:b0:1c7:29fd:33b6 with SMTP id x18-20020a170902821200b001c729fd33b6mr5175839pln.40.1696521520944; Thu, 05 Oct 2023 08:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521520; cv=none; d=google.com; s=arc-20160816; b=SeUV9M1NOYdN3f5ohoGp6AOEsWec4H5OwFfCUcFbQU5SSb4FXmOLmaJ6KW9qdexold 80E89wKlMBvprLdbSjLeBqGyKqpyuxSA+MQC4Ang/vO10RR1Vcix9G/Ed2O8UKsi2v6i Mu5xi8s2kvmd7sz3zvWugZDPo9M6S/BBfEBSa1MJdvic1W6oyetaz1vB+bhFHejICD90 lCnxucUEvp5pLy4CMQa6VMyuiIKDUgPV0zyUupItnW6M11AAb4KzsUkahJem4ayBDJjj 8GVv+LXCz03AntvvAuTcICcV8P61ulqHTWdm0DPNqCS8PvKoKZVsBHWiGyaymFuACyqN Ja8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=czgSb+pm6uNjMEiZ+zLe1URTxhscF82iKhFuHMluZ1o=; fh=WzmU0R+Jl7RzUb7lYiYf1G4vfjpBuXWbidBx19MTwwE=; b=KYuJ8d7GbHlbyRv+lzkyhvNVSLPVHxCgw7w5kSY10fTPlNCGyh4yDIyhEXDtYkN/9B XVHwvzZ+Yt8Sx+Iw2rI5tPUU+pwgKWQtEYk9Ry22KVjwQ0EpwkdKLio6UNntlI3/vR+X UVEy+WJ4uavfo3cBE6SVE26tM5IalqQw3TZN/0prF4CFDkjNZj2QnigUNWYKOI5vj0i0 Rxfr5omnQtGhkPnTf194V6tZoPNeUYGLMNigTWSOYZo4evW+jCo1qyTmBvoU+ZHl0oWt ICM84WuTYUxYyBDtsl8S1P2BgA/tudwJcyZhLDeoDKb4fvHdUWO2t2S0yI9YrsjLv5Vc ptlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=plmD0wnA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n3-20020a170902e54300b001bf3fe55e78si1768419plf.600.2023.10.05.08.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=plmD0wnA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1DE8588D5174; Thu, 5 Oct 2023 08:58:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238157AbjJEP6W (ORCPT + 99 others); Thu, 5 Oct 2023 11:58:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234278AbjJEP4n (ORCPT ); Thu, 5 Oct 2023 11:56:43 -0400 Received: from out-193.mta0.migadu.com (out-193.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40EF46618 for ; Thu, 5 Oct 2023 07:04:41 -0700 (PDT) Message-ID: <6545ac4c-1205-6c09-49ea-e00c24d1a2ff@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696514677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=czgSb+pm6uNjMEiZ+zLe1URTxhscF82iKhFuHMluZ1o=; b=plmD0wnAyGVVn6u1f6DP2PD1OQ3xfBXTH2n1KSVIw0vTM9wlyerdB3V9BDsRd7ixuIkh3k waXcprzA8Z/ok/W19GBjZhG28HLF19G97VFOoWwdwCtbepWjT8dt4hz4WJWZDx4qNjr+yZ +5pQBkVsTHH8zmsgKUz0xQacKA9wjoI= Date: Thu, 5 Oct 2023 22:04:28 +0800 MIME-Version: 1.0 Subject: Re: [PATCH v4 2/2] mm: Init page count in reserve_bootmem_region when MEMINIT_EARLY Content-Language: en-US To: Mike Rapoport Cc: David Hildenbrand , akpm@linux-foundation.org, mike.kravetz@oracle.com, muchun.song@linux.dev, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230929100252.GW3303@kernel.org> <15233624-f32e-172e-b2f6-7ca7bffbc96d@linux.dev> <20231001185934.GX3303@kernel.org> <90342474-432a-9fe3-2f11-915a04f0053f@linux.dev> <20231002084708.GZ3303@kernel.org> <20231002111051.GA3303@kernel.org> <3057dab3-19f2-99ca-f125-e91a094975ed@redhat.com> <8c9ee3bd-6d71-4111-8f4e-91bc52b42ed4@linux.dev> <20231005050619.GB3303@kernel.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yajun Deng In-Reply-To: <20231005050619.GB3303@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:58:39 -0700 (PDT) On 2023/10/5 13:06, Mike Rapoport wrote: > On Tue, Oct 03, 2023 at 10:38:09PM +0800, Yajun Deng wrote: >> On 2023/10/2 19:25, David Hildenbrand wrote: >>> On 02.10.23 13:10, Mike Rapoport wrote: >>>>>> That 'if' breaks the invariant that __free_pages_core is >>>>>> always called for >>>>>> pages with initialized page count. Adding it may lead to >>>>>> subtle bugs and >>>>>> random memory corruption so we don't want to add it at the >>>>>> first place. >>>>> As long as we have to special-case memory hotplug, we know that we are >>>>> always coming via generic_online_page() in that case. We could >>>>> either move >>>>> some logic over there, or let __free_pages_core() know what it >>>>> should do. >>>> Looks like the patch rather special cases MEMINIT_EARLY, although I >>>> didn't >>>> check throughfully other code paths. >>>> Anyway, relying on page_count() to be correct in different ways for >>>> different callers of __free_pages_core() does not sound right to me. >>> Absolutely agreed. >>> >> I already sent v5  a few days ago. Comments, please... > Does it address all the feedback from this thread? > Except hotplug. As far as I konw, we only clear page count in MEMINIT_EARLY and all tail pages in compound page. So adding 'if (page_count(page))' will have no actual effect for other case. According to previous data, it didn't become slower in hotplug.