Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1471965rdh; Mon, 25 Sep 2023 14:00:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHknhTyqQrwG6MHupdN7zKr9HkzY++CmiFP+oBFkVdf4pl943T7OLJapPBiY07Z/0/g45KY X-Received: by 2002:a17:90b:3b8d:b0:274:9a85:2596 with SMTP id pc13-20020a17090b3b8d00b002749a852596mr5500484pjb.32.1695675645438; Mon, 25 Sep 2023 14:00:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695675645; cv=none; d=google.com; s=arc-20160816; b=0UOS+hEeHAaLRbJu698xRCqfPPM5qIEeGGXx1PTjbiA/AtJ3LrG9PhChcctnPATkPX m1IlyratDbLWaYQwxa1enNmlHlra0wSpac61QG8OgtwyfQO0CFBc13KXslLF0qh4tsC6 Xh+uO/TxnXEtYSRvz+0vce6PW0A/F4GCtn/MwjGDC1pb25r/f13jR9OWPJkrQB0fQ6CT hK3DrSOxPpF+Tn5jaCo6GFaEF5HRJ2RQcK9w2Q1B3d9SgSzXS2zcmHrf8kujUwD98V6Y aUKnX+W2aExVnXf+ZjcwkSh6mdvcyLATEt/aa0xDJM1H8fpTG5YAzabnzD0y9vvsJ75l UEkQ== 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=N6W8dzhWNTrYSwHnH9gHWcZYHgeucRQvEBY6XvFiEgk=; fh=dxt/6D7O8/mk25BON3d8Otwv9nkDJZEMuinSuDWzeUQ=; b=lGeTlxEeyUHDuX2l+F/t5fBRq13Hmp5mMiTapsVJGBU39e57OiVJr+4MqDQ/leWdCQ f1bXXxGs4m1SkcHPxeWgEOniL3AeL/5GJKnqWt9yQzANv3yBAmrKDZWmBitaU5dJbwuR q8Ewt6xYbFUGiScABaRdRH/4s/8PNKqOGF4j3f8UAuEIOizQhrR4JYkTT8i9vQbPIkso vlvnipdxoUTJZx+wQy5QDsTfh3Ievzt+TCESXOqaZvL3Zu3IszgzJEqsqSsKM2N8MdBe dChnPnb0ThRxK+vp4iZi1hYZQO2Oa4h8fFFx3cToHFwcGo4CmTw6NDxWPGu7ulIjURG+ getg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=r+oxEIY5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a13-20020a17090a8c0d00b00263a985aba5si12884959pjo.149.2023.09.25.14.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 14:00:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=r+oxEIY5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0FCF08059E48; Mon, 25 Sep 2023 08:10:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232603AbjIYPKy (ORCPT + 99 others); Mon, 25 Sep 2023 11:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbjIYPKv (ORCPT ); Mon, 25 Sep 2023 11:10:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B0E197 for ; Mon, 25 Sep 2023 08:10:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67C99C433C7; Mon, 25 Sep 2023 15:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1695654644; bh=RSzIWUOnE7T8XNeVBMrB6XLnBz1gFcQH4H/BZEvdBF4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=r+oxEIY58+50ytAKbsVPV0M2wse/nGBiBuuL5gcaM9mUUq7mqFXP7UPdZd0BkYs8h I+MIOej3TQU05+ddc47d8Joo9ZsnGYZ2fmXKUhjhM5DLrab+9YhUjJU3M+ZahA6Zdv 15ZV9Skb0m37hBV8ibemCTIIGMllW5UTHktJ5KOo= Date: Mon, 25 Sep 2023 08:10:43 -0700 From: Andrew Morton To: Yajun Deng Cc: rppt@kernel.org, mike.kravetz@oracle.com, muchun.song@linux.dev, willy@infradead.org, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm: pass page count and reserved to __init_single_page Message-Id: <20230925081043.b4256d18f150e54ee7cb9c99@linux-foundation.org> In-Reply-To: <20230925072150.386880-2-yajun.deng@linux.dev> References: <20230925072150.386880-1-yajun.deng@linux.dev> <20230925072150.386880-2-yajun.deng@linux.dev> 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=-5.9 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 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 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:10:52 -0700 (PDT) On Mon, 25 Sep 2023 15:21:49 +0800 Yajun Deng wrote: > When we init a single page, we need to mark this page reserved if it > does. And some pages may not need to set page count, such as compound > pages. > > Introduce INIT_PAGE_COUNT and INIT_PAGE_RESERVED, let the caller > decide if it needs to set page count and mark page reserved or not. > > ... > > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -3196,7 +3196,7 @@ static void __init hugetlb_folio_init_tail_vmemmap(struct folio *folio, > for (pfn = head_pfn + start_page_number; pfn < end_pfn; pfn++) { > struct page *page = pfn_to_page(pfn); > > - __init_single_page(page, pfn, zone, nid); > + __init_single_page(page, pfn, zone, nid, INIT_PAGE_COUNT); > prep_compound_tail((struct page *)folio, pfn - head_pfn); > ret = page_ref_freeze(page, 1); > VM_BUG_ON(!ret); > diff --git a/mm/internal.h b/mm/internal.h > index 7a961d12b088..e9366cce461c 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -1209,8 +1209,14 @@ struct vma_prepare { > struct vm_area_struct *remove2; > }; > > +enum { > + INIT_PAGE_COUNT = (1 << 0), > + INIT_PAGE_RESERVED = (1 << 1), > +}; It would be neater to give this enum a name > void __meminit __init_single_page(struct page *page, unsigned long pfn, > - unsigned long zone, int nid); > + unsigned long zone, int nid, > + unsigned int flags); Then use this enum for `flags'.