From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796351326; b=NONTpmCzUs8Swrg/Ri0KywZTte3HC/zbb4GZT1NcmtiOOT6RjMipkRexTgnM0ERuHrYy CHjfkCl5umZeNS5RG51njhVr4ZLbQonCrq38l976NfLjLdK+77N6vIhsNqkMz2JaK1Fs6 vNRhR0I5DF1bZfrOgoNCoe7NvFpEsvOUhhPLMjJistodeG7AvY7vVHG50TBDaGSryThFk ug4NALuiUyXeX/uqamZCw7RU07ZOQ+r2G9VR4Kvu9w/fVqnMgCtpmYCc5XiEqQkNhn1hH N0hfIUL3hJQMoGie05660Vd+kEF/4zQ+i8TM/16uiB2voN4joEQ+N0Q5bB7CGQD+j9g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796351326; h=Received:DKIM-Signature:Received:Received:X-ME-Sender:X-ME-Received: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=RUtngutP0HpmTgN+8AL+gbVwH0LIx7nmQcFggZwW+DM=; b=Z1LUHOqbdI+1V60ySQaINIGrzsmu6hVdvz5X1nVmVC8Kd3WIQGU4QfjB0I+LlOGHc1TV 3znxNAo/jgqm4QPkIcaRJYxAkrsM/+vIZ9n1U7HUfxtsHXywKy5UoAAJ5og4ivfGn3Fje stQxuG25FM/SVtIaVru5sTXj1mr3i+SCatis8wdlIXdASDAVw2WJ+2Q01pAg3AI0Cm2pU sMuav5xQ83DDY23WdjvIJmnjD1KToBBjdrBlWpk0bBXKrC8+WGJx1mDFUuBiRmRoJ4ppI S5OBMl1lZHNzJdAyl96JFjZesulUELZ7jo/hdSlkG95NW75NSeVOdKmfshIo2U2bzxQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LAXm51Ch; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97D44606A322 for ; Fri, 4 Dec 2026 02:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LAXm51Ch Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABD241F00931; Fri, 4 Dec 2026 02:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796351326; bh=RUtngutP0HpmTgN+8AL+gbVwH0LIx7nmQcFggZwW+DM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=LAXm51ChHh07UNOvh1wVjnJAVJyu2K0xh8OsgaJIDY/8webj7wPicVZRQDlpVz4oN 1RbRAOGpN0H9gOQC4WigJYZMz3GtfqYmKwPp5yg3d5Fmvpneh4iNY7MX+DDk7AVwbm WJkEUH0Q10k9ccUcw0jVWo+FvU5356sPNdLR0we2Xq8iijeZjMfBUZ2yKYATa4ym7E g4ijScCPZuZiRb1+bena+GmuAYGzeW/dFfK8NhWGffZuu9FORbMVn+XO9l3ux3SFdo Wxxt30tmHZtqXGmArbqk8tRjQVjjh/EeWcN6V/bfvLClHBM6xGr2JIfQLi/XS1Id3F K1J8nnCmSKB+A== Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfauth.ams.internal (Postfix) with ESMTP id EBF0B198003A; Thu, 3 Dec 2026 21:28:41 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Thu, 03 Dec 2026 21:28:44 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGW1tg9NiKOtbXdCYfuCuTWRr23u69f4GeOg3pyKOC7cMHhjWRrN+LDnY2CuDT+uE zDxWeompOkcTEuOQAYn0Ut24QRTHv8/miUq6b2UpucbZG4oLSPz12NpyDHODybvjXzeNaG xAl37zPg5vnX6M+iFhIj6Gln62IcJIlHrx26CclO2L7qI1JUSB6LHf0AvKOccv/wOQcyu/ a70c8iKg9VTNmdiCZZfCTGBJaUdhoR14KOEhx/n29trq2dd3lMO4xv4pyYFRr8bdCPXU6t sdwB9uYEqb968kVbft59si+Dk6UeRo4XG0VjfAZxbq7xcnHlASsKH6xA8W6wGP144Pdztu dPwnZwWdU7IoCwmEkPLo9BUFAYy7LVADiGB28EJl5nPFdIBjBteeofzEeih0KKLOn49cs4 UumlZ0oD9OohPpV+qlyFXEmHBWCx8DcDRsVJ4YzRF00xhGDfJwqDuhHDYU69uYePQ9KX2f VRlJaHX/YrvcmsG+yy2Ab/CS5AHsmU2YghlXq/O9nh5ZTCD0rhkaJ92u4JRhWkqN3APDrA PeKJAef0p0x9l7KJXOQbGUIdt1v4RdmymR/yFLcbWb6FPAAaUCKzfLYuaJDUvds15gUjH8 NHCUEyhU/2X42qse587rXoX2rRnYmyNEHVEmGmACmz1BzDqZYuhmk5643PMw X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Dec 2026 21:28:40 -0500 (EST) Date: Thu, 3 Dec 2026 18:28:39 -0800 From: "Kiryl Shutsemau (Meta)" To: Pankaj Gupta Cc: Andrew Morton , Vlastimil Babka , Johannes Weiner , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , Tom Lendacky , Farrah Chen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, pankaj.gupta.linux@gmail.com Subject: Re: [PATCH 0/2] mm/page_alloc: fix lazy memory acceptance before watermarks are set Message-ID: References: <20261130172641.237214-1-pankaj.gupta@amd.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261130172641.237214-1-pankaj.gupta@amd.com> On Mon, Nov 30, 2026 at 11:26:39AM -0600, Pankaj Gupta wrote: > Lazy memory acceptance should accept memory only when it is needed. > Since commit 800f1059c99e ("mm/page_alloc: fix memory accept before > watermarks gets initialized"), one MAX_PAGE_ORDER page is accepted on > every page allocation until the zone watermarks are set. On a 19 GiB > SEV-SNP guest this accepts about ~14 GiB during boot and hence reduce the > boot time. > > Patch 1 renames cond_accept_memory() to accept_memory_to_wmark(). > > Patch 2 accepts memory before the watermarks are set only when an > allocation cannot be satisfied. > > SEV-SNP guest with 19 GiB of memory, memory left unaccepted after boot, > before and after this change: > > before after > 4 vCPUs 3.1 GiB 14.7 GiB > 64 vCPUs 2.8 GiB 13.9 GiB > > This also reduces the boot time of the guest. Numbers looks iffy to me. The table puts the difference at 11.6 GiB with 4 vCPUs. At 4 MiB per allocation, that is about 3000 page allocations before init_per_zone_wmark_min(). Where do they come from? I traced kmem:mm_page_alloc from boot on a KVM guest. I see a few hundred page allocations before init_per_zone_wmark_min() with 4 vCPUs and about 1,500 with 64. With deferred struct page init, most of ZONE_NORMAL only reaches the unaccepted list in page_alloc_init_late(), and after that there are 72 allocations with 4 vCPUs and 592 with 64. That is 0.3 GiB and 2.3 GiB at most. The number of early allocations also grows several times from 4 to 64 vCPUs, but your numbers barely move. Could you show where the memory gets accepted? nr_unaccepted at the point init_per_zone_wmark_min() runs, on both kernels, would tell how much of the difference comes from this path. -- Kiryl Shutsemau / Kirill A. Shutemov