From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033FBE9271C for ; Thu, 5 Oct 2023 15:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234196AbjJEPpn (ORCPT ); Thu, 5 Oct 2023 11:45:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233673AbjJEPpA (ORCPT ); Thu, 5 Oct 2023 11:45:00 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6153821A21 for ; Thu, 5 Oct 2023 07:32:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD21DC433CD; Thu, 5 Oct 2023 05:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696482444; bh=q9gwVh9i7yhacKF0+Y1E5YalBV+GiHWLIMRRh+7yaJA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZPQxDQ2PwLXpWqinMgBQRN97ZkH0MQvovaLYeB4w1HxqXKfBITyukOtR5Xeh5LdEG YwhgvHjqCW3tRJlrBa+d6p9p/oIr6QBMEY0T32z1OQtcqRIVP2oVnf8jAKzaLI6x4p PEZbiQJO0vA8Xzad3bEqwkDQsjyVs7nj2fwqc53z32HUG6UIeV7UfaRZbde0jTR5LQ XwqKUqwZkzLSQCgA9+E7jQyTi1MVSEgZhvhsNPhKInezo6YkvmMnrUgVkkLorfp7b9 6CO1kMKHWltCupII9JDmmCz/JMmriijlTQY2+euPnxiu0X5iDoWDR7wFXUKxerljuf KcvLNPfoOvCzQ== Date: Thu, 5 Oct 2023 08:06:19 +0300 From: Mike Rapoport To: Yajun Deng 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 Subject: Re: [PATCH v4 2/2] mm: Init page count in reserve_bootmem_region when MEMINIT_EARLY Message-ID: <20231005050619.GB3303@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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8c9ee3bd-6d71-4111-8f4e-91bc52b42ed4@linux.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- Sincerely yours, Mike.